Read and write map files.

This commit is contained in:
Ben Vanik
2013-02-03 03:34:43 -08:00
parent a020072ed7
commit 59ccfdd999
13 changed files with 240 additions and 111 deletions

View File

@@ -49,12 +49,17 @@ public:
ExceptionEntry = 2,
};
virtual ~Symbol() {}
virtual ~Symbol();
SymbolType symbol_type;
const char* name();
void set_name(const char* value);
protected:
Symbol(SymbolType type) : symbol_type(type) {}
Symbol(SymbolType type);
char* name_;
};
class ExceptionEntrySymbol;
@@ -105,7 +110,6 @@ public:
uint32_t start_address;
uint32_t end_address;
char* name;
FunctionType type;
uint32_t flags;
@@ -125,7 +129,6 @@ public:
virtual ~VariableSymbol();
uint32_t address;
char* name;
kernel::KernelExport* kernel_export;
};

View File

@@ -32,22 +32,23 @@ public:
virtual int Analyze();
Symbol* GetSymbol(uint32_t address);
ExceptionEntrySymbol* GetOrInsertExceptionEntry(uint32_t address);
FunctionSymbol* GetOrInsertFunction(uint32_t address);
VariableSymbol* GetOrInsertVariable(uint32_t address);
FunctionSymbol* GetFunction(uint32_t address);
VariableSymbol* GetVariable(uint32_t address);
Symbol* GetSymbol(uint32_t address);
int GetAllVariables(std::vector<VariableSymbol*>& variables);
int GetAllFunctions(std::vector<FunctionSymbol*>& functions);
void Write(const char* file_name);
void Dump();
void DumpFunctionBlocks(FunctionSymbol* fn);
void ReadMap(const char* file_name);
void WriteMap(const char* file_name);
void Dump(FILE* file);
void DumpFunctionBlocks(FILE* file, FunctionSymbol* fn);
protected:
typedef std::tr1::unordered_map<uint32_t, Symbol*> SymbolMap;
typedef std::map<uint32_t, Symbol*> SymbolMap;
typedef std::list<FunctionSymbol*> FunctionList;
int AnalyzeFunction(FunctionSymbol* fn);