Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
19 #ifndef __IFACE_DECOMP__
20 #define __IFACE_DECOMP__
25 #include "callgraph.hh"
27 #ifdef CPUI_RULECOMPILE
28 #include "rulecompile.hh"
48 map<Funcdata*,PrototypePieces> prototypePieces;
49 void storePrototypePieces(
Funcdata *fd_in,
PrototypePieces pp_in ) { prototypePieces.insert(pair<Funcdata*,PrototypePieces>(fd_in,pp_in)); }
52 #ifdef CPUI_RULECOMPILE
53 string experimental_file;
76 virtual void dump(
const Address &addr,
const string &mnem,
const string &body) {
79 for(int4 i=mnem.size();i<mnemonicpad;++i) *s <<
' ';
99 virtual string getModule(
void)
const {
return "decompile"; }
113 virtual void execute(istream &s);
118 virtual void execute(istream &s);
123 virtual void execute(istream &s);
128 virtual void execute(istream &s);
133 virtual void execute(istream &s);
138 virtual void execute(istream &s);
143 virtual void execute(istream &s);
148 virtual void execute(istream &s);
153 virtual void execute(istream &s);
158 virtual void execute(istream &s);
163 virtual void execute(istream &s);
168 virtual void execute(istream &s);
173 virtual void execute(istream &s);
178 virtual void execute(istream &s);
183 virtual void execute(istream &s);
188 virtual void execute(istream &s);
193 virtual void execute(istream &s);
198 virtual void execute(istream &s);
203 virtual void execute(istream &s);
208 virtual void execute(istream &s);
213 virtual void execute(istream &s);
218 virtual void execute(istream &s);
223 virtual void execute(istream &s);
228 virtual void execute(istream &s);
233 virtual void execute(istream &s);
239 virtual void execute(istream &s);
245 virtual void execute(istream &s);
250 virtual void execute(istream &s);
255 virtual void execute(istream &s);
260 virtual void execute(istream &s);
265 virtual void execute(istream &s);
270 virtual void execute(istream &s);
275 virtual void execute(istream &s);
280 virtual void execute(istream &s);
285 virtual void execute(istream &s);
290 virtual void execute(istream &s);
295 virtual void execute(istream &s);
300 virtual void execute(istream &s);
305 virtual void execute(istream &s);
310 virtual void execute(istream &s);
315 virtual void execute(istream &s);
320 virtual void execute(istream &s);
325 virtual void execute(istream &s);
330 virtual void execute(istream &s);
335 virtual void execute(istream &s);
340 virtual void execute(istream &s);
345 virtual void execute(istream &s);
350 virtual void execute(istream &s);
355 virtual void execute(istream &s);
360 virtual void execute(istream &s);
365 virtual void execute(istream &s);
370 virtual void execute(istream &s);
375 virtual void execute(istream &s);
380 virtual void execute(istream &s);
385 virtual void execute(istream &s);
390 virtual void execute(istream &s);
395 virtual void execute(istream &s);
400 virtual void execute(istream &s);
405 virtual void execute(istream &s);
410 virtual void execute(istream &s);
419 virtual void execute(istream &s);
425 virtual void execute(istream &s);
430 virtual void execute(istream &s);
435 virtual void execute(istream &s);
440 virtual void execute(istream &s);
445 virtual void execute(istream &s);
450 virtual void execute(istream &s);
455 virtual void execute(istream &s);
460 virtual void execute(istream &s);
465 virtual void execute(istream &s);
470 virtual void execute(istream &s);
475 virtual void execute(istream &s);
483 virtual void execute(istream &s);
490 virtual void execute(istream &s);
495 virtual void execute(istream &s);
500 virtual void execute(istream &s);
505 virtual void execute(istream &s);
511 virtual void execute(istream &s);
516 virtual void execute(istream &s);
517 static void readPcodeSnippet(istream &s,
string &name,
string &outname,vector<string> &inname,
518 string &pcodestring);
523 virtual void execute(istream &s);
528 virtual void execute(istream &s);
533 virtual void execute(istream &s);
538 virtual void execute(istream &s);
543 virtual void execute(istream &s);
548 virtual void execute(istream &s);
553 virtual void execute(istream &s);
558 virtual void execute(istream &s);
563 virtual void execute(istream &s);
566 #ifdef CPUI_RULECOMPILE
569 virtual void execute(istream &s);
574 virtual void execute(istream &s);
578 #ifdef OPACTION_DEBUG
581 virtual void execute(istream &s);
586 virtual void execute(istream &s);
591 virtual void execute(istream &s);
596 virtual void execute(istream &s);
601 virtual void execute(istream &s);
606 virtual void execute(istream &s);
611 virtual void execute(istream &s);
616 virtual void execute(istream &s);
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2157
Print current function without control-flow: print C flat
Definition: ifacedecomp.hh:211
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1197
Write the forward dominance graph to a file: graph dom <filename>
Definition: ifacedecomp.hh:463
bool quick
Set to true if a quick analysis is desired.
Definition: ifacedecomp.hh:488
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.cc:2277
virtual void execute(istream &s)
Definition: ifacedecomp.cc:858
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1854
Print the raw p-code for the current function: print raw
Definition: ifacedecomp.hh:448
virtual void execute(istream &s)
Definition: ifacedecomp.cc:286
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1531
virtual void execute(istream &s)
Definition: ifacedecomp.cc:329
Mark a constant to be printed in decimal format: force dec <varnode>
Definition: ifacedecomp.hh:358
Override the prototype of a called function: override prototype <address> <declaration>
Definition: ifacedecomp.hh:368
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2350
virtual void execute(istream &s)
Definition: ifacedecomp.cc:3056
virtual IfaceData * createData(void)
Create a specialized data object for this command (and its module)
Definition: ifacedecomp.hh:100
Add a memory range as discoverable global variables: global add <address+size>
Definition: ifacedecomp.hh:388
Write a graph representation of data-flow to a file: graph dataflow <filename>
Definition: ifacedecomp.hh:453
Provide an overriding jump-table for an indirect branch: override jumptable ...
Definition: ifacedecomp.hh:373
virtual void execute(istream &s)
Definition: ifacedecomp.cc:366
Determine the prototype model for all functions: produce prototypes
Definition: ifacedecomp.hh:237
Name global registers: global registers
Definition: ifacedecomp.hh:403
virtual void execute(istream &s)
Definition: ifacedecomp.cc:816
Abstract class for emitting disassembly to an application.
Definition: translate.hh:118
Mark a memory range as read-only: readonly <address+size>
Definition: ifacedecomp.hh:546
Add some terminal capabilities to the command-line interface (IfaceStatus)
Print transform statistics for the decompiler engine: print actionstats
Definition: ifacedecomp.hh:531
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2657
Add a dynamic symbol to the current function: map hash <address> <hash> <typedeclaration>
Definition: ifacedecomp.hh:161
IfaceStatus * status
The console owning this command.
Definition: ifacedecomp.hh:93
void execute(IfaceStatus *status, IfaceDecompData *dcp)
Execute one command for the console.
Definition: ifacedecomp.cc:3273
virtual void execute(istream &s)
Definition: ifacedecomp.cc:790
Create an external ref symbol map externalref <address> <refaddress> [<name>]
Definition: ifacedecomp.hh:171
Create a new function: map function <address> [<functionname>] [nocode]
Definition: ifacedecomp.hh:166
Clear the current architecture/program: clear architecture
Definition: ifacedecomp.hh:146
Create a code label: map label <name> <address>
Definition: ifacedecomp.hh:176
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1605
Structure an external control-flow graph: structure blocks <infile> <outfile>
Definition: ifacedecomp.hh:556
virtual void execute(istream &s)
Definition: ifacedecomp.cc:500
Print any known type definitions: print C types
Definition: ifacedecomp.hh:226
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.hh:105
virtual void execute(istream &s)
Definition: ifacedecomp.cc:478
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2704
Mark a storage location to be split: prefersplit <address+size> <splitsize>
Definition: ifacedecomp.hh:551
Print a description of the current functions control-flow: print tree block
Definition: ifacedecomp.hh:283
Lock in the current function's prototype: prototype lock
Definition: ifacedecomp.hh:423
virtual void execute(istream &s)
Definition: ifacedecomp.cc:926
Make a specific function current: load function <functionname>
Definition: ifacedecomp.hh:136
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1376
virtual void execute(istream &s)
Definition: ifacedecomp.cc:448
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2402
Treat all normal memory as discoverable global variables: global spaces
Definition: ifacedecomp.hh:398
virtual void execute(istream &s)
Definition: ifacedecomp.cc:3027
Varnode * readVarnode(istream &s)
Read a varnode from the given stream.
Definition: ifacedecomp.cc:1320
virtual void execute(istream &s)
Definition: ifacedecomp.cc:894
Change the data-type of a symbol: retype <varname> <typedeclaration>
Definition: ifacedecomp.hh:308
List all functions in leaf order: callgraph list
Definition: ifacedecomp.hh:503
virtual void execute(istream &s)
Definition: ifacedecomp.cc:804
Execute a command script : source <filename>
Definition: ifacedecomp.hh:111
Check for duplicate hashes in functions: duplicate hash
Definition: ifacedecomp.hh:473
virtual void execute(istream &s)
Definition: ifacedecomp.cc:830
Print cover information about a Varnode: print cover varnode <varnode>
Definition: ifacedecomp.hh:338
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1181
virtual void execute(istream &s)
Definition: ifacedecomp.cc:910
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1110
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.cc:2219
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1073
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2562
Definition: callgraph.hh:91
A generic console mode interface and command executor.
Definition: interface.hh:195
Print all Varnodes in the current function: print tree varnode
Definition: ifacedecomp.hh:278
Attach a named symbol to a specific Varnode: name varnode <varnode> <name>
Definition: ifacedecomp.hh:343
Common data shared by decompiler commands.
Definition: ifacedecomp.hh:42
Interface capability point for all decompiler commands.
Definition: ifacedecomp.hh:32
Write decompilation for all functions to a file: produce C <filename>
Definition: ifacedecomp.hh:231
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2142
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2764
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2520
Write the current call-graph to a file: callgraph dump <filename>
Definition: ifacedecomp.hh:481
virtual void execute(istream &s)
Definition: ifacedecomp.cc:727
Print the current function using C syntax:print C
Definition: ifacedecomp.hh:216
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1773
Dump a memory to file: binary <address+size> <filename>
Definition: ifacedecomp.hh:191
virtual void execute(istream &s)
Definition: ifacedecomp.cc:710
Decompile the current function: decompile
Definition: ifacedecomp.hh:196
Count p-code in the current function: count pcode
Definition: ifacedecomp.hh:526
static void readPcodeSnippet(istream &s, string &name, string &outname, vector< string > &inname, string &pcodestring)
Scan a single-line p-code snippet declaration from the given stream.
Definition: ifacedecomp.cc:2730
Map a new symbol into the program: map address <address> <typedeclaration>
Definition: ifacedecomp.hh:156
Mark a memory range as volatile: volatile <address+size>
Definition: ifacedecomp.hh:541
Print all address spaces: print spaces
Definition: ifacedecomp.hh:288
Change when dead code elimination starts: deadcode delay <name> <delay>
Definition: ifacedecomp.hh:383
void iterateFunctionsLeafOrder(void)
Iterate command over all functions in a call-graph traversal.
Definition: ifacedecomp.cc:194
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1096
Disassembly emitter that prints to a console stream.
Definition: ifacedecomp.hh:71
Remove a memory range from discoverable global variables: global remove <address+size>
Definition: ifacedecomp.hh:393
virtual void execute(istream &s)
Definition: ifacedecomp.cc:883
static void check(Funcdata *fd, ostream &s)
Check for duplicate hashes in given function.
Definition: ifacedecomp.cc:2457
virtual void execute(istream &s)
Definition: ifacedecomp.cc:673
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2171
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1233
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1161
Create a control-flow override: override flow <address> branch|call|callreturn|return
Definition: ifacedecomp.hh:378
Reset transform statistics for the decompiler engine: reset actionstats
Definition: ifacedecomp.hh:536
List all current actions and rules for the decompiler: list action
Definition: ifacedecomp.hh:243
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2201
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1681
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2791
Display any overrides for the current function: list override
Definition: ifacedecomp.hh:248
Change the base address of the load image: adjust vma 0xabcd0123
Definition: ifacedecomp.hh:131
Set a break point at the start of an Action: break start <actionname>
Definition: ifacedecomp.hh:268
List known prototype models: list prototypes
Definition: ifacedecomp.hh:253
void iterateScopesRecursive(Scope *scope)
Iterate recursively over all functions in given scope.
Definition: ifacedecomp.cc:152
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1513
virtual void execute(istream &s)
Definition: ifacedecomp.cc:391
Raw components of a function prototype (obtained from parsing source code)
Definition: fspec.hh:1144
Print info about a scope/namespace: print map <name>
Definition: ifacedecomp.hh:438
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.cc:2713
Container for data structures associated with a single function.
Definition: funcdata.hh:45
Perform parameter-id analysis on the current function: print parammeasures
Definition: ifacedecomp.hh:298
Print current output using a specific language: print language <langname>
Definition: ifacedecomp.hh:201
Remove a symbol by name: remove <varname>
Definition: ifacedecomp.hh:313
Read in symbols from the load image: read symbols
Definition: ifacedecomp.hh:151
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1124
IfaceDecompData(void)
Constructor.
Definition: ifacedecomp.cc:214
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1570
virtual string getModule(void) const
Get the formal module name to which this command belongs.
Definition: ifacedecomp.hh:99
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2376
Unlock the current function's prototype: prototype unlock
Definition: ifacedecomp.hh:428
virtual void registerCommands(IfaceStatus *status)
Register commands for this grouping.
Definition: ifacedecomp.cc:32
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1803
void iterateFunctionsAddrOrder(void)
Iterate command over all functions in all scopes.
Definition: ifacedecomp.cc:184
virtual void execute(istream &s)
Definition: ifacedecomp.cc:844
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1261
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2316
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1887
void abortFunction(ostream &s)
Clear references to current function.
Definition: ifacedecomp.cc:247
A command that can be executed from the command line.
Definition: interface.hh:97
Groups of console commands that are discovered by the loader.
Definition: interface.hh:161
virtual void execute(istream &s)
Definition: ifacedecomp.cc:629
Parse a line of C syntax: parse line ...
Definition: ifacedecomp.hh:121
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2830
virtual void execute(istream &s)
Definition: ifacedecomp.cc:570
Display bytes in the load image: dump <address+size>
Definition: ifacedecomp.hh:186
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1417
Build the call-graph for the architecture/program: callgraph build
Definition: ifacedecomp.hh:486
Add a new callother fix-up to the program: fixup callother ...
Definition: ifacedecomp.hh:521
void printRaw(ostream &s) const
Write a raw version of the address to a stream.
Definition: address.hh:276
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1723
Print declarations for any known global variables: print C globals
Definition: ifacedecomp.hh:221
virtual void execute(istream &s)
Definition: ifacedecomp.cc:3331
Print disassembly of a memory range: disassemble [<address1> <address2>]
Definition: ifacedecomp.hh:181
void allocateCallGraph(void)
Allocate the call-graph object.
Definition: ifacedecomp.cc:235
Display all Varnodes in a HighVariable: print high <name>
Definition: ifacedecomp.hh:293
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1047
virtual void execute(istream &s)=0
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.cc:2573
virtual void execute(istream &s)
Definition: ifacedecomp.cc:532
Set a breakpoint when a Rule or Action executes: break action <actionname>
Definition: ifacedecomp.hh:273
Funcdata * fd
Current function active in the console.
Definition: ifacedecomp.hh:44
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1659
Set the value of a register: set track <name> <value> [<startaddress> <endaddress>]
Definition: ifacedecomp.hh:263
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2887
Architecture * conf
Current architecture/program active in the console.
Definition: ifacedecomp.hh:45
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1874
Adjust a decompiler option: option <optionname> [<param1>] [<param2>] [<param3>]
Definition: ifacedecomp.hh:116
Build the call-graph using quick analysis: callgraph build quick
Definition: ifacedecomp.hh:494
CallGraph * cgraph
Call-graph information for the program.
Definition: ifacedecomp.hh:46
Create a new function at an address: load addr <address> [<funcname>]
Definition: ifacedecomp.hh:141
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2854
Root class for all decompiler specific commands.
Definition: ifacedecomp.hh:91
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2808
Print cover info about a HighVariable: print cover varnodehigh <varnode>
Definition: ifacedecomp.hh:328
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1393
virtual void dump(const Address &addr, const string &mnem, const string &body)
The main disassembly emitting method.
Definition: ifacedecomp.hh:76
Print information about a Varnode: print varnode <varnode>
Definition: ifacedecomp.hh:318
Add a new call fix-up to the program: fixup call ...
Definition: ifacedecomp.hh:514
Data specialized for a particular command module.
Definition: interface.hh:85
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1631
virtual void execute(istream &s)
Definition: ifacedecomp.cc:756
virtual void execute(istream &s)
Definition: ifacedecomp.cc:511
Parse a file with C declarations: parse file <filename>
Definition: ifacedecomp.hh:126
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2996
Print the current function with C syntax and XML markup:print C xml
Definition: ifacedecomp.hh:206
virtual void execute(istream &s)
Definition: ifacedecomp.cc:648
virtual void execute(istream &s)
Definition: ifacedecomp.cc:598
IfaceDecompData * dcp
Data common to decompiler commands.
Definition: ifacedecomp.hh:94
Continue decompilation after a break point: continue
Definition: ifacedecomp.hh:443
Print range of locals on the stack: print localrange
Definition: ifacedecomp.hh:433
Run value-set analysis on the current function: analyze range full|partial <varnode>
Definition: ifacedecomp.hh:561
virtual void execute(istream &s)
Definition: ifacedecomp.cc:1834
void followFlow(ostream &s, int4 size)
Generate raw p-code for the current function.
Definition: ifacedecomp.cc:418
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2127
Rename a variable: rename <oldname> <newname>
Definition: ifacedecomp.hh:303
virtual void execute(istream &s)
Definition: ifacedecomp.cc:996
Load the call-graph from a file: callgraph load <filename>
Definition: ifacedecomp.hh:498
Force a branch to be an unstructured goto: force goto <branchaddr> <targetaddr>
Definition: ifacedecomp.hh:363
Print cover info about a HighVariable: print cover high <name>
Definition: ifacedecomp.hh:323
void clearArchitecture(void)
Free all resources for the current architecture/program.
Definition: ifacedecomp.cc:256
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2630
virtual void setData(IfaceStatus *root, IfaceData *data)
Associate a specific data object with this command.
Definition: ifacedecomp.hh:98
virtual void execute(istream &s)
Definition: ifacedecomp.cc:2253
Write a graph representation of control-flow to a file: graph controlflow <filename>
Definition: ifacedecomp.hh:458
void mainloop(IfaceStatus *status)
Execute commands as they become available.
Definition: ifacedecomp.cc:3310
Attach a typed symbol to a specific Varnode: type varnode <varnode> <typedeclaration>
Definition: ifacedecomp.hh:348
Mark a constant to be printed in hex format: force hex <varnode>
Definition: ifacedecomp.hh:353
virtual void execute(istream &s)
Definition: ifacedecomp.cc:3011
virtual void iterationCallback(Funcdata *fd)
Perform the per-function aspect of this command.
Definition: ifacedecomp.cc:2526