fix nmtest
test/Makefile: get nmtest to compile test/nmtest.cc: make nmtest actually do something --HG-- extra : convert_revision : 471c02c51355a5145f0d0ce965c2a341076120c0
This commit is contained in:
parent
ce5f326f11
commit
49c8675f01
2 changed files with 36 additions and 28 deletions
|
@ -33,8 +33,8 @@ initest: test/initest.cc base/str.cc base/inifile.cc base/cprintf.cc
|
|||
lrutest: test/lru_test.cc
|
||||
$(CXX) $(CCFLAGS) -o $@ $^
|
||||
|
||||
nmtest: test/nmtest.cc base/object_file.cc base/symtab.cc base/misc.cc base/str.cc
|
||||
$(CXX) $(CCFLAGS) -o $@ $^
|
||||
nmtest: test/nmtest.cc base/output.cc base/hostinfo.cc base/cprintf.cc base/misc.cc base/loader/object_file.cc base/loader/symtab.cc base/misc.cc base/str.cc base/loader/aout_object.cc base/loader/ecoff_object.cc base/loader/elf_object.cc
|
||||
$(CXX) $(CCFLAGS) -I/n/ziff/z/binkertn/build/work/ALPHA_FS -lelf -o $@ $^
|
||||
|
||||
offtest: test/offtest.cc
|
||||
$(CXX) $(CCFLAGS) -o $@ $^
|
||||
|
|
|
@ -30,45 +30,53 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ecoff.hh"
|
||||
#include "base/loader/object_file.hh"
|
||||
#include "base/str.hh"
|
||||
#include "base/loader/symtab.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "base/str.hh"
|
||||
|
||||
using namespace std;
|
||||
Tick curTick;
|
||||
|
||||
ostream *outputStream = &cout;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
EcoffObject obj;
|
||||
if (argc != 3) {
|
||||
cout << "usage: " << argv[0] << " <filename> <symbol>\n";
|
||||
return 1;
|
||||
}
|
||||
if (argc != 2 && argc != 3)
|
||||
panic("usage: %s <filename> <symbol>\n", argv[0]);
|
||||
|
||||
if (!obj.open(argv[1])) {
|
||||
cout << "file not found\n";
|
||||
return 1;
|
||||
}
|
||||
ObjectFile *obj = createObjectFile(argv[1]);
|
||||
if (!obj)
|
||||
panic("file not found\n");
|
||||
|
||||
SymbolTable symtab;
|
||||
obj.loadGlobals(&symtab);
|
||||
obj->loadGlobalSymbols(&symtab);
|
||||
obj->loadLocalSymbols(&symtab);
|
||||
|
||||
if (argc == 2) {
|
||||
SymbolTable::ATable::const_iterator i = symtab.getAddrTable().begin();
|
||||
SymbolTable::ATable::const_iterator end = symtab.getAddrTable().end();
|
||||
while (i != end) {
|
||||
cprintf("%#x %s\n", i->first, i->second);
|
||||
++i;
|
||||
}
|
||||
} else {
|
||||
string symbol = argv[2];
|
||||
Addr address;
|
||||
|
||||
if (symbol[0] == '0' && symbol[1] == 'x') {
|
||||
if (to_number(symbol, address) && symtab.findSymbol(address, symbol))
|
||||
cout << "address = 0x" << hex << address
|
||||
<< ", symbol = " << symbol << "\n";
|
||||
if (to_number(symbol, address) &&
|
||||
symtab.findSymbol(address, symbol))
|
||||
cprintf("address = %#x, symbol = %s\n", address, symbol);
|
||||
else
|
||||
cout << "address = 0x" << hex << address << " was not found\n";
|
||||
cprintf("address = %#x was not found\n", address);
|
||||
} else {
|
||||
if (symtab.findAddress(symbol, address))
|
||||
cout << "symbol = " << symbol << ", address = 0x" << hex
|
||||
<< address << "\n";
|
||||
cprintf("symbol = %s address = %#x\n", symbol, address);
|
||||
else
|
||||
cout << "symbol = " << symbol << " was not found\n";
|
||||
cprintf("symbol = %s was not found\n", symbol);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue