Reverse-rebase the vtable pointers printed to stderr.log.

develop
Alexander Gavrilov 2012-04-12 11:21:25 +04:00
parent 583ccdcc0c
commit 38a8c43a25
2 changed files with 8 additions and 2 deletions

@ -260,8 +260,10 @@ virtual_identity *virtual_identity::get(virtual_ptr instance_ptr)
<< ", previous 0x" << unsigned(p->vtable_ptr) << std::dec << std::endl; << ", previous 0x" << unsigned(p->vtable_ptr) << std::dec << std::endl;
abort(); abort();
} else if (!p->vtable_ptr) { } else if (!p->vtable_ptr) {
uint32_t pv = unsigned(vtable);
pv -= Core::getInstance().vinfo->getRebaseDelta();
std::cerr << "<vtable-address name='" << p->getOriginalName() << "' value='0x" std::cerr << "<vtable-address name='" << p->getOriginalName() << "' value='0x"
<< std::hex << unsigned(vtable) << std::dec << "'/>" << std::endl; << std::hex << pv << std::dec << "'/>" << std::endl;
} }
known[vtable] = p; known[vtable] = p;

@ -53,12 +53,13 @@ namespace DFHack
std::map <std::string, uint32_t> Addresses; std::map <std::string, uint32_t> Addresses;
std::map <std::string, uint32_t> VTables; std::map <std::string, uint32_t> VTables;
uint32_t base; uint32_t base;
int rebase_delta;
std::string version; std::string version;
OSType OS; OSType OS;
public: public:
VersionInfo() VersionInfo()
{ {
base = 0; base = 0; rebase_delta = 0;
version = "invalid"; version = "invalid";
OS = OS_BAD; OS = OS_BAD;
}; };
@ -69,11 +70,13 @@ namespace DFHack
Addresses = rhs.Addresses; Addresses = rhs.Addresses;
VTables = rhs.VTables; VTables = rhs.VTables;
base = rhs.base; base = rhs.base;
rebase_delta = rhs.rebase_delta;
version = rhs.version; version = rhs.version;
OS = rhs.OS; OS = rhs.OS;
}; };
uint32_t getBase () const { return base; }; uint32_t getBase () const { return base; };
int getRebaseDelta() const { return rebase_delta; }
void setBase (const uint32_t _base) { base = _base; }; void setBase (const uint32_t _base) { base = _base; };
void rebaseTo(const uint32_t new_base) void rebaseTo(const uint32_t new_base)
{ {
@ -81,6 +84,7 @@ namespace DFHack
int64_t newx = new_base; int64_t newx = new_base;
int64_t rebase = newx - old; int64_t rebase = newx - old;
base = new_base; base = new_base;
rebase_delta += rebase;
for (auto iter = Addresses.begin(); iter != Addresses.end(); ++iter) for (auto iter = Addresses.begin(); iter != Addresses.end(); ++iter)
iter->second += rebase; iter->second += rebase;
for (auto iter = VTables.begin(); iter != VTables.end(); ++iter) for (auto iter = VTables.begin(); iter != VTables.end(); ++iter)