mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
A first cut at normalizing the structure of sleigh error messages
This commit is contained in:
parent
b0609a1cb3
commit
0ed1540e3a
22 changed files with 661 additions and 408 deletions
|
@ -78,6 +78,8 @@ public:
|
|||
static SubtableSymbol *getCurrentSubtable(const list<WithBlock> &stack);
|
||||
};
|
||||
|
||||
class SleighCompile;
|
||||
|
||||
class ConsistencyChecker {
|
||||
struct OptimizeRecord {
|
||||
int4 writeop;
|
||||
|
@ -91,6 +93,7 @@ class ConsistencyChecker {
|
|||
OptimizeRecord(void) {
|
||||
writeop = -1; readop = -1; inslot=-1; writecount=0; readcount=0; writesection=-2; readsection=-2; opttype=-1; }
|
||||
};
|
||||
SleighCompile *slgh;
|
||||
int4 unnecessarypcode;
|
||||
int4 readnowrite;
|
||||
int4 writenoread;
|
||||
|
@ -99,6 +102,8 @@ class ConsistencyChecker {
|
|||
SubtableSymbol *root_symbol;
|
||||
vector<SubtableSymbol *> postorder;
|
||||
map<SubtableSymbol *,int4> sizemap; // Sizes associated with tables
|
||||
void reportError(const Location* loc, const string &msg);
|
||||
void reportWarning(const Location* loc, const string &msg);
|
||||
OperandSymbol *getOperandSymbol(int4 slot,OpTpl *op,Constructor *ct);
|
||||
void printOpName(ostream &s,OpTpl *op);
|
||||
void printOpError(OpTpl *op,Constructor *ct,int4 err1,int4 err2,const string &message);
|
||||
|
@ -124,7 +129,7 @@ class ConsistencyChecker {
|
|||
void checkUnusedTemps(Constructor *ct,const map<uintb,OptimizeRecord> &recs);
|
||||
void optimize(Constructor *ct);
|
||||
public:
|
||||
ConsistencyChecker(SubtableSymbol *rt,bool unnecessary,bool warndead);
|
||||
ConsistencyChecker(SleighCompile *sleigh, SubtableSymbol *rt,bool unnecessary,bool warndead);
|
||||
bool test(void);
|
||||
bool testTruncations(bool isbigendian);
|
||||
void optimizeAll(void);
|
||||
|
@ -140,8 +145,6 @@ struct FieldContext {
|
|||
FieldContext(VarnodeSymbol *s,FieldQuality *q) { sym=s; qual=q; }
|
||||
};
|
||||
|
||||
class SleighCompile;
|
||||
|
||||
class MacroBuilder : public PcodeBuilder {
|
||||
SleighCompile *slgh;
|
||||
bool haserror;
|
||||
|
@ -150,7 +153,7 @@ class MacroBuilder : public PcodeBuilder {
|
|||
bool transferOp(OpTpl *op,vector<HandleTpl *> ¶ms);
|
||||
virtual void dump( OpTpl *op );
|
||||
void free(void);
|
||||
void reportError(const string &val);
|
||||
void reportError(const Location* loc, const string &val);
|
||||
public:
|
||||
MacroBuilder(SleighCompile *sl,vector<OpTpl *> &ovec,uint4 lbcnt) : PcodeBuilder(lbcnt),outvec(ovec) {
|
||||
slgh = sl; haserror = false; }
|
||||
|
@ -166,7 +169,9 @@ public:
|
|||
class SleighPcode : public PcodeCompile {
|
||||
SleighCompile *compiler;
|
||||
virtual uintb allocateTemp(void);
|
||||
virtual void reportError(const string &msg);
|
||||
virtual const Location *getLocation(SleighSymbol *sym) const;
|
||||
virtual void reportError(const Location* loc, const string &msg);
|
||||
virtual void reportWarning(const Location* loc, const string &msg);
|
||||
virtual void addSymbol(SleighSymbol *sym);
|
||||
public:
|
||||
SleighPcode(void) : PcodeCompile() { compiler = (SleighCompile *)0; }
|
||||
|
@ -191,6 +196,8 @@ private:
|
|||
vector<string> relpath; // Relative path (to cwd) for each filename
|
||||
vector<string> filename; // Stack of current files being parsed
|
||||
vector<int4> lineno; // Current line number for each file in stack
|
||||
map<Constructor *, Location> ctorLocationMap; // Map constructor to its defining parse location
|
||||
map<SleighSymbol *, Location> symbolLocationMap; // Map symbol to its defining parse location
|
||||
int4 userop_count; // Number of userops defined
|
||||
bool warnunnecessarypcode; // True if we warn of unnecessary ZEXT or SEXT
|
||||
bool warndeadtemps; // True if we warn of temporaries that are written but not read
|
||||
|
@ -198,7 +205,10 @@ private:
|
|||
bool warnalllocalcollisions; // True if local export collisions generate individual warnings
|
||||
bool warnallnops; // True if pcode NOPs generate individual warnings
|
||||
vector<string> noplist; // List of individual NOP warnings
|
||||
mutable Location currentLocCache; // Location for (last) request of current location
|
||||
int4 errors;
|
||||
|
||||
const Location* getCurrentLocation(void) const;
|
||||
void predefinedSymbols(void);
|
||||
int4 calcContextVarLayout(int4 start,int4 sz,int4 numbits);
|
||||
void buildDecisionTrees(void);
|
||||
|
@ -220,9 +230,18 @@ private:
|
|||
void checkUniqueAllocation(void);
|
||||
public:
|
||||
SleighCompile(void);
|
||||
void reportError(const string &msg,bool includeline);
|
||||
void reportWarning(const string &msg,bool includeline);
|
||||
const Location *getLocation(Constructor* ctor) const;
|
||||
const Location *getLocation(SleighSymbol *sym) const;
|
||||
string formatStatusMessage(const Location* loc, const string &msg);
|
||||
void reportError(const string &msg);
|
||||
void reportError(const Location *loc, const string &msg);
|
||||
void reportWarning(const string &msg);
|
||||
void reportWarning(const Location *loc, const string &msg);
|
||||
int4 numErrors(void) const { return errors; }
|
||||
void reportInfo(const string &msg);
|
||||
void reportInfo(const Location *loc, const string &msg);
|
||||
|
||||
|
||||
uintb getUniqueAddr(void);
|
||||
void setUnnecessaryPcodeWarning(bool val) { warnunnecessarypcode = val; }
|
||||
void setDeadTempWarning(bool val) { warndeadtemps = val; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue