diff options
author | Nathan Binkert <binkertn@umich.edu> | 2005-11-20 18:42:12 -0500 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2005-11-20 18:42:12 -0500 |
commit | 63bb46b6d8028ed9c759e4bd0822dd2ad25c926b (patch) | |
tree | 1d0a4d619ff214a92a448d06d78301dbb4aebb50 /base/loader/symtab.cc | |
parent | 4e393f38ec9f3995a8fbd61ffdb0fd6da40b2ee1 (diff) | |
download | gem5-63bb46b6d8028ed9c759e4bd0822dd2ad25c926b.tar.xz |
Serialize the symbol tables
base/loader/symtab.cc:
Add support for clearing out the symbol table
Add support for serializing the symbol table (clear on unserialize)
Don't allow empty symbols to be entered into the table
base/loader/symtab.hh:
Add support for clearing out the symbol table
Add support for serializing the symbol table
sim/system.cc:
Serialize the kernel, console, and palcode symbol tables so that
we can capture any dynamic symbols that are added and so that we
don't have to have the same kernel binary around to get the
symbols right
--HG--
extra : convert_revision : 779888c88aa530f3adcd37dc7600a335951d05f7
Diffstat (limited to 'base/loader/symtab.cc')
-rw-r--r-- | base/loader/symtab.cc | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/base/loader/symtab.cc b/base/loader/symtab.cc index e4590ac62..25f54f9bf 100644 --- a/base/loader/symtab.cc +++ b/base/loader/symtab.cc @@ -31,18 +31,29 @@ #include <string> #include <vector> -#include "sim/host.hh" +#include "base/loader/symtab.hh" #include "base/misc.hh" #include "base/str.hh" -#include "base/loader/symtab.hh" +#include "sim/host.hh" +#include "sim/serialize.hh" using namespace std; SymbolTable *debugSymbolTable = NULL; +void +SymbolTable::clear() +{ + addrTable.clear(); + symbolTable.clear(); +} + bool SymbolTable::insert(Addr address, string symbol) { + if (symbol.empty()) + return false; + if (!addrTable.insert(make_pair(address, symbol)).second) return false; @@ -59,10 +70,8 @@ SymbolTable::load(const string &filename) string buffer; ifstream file(filename.c_str()); - if (!file) { - cerr << "Can't open symbol table file " << filename << endl; - fatal("file error"); - } + if (!file) + fatal("file error: Can't open symbol table file %s\n", filename); while (!file.eof()) { getline(file, buffer); @@ -95,3 +104,34 @@ SymbolTable::load(const string &filename) return true; } + +void +SymbolTable::serialize(const string &base, ostream &os) +{ + paramOut(os, base + ".size", addrTable.size()); + + int i = 0; + ATable::const_iterator p, end = addrTable.end(); + for (p = addrTable.begin(); p != end; ++p) { + paramOut(os, csprintf("%s.addr_%d", base, i), p->first); + paramOut(os, csprintf("%s.symbol_%d", base, i), p->second); + ++i; + } +} + +void +SymbolTable::unserialize(const string &base, Checkpoint *cp, + const string §ion) +{ + clear(); + int size; + paramIn(cp, section, base + ".size", size); + for (int i = 0; i < size; ++i) { + Addr addr; + std::string symbol; + + paramIn(cp, section, csprintf("%s.addr_%d", base, i), addr); + paramIn(cp, section, csprintf("%s.symbol_%d", base, i), symbol); + insert(addr, symbol); + } +} |