My Project
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 OptionInline : public ArchOption {
100 public:
101  OptionInline(void) { name = "inline"; }
102  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
103 };
104 
105 class OptionNoReturn : public ArchOption {
106 public:
107  OptionNoReturn(void) { name = "noreturn"; }
108  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
109 };
110 
112 public:
113  OptionStructAlign(void) { name = "structalign"; }
114  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
115 };
116 
117 class OptionWarning : public ArchOption {
118 public:
119  OptionWarning(void) { name = "warning"; }
120  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
121 };
122 
124 public:
125  OptionNullPrinting(void) { name = "nullprinting"; }
126  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
127 };
128 
129 class OptionInPlaceOps : public ArchOption {
130 public:
131  OptionInPlaceOps(void) { name = "inplaceops"; }
132  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
133 };
134 
136 public:
137  OptionConventionPrinting(void) { name = "conventionprinting"; }
138  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
139 };
140 
142 public:
143  OptionNoCastPrinting(void) { name = "nocastprinting"; }
144  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
145 };
146 
148 public:
149  OptionHideExtensions(void) { name="hideextensions"; }
150  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
151 };
152 
154 public:
155  OptionMaxLineWidth(void) { name = "maxlinewidth"; }
156  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
157 };
158 
160 public:
161  OptionIndentIncrement(void) { name = "indentincrement"; }
162  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
163 };
164 
166 public:
167  OptionCommentIndent(void) { name = "commentindent"; }
168  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
169 };
170 
172 public:
173  OptionCommentStyle(void) { name = "commentstyle"; }
174  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
175 };
176 
178 public:
179  OptionCommentHeader(void) { name = "commentheader"; }
180  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
181 };
182 
184 public:
185  OptionCommentInstruction(void) { name = "commentinstruction"; }
186  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
187 };
188 
190 public:
191  OptionIntegerFormat(void) { name = "integerformat"; }
192  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
193 };
194 
195 class OptionSetAction : public ArchOption {
196 public:
197  OptionSetAction(void) { name = "setaction"; }
198  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
199 };
200 
202 public:
203  OptionCurrentAction(void) { name = "currentaction"; }
204  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
205 };
206 
208 public:
209  OptionAllowContextSet(void) { name = "allowcontextset"; }
210  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
211 };
212 
214 public:
215  OptionIgnoreUnimplemented(void) { name = "ignoreunimplemented"; }
216  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
217 };
218 
220 public:
221  OptionErrorUnimplemented(void) { name = "errorunimplemented"; }
222  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
223 };
224 
226 public:
227  OptionErrorReinterpreted(void) { name = "errorreinterpreted"; }
228  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
229 };
230 
232 public:
233  OptionErrorTooManyInstructions(void) { name = "errortoomanyinstructions"; }
234  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
235 };
236 
237 class OptionProtoEval : public ArchOption {
238 public:
239  OptionProtoEval(void) { name = "protoeval"; }
240  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
241 };
242 
244 public:
245  OptionSetLanguage(void) { name = "setlanguage"; }
246  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
247 };
248 
249 class OptionJumpLoad : public ArchOption {
250 public:
251  OptionJumpLoad(void) { name = "jumpload"; }
252  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
253 };
254 
255 class OptionToggleRule : public ArchOption {
256 public:
257  OptionToggleRule(void) { name = "togglerule"; }
258  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
259 };
260 
261 class OptionAliasBlock : public ArchOption {
262 public:
263  OptionAliasBlock(void) { name = "aliasblock"; }
264  virtual string apply(Architecture *glb,const string &p1,const string &p2,const string &p3) const;
265 };
266 
267 #endif
Toggle whether the disassembly engine is allowed to modify context.
Definition: options.hh:207
string name
Name of the option.
Definition: options.hh:34
OptionAllowContextSet(void)
Constructor.
Definition: options.hh:209
Set the number of characters to indent per nested scope.
Definition: options.hh:159
OptionWarning(void)
Constructor.
Definition: options.hh:119
OptionStructAlign(void)
Constructor.
Definition: options.hh:113
Set the extrapop parameter used by the (default) prototype model.
Definition: options.hh:75
OptionConventionPrinting(void)
Constructor.
Definition: options.hh:137
Toggle whether different comment types are emitted by the decompiler in the body of a function...
Definition: options.hh:183
How many characters to indent comment lines.
Definition: options.hh:165
Mark/unmark a specific function with the noreturn property.
Definition: options.hh:105
Base class for options classes that affect the configuration of the Architecture object.
Definition: options.hh:32
Toggle whether a specific Rule is applied in the current Action.
Definition: options.hh:255
Toggle whether cast syntax is emitted by the decompiler or stripped.
Definition: options.hh:141
Set the default prototype model for analyzing unknown functions.
Definition: options.hh:87
OptionCommentInstruction(void)
Constructor.
Definition: options.hh:185
Toggle whether read-only memory locations have their value propagated.
Definition: options.hh:81
Establish a new root Action for the decompiler.
Definition: options.hh:195
OptionCurrentAction(void)
Constructor.
Definition: options.hh:203
OptionNoReturn(void)
Constructor.
Definition: options.hh:107
OptionCommentHeader(void)
Constructor.
Definition: options.hh:179
OptionInPlaceOps(void)
Constructor.
Definition: options.hh:131
Set the maximum number of characters per decompiled line.
Definition: options.hh:153
OptionSetLanguage(void)
Constructor.
Definition: options.hh:245
OptionExtraPop(void)
Constructor.
Definition: options.hh:77
Lightweight (and incomplete) XML parser for marshaling data to and from the decompiler.
OptionErrorTooManyInstructions(void)
Constructor.
Definition: options.hh:233
Set the current language emitted by the decompiler.
Definition: options.hh:243
OptionJumpLoad(void)
Constructor.
Definition: options.hh:251
Set the prototype model to use when evaluating the parameters of the current function.
Definition: options.hh:237
Toggle whether the calling convention is printed when emitting function prototypes.
Definition: options.hh:135
Toggle whether the decompiler attempts to infer constant pointers.
Definition: options.hh:93
OptionIndentIncrement(void)
Constructor.
Definition: options.hh:161
A Dispatcher for possible ArchOption commands.
Definition: options.hh:63
Toggle whether null pointers should be printed as the string "NULL".
Definition: options.hh:123
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
Toggle whether too many instructions in one function body is considered a fatal error.
Definition: options.hh:231
OptionHideExtensions(void)
Constructor.
Definition: options.hh:149
OptionToggleRule(void)
Constructor.
Definition: options.hh:257
OptionMaxLineWidth(void)
Constructor.
Definition: options.hh:155
Set the formatting strategy used by the decompiler to emit integers.
Definition: options.hh:189
Mark/unmark a specific function as inline.
Definition: options.hh:99
An XML element. A node in the DOM tree.
Definition: xml.hh:150
static bool onOrOff(const string &p)
Parse an "on" or "off" string.
Definition: options.cc:25
Toggle whether unimplemented instructions are treated as a fatal error.
Definition: options.hh:219
Toggle whether a warning should be issued if a specific action/rule is applied.
Definition: options.hh:117
Base class for error handling facilities.
Toggle whether unimplemented instructions are treated as a no-operation.
Definition: options.hh:213
Toggle whether the decompiler should try to recover the table used to evaluate a switch.
Definition: options.hh:249
OptionIntegerFormat(void)
Constructor.
Definition: options.hh:191
Toggle whether off-cut reinterpretation of an instruction is a fatal error.
Definition: options.hh:225
OptionNullPrinting(void)
Constructor.
Definition: options.hh:125
OptionErrorUnimplemented(void)
Constructor.
Definition: options.hh:221
OptionErrorReinterpreted(void)
Constructor.
Definition: options.hh:227
OptionCommentIndent(void)
Constructor.
Definition: options.hh:167
OptionCommentStyle(void)
Constructor.
Definition: options.hh:173
OptionNoCastPrinting(void)
Constructor.
Definition: options.hh:143
OptionProtoEval(void)
Constructor.
Definition: options.hh:239
Toggle whether implied extensions (ZEXT or SEXT) are printed.
Definition: options.hh:147
Set how locked data-types on the stack affect alias heuristics.
Definition: options.hh:261
string getName(void) const
Return the name of the option.
Definition: options.hh:36
OptionAliasBlock(void)
Constructor.
Definition: options.hh:263
Toggle whether different comment types are emitted by the decompiler in the header for a function...
Definition: options.hh:177
OptionSetAction(void)
Constructor.
Definition: options.hh:197
OptionIgnoreUnimplemented(void)
Constructor.
Definition: options.hh:215
Toggle a sub-group of actions within a root Action.
Definition: options.hh:201
Alter the "structure alignment" data organization setting.
Definition: options.hh:111
Set the style of comment emitted by the decompiler.
Definition: options.hh:171
OptionReadOnly(void)
Constructor.
Definition: options.hh:83
OptionInline(void)
Constructor.
Definition: options.hh:101
virtual string apply(Architecture *glb, const string &p1, const string &p2, const string &p3) const =0
Apply a particular configuration option to the Architecture.
OptionInferConstPtr(void)
Constructor.
Definition: options.hh:95
Toggle whether in-place operators (+=, *=, &=, etc.) are emitted by the decompiler.
Definition: options.hh:129
OptionDefaultPrototype(void)
Constructor.
Definition: options.hh:89