Ghidra Decompiler Analysis Engine
options.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 
19 #ifndef __ARCH_OPTIONS__
20 #define __ARCH_OPTIONS__
21 
22 #include "error.hh"
23 #include "xml.hh"
24 
25 class Architecture;
26 
32 class ArchOption {
33 protected:
34  string name;
35 public:
36  string getName(void) const { return name; }
37 
49  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const=0;
50  virtual ~ArchOption(void) {}
51  static bool onOrOff(const string &p);
52 };
53 
64  Architecture *glb;
65  map<string,ArchOption *> optionmap;
66  void registerOption(ArchOption *option);
67 public:
69  ~OptionDatabase(void);
70  string set(const string &nm,const string &p1="",const string &p2="",const string &p3="");
71  void parseOne(const Element *el);
72  void restoreXml(const Element *el);
73 };
74 
75 class OptionExtraPop : public ArchOption {
76 public:
77  OptionExtraPop(void) { name = "extrapop"; }
78  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
79 };
80 
81 class OptionReadOnly : public ArchOption {
82 public:
83  OptionReadOnly(void) { name = "readonly"; }
84  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
85 };
86 
88 public:
89  OptionDefaultPrototype(void) { name = "defaultprototype"; }
90  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
91 };
92 
94 public:
95  OptionInferConstPtr(void) { name = "inferconstptr"; }
96  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
97 };
98 
99 class OptionForLoops : public ArchOption {
100 public:
101  OptionForLoops(void) { name = "analyzeforloops"; }
102  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
103 };
104 
105 class OptionInline : public ArchOption {
106 public:
107  OptionInline(void) { name = "inline"; }
108  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
109 };
110 
111 class OptionNoReturn : public ArchOption {
112 public:
113  OptionNoReturn(void) { name = "noreturn"; }
114  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
115 };
116 
118 public:
119  OptionStructAlign(void) { name = "structalign"; }
120  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
121 };
122 
123 class OptionWarning : public ArchOption {
124 public:
125  OptionWarning(void) { name = "warning"; }
126  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
127 };
128 
130 public:
131  OptionNullPrinting(void) { name = "nullprinting"; }
132  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
133 };
134 
135 class OptionInPlaceOps : public ArchOption {
136 public:
137  OptionInPlaceOps(void) { name = "inplaceops"; }
138  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
139 };
140 
142 public:
143  OptionConventionPrinting(void) { name = "conventionprinting"; }
144  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
145 };
146 
148 public:
149  OptionNoCastPrinting(void) { name = "nocastprinting"; }
150  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
151 };
152 
154 public:
155  OptionHideExtensions(void) { name="hideextensions"; }
156  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
157 };
158 
160 public:
161  OptionMaxLineWidth(void) { name = "maxlinewidth"; }
162  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
163 };
164 
166 public:
167  OptionIndentIncrement(void) { name = "indentincrement"; }
168  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
169 };
170 
172 public:
173  OptionCommentIndent(void) { name = "commentindent"; }
174  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
175 };
176 
178 public:
179  OptionCommentStyle(void) { name = "commentstyle"; }
180  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
181 };
182 
184 public:
185  OptionCommentHeader(void) { name = "commentheader"; }
186  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
187 };
188 
190 public:
191  OptionCommentInstruction(void) { name = "commentinstruction"; }
192  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
193 };
194 
196 public:
197  OptionIntegerFormat(void) { name = "integerformat"; }
198  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
199 };
200 
201 class OptionSetAction : public ArchOption {
202 public:
203  OptionSetAction(void) { name = "setaction"; }
204  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
205 };
206 
208 public:
209  OptionCurrentAction(void) { name = "currentaction"; }
210  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
211 };
212 
214 public:
215  OptionAllowContextSet(void) { name = "allowcontextset"; }
216  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
217 };
218 
220 public:
221  OptionIgnoreUnimplemented(void) { name = "ignoreunimplemented"; }
222  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
223 };
224 
226 public:
227  OptionErrorUnimplemented(void) { name = "errorunimplemented"; }
228  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
229 };
230 
232 public:
233  OptionErrorReinterpreted(void) { name = "errorreinterpreted"; }
234  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
235 };
236 
238 public:
239  OptionErrorTooManyInstructions(void) { name = "errortoomanyinstructions"; }
240  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
241 };
242 
243 class OptionProtoEval : public ArchOption {
244 public:
245  OptionProtoEval(void) { name = "protoeval"; }
246  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
247 };
248 
250 public:
251  OptionSetLanguage(void) { name = "setlanguage"; }
252  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
253 };
254 
255 class OptionJumpLoad : public ArchOption {
256 public:
257  OptionJumpLoad(void) { name = "jumpload"; }
258  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
259 };
260 
261 class OptionToggleRule : public ArchOption {
262 public:
263  OptionToggleRule(void) { name = "togglerule"; }
264  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
265 };
266 
267 class OptionAliasBlock : public ArchOption {
268 public:
269  OptionAliasBlock(void) { name = "aliasblock"; }
270  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
271 };
272 
274 public:
275  OptionMaxInstruction(void) { name="maxinstruction"; }
276  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
277 };
278 
280 public:
281  OptionNamespaceStrategy(void) { name = "namespacestrategy"; }
282  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
283 };
284 
285 #endif
OptionCommentHeader
Toggle whether different comment types are emitted by the decompiler in the header for a function.
Definition: options.hh:183
OptionJumpLoad::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:758
OptionSetAction
Establish a new root Action for the decompiler.
Definition: options.hh:201
OptionAllowContextSet
Toggle whether the disassembly engine is allowed to modify context.
Definition: options.hh:213
OptionDatabase::~OptionDatabase
~OptionDatabase(void)
Destructor.
Definition: options.cc:88
OptionDatabase::OptionDatabase
OptionDatabase(Architecture *g)
Construct given the owning Architecture.
Definition: options.cc:48
OptionAllowContextSet::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:608
OptionCurrentAction::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:581
OptionErrorTooManyInstructions::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:694
OptionConventionPrinting::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:391
OptionForLoops
Toggle whether the decompiler attempts to recover for-loop variables.
Definition: options.hh:99
error.hh
Base class for error handling facilities.
OptionErrorTooManyInstructions
Toggle whether too many instructions in one function body is considered a fatal error.
Definition: options.hh:237
OptionMaxInstruction
Maximum number of instructions that can be processed in a single function.
Definition: options.hh:273
OptionIgnoreUnimplemented
Toggle whether unimplemented instructions are treated as a no-operation.
Definition: options.hh:219
OptionStructAlign::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:323
ArchOption::name
string name
Name of the option.
Definition: options.hh:34
OptionAliasBlock::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:820
OptionSetAction::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:558
OptionDefaultPrototype::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:220
OptionJumpLoad
Toggle whether the decompiler should try to recover the table used to evaluate a switch.
Definition: options.hh:255
OptionDefaultPrototype
Set the default prototype model for analyzing unknown functions.
Definition: options.hh:87
OptionExtraPop::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:167
OptionNoReturn::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:298
OptionCommentStyle
Set the style of comment emitted by the decompiler.
Definition: options.hh:177
OptionCommentIndent::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:474
OptionInferConstPtr
Toggle whether the decompiler attempts to infer constant pointers.
Definition: options.hh:93
OptionToggleRule
Toggle whether a specific Rule is applied in the current Action.
Definition: options.hh:261
OptionHideExtensions
Toggle whether implied extensions (ZEXT or SEXT) are printed.
Definition: options.hh:153
OptionDatabase::set
string set(const string &nm, const string &p1="", const string &p2="", const string &p3="")
Issue an option command.
Definition: options.cc:102
OptionCommentInstruction::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:524
OptionCommentIndent
How many characters to indent comment lines.
Definition: options.hh:171
OptionProtoEval
Set the prototype model to use when evaluating the parameters of the current function.
Definition: options.hh:243
Element
An XML element. A node in the DOM tree.
Definition: xml.hh:150
OptionSetLanguage::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:743
OptionDatabase::parseOne
void parseOne(const Element *el)
Unwrap and execute a single option XML tag.
Definition: options.cc:115
OptionSetLanguage
Set the current language emitted by the decompiler.
Definition: options.hh:249
OptionNamespaceStrategy::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:865
OptionIgnoreUnimplemented::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:625
Architecture
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
OptionWarning
Toggle whether a warning should be issued if a specific action/rule is applied.
Definition: options.hh:123
OptionInline
Mark/unmark a specific function as inline.
Definition: options.hh:105
OptionInPlaceOps
Toggle whether in-place operators (+=, *=, &=, etc.) are emitted by the decompiler.
Definition: options.hh:135
OptionInferConstPtr::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:232
OptionReadOnly::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:205
OptionErrorReinterpreted::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:671
OptionProtoEval::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:719
OptionIntegerFormat
Set the formatting strategy used by the decompiler to emit integers.
Definition: options.hh:195
OptionMaxLineWidth
Set the maximum number of characters per decompiled line.
Definition: options.hh:159
OptionMaxInstruction::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:845
ArchOption::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const =0
Apply a particular configuration option to the Architecture.
OptionIntegerFormat::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:544
OptionWarning::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:341
OptionErrorUnimplemented
Toggle whether unimplemented instructions are treated as a fatal error.
Definition: options.hh:225
OptionCommentInstruction
Toggle whether different comment types are emitted by the decompiler in the body of a function.
Definition: options.hh:189
OptionToggleRule::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:780
OptionStructAlign
Alter the "structure alignment" data organization setting.
Definition: options.hh:117
OptionNoCastPrinting
Toggle whether cast syntax is emitted by the decompiler or stripped.
Definition: options.hh:147
OptionExtraPop
Set the extrapop parameter used by the (default) prototype model.
Definition: options.hh:75
OptionCurrentAction
Toggle a sub-group of actions within a root Action.
Definition: options.hh:207
OptionAliasBlock
Set how locked data-types on the stack affect alias heuristics.
Definition: options.hh:267
OptionReadOnly
Toggle whether read-only memory locations have their value propagated.
Definition: options.hh:81
ArchOption::onOrOff
static bool onOrOff(const string &p)
Parse an "on" or "off" string.
Definition: options.cc:25
OptionIndentIncrement
Set the number of characters to indent per nested scope.
Definition: options.hh:165
OptionNamespaceStrategy
How should namespace tokens be displayed.
Definition: options.hh:279
OptionInline::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:272
OptionNoReturn
Mark/unmark a specific function with the noreturn property.
Definition: options.hh:111
xml.hh
Lightweight (and incomplete) XML parser for marshaling data to and from the decompiler.
OptionForLoops::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:258
ArchOption
Base class for options classes that affect the configuration of the Architecture object.
Definition: options.hh:32
OptionConventionPrinting
Toggle whether the calling convention is printed when emitting function prototypes.
Definition: options.hh:141
OptionDatabase::restoreXml
void restoreXml(const Element *el)
Execute a series of option commands passed by XML.
Definition: options.cc:146
OptionInPlaceOps::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:376
OptionMaxLineWidth::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:439
OptionCommentStyle::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:491
OptionErrorReinterpreted
Toggle whether off-cut reinterpretation of an instruction is a fatal error.
Definition: options.hh:231
OptionIndentIncrement::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:456
OptionNullPrinting::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:361
OptionNullPrinting
Toggle whether null pointers should be printed as the string "NULL".
Definition: options.hh:129
OptionHideExtensions::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:421
OptionErrorUnimplemented::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:648
OptionCommentHeader::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:503
OptionNoCastPrinting::apply
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const
Apply a particular configuration option to the Architecture.
Definition: options.cc:406
OptionDatabase
A Dispatcher for possible ArchOption commands.
Definition: options.hh:63