From 38a8c43a25221fdd0dfb21da297cb4c87621d21c Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 12 Apr 2012 11:21:25 +0400 Subject: [PATCH] Reverse-rebase the vtable pointers printed to stderr.log. --- library/DataDefs.cpp | 4 +++- library/include/VersionInfo.h | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp index 76c872445..05988e419 100644 --- a/library/DataDefs.cpp +++ b/library/DataDefs.cpp @@ -260,8 +260,10 @@ virtual_identity *virtual_identity::get(virtual_ptr instance_ptr) << ", previous 0x" << unsigned(p->vtable_ptr) << std::dec << std::endl; abort(); } else if (!p->vtable_ptr) { + uint32_t pv = unsigned(vtable); + pv -= Core::getInstance().vinfo->getRebaseDelta(); std::cerr << "" << std::endl; + << std::hex << pv << std::dec << "'/>" << std::endl; } known[vtable] = p; diff --git a/library/include/VersionInfo.h b/library/include/VersionInfo.h index 7f82163ef..5ff20516e 100644 --- a/library/include/VersionInfo.h +++ b/library/include/VersionInfo.h @@ -53,12 +53,13 @@ namespace DFHack std::map Addresses; std::map VTables; uint32_t base; + int rebase_delta; std::string version; OSType OS; public: VersionInfo() { - base = 0; + base = 0; rebase_delta = 0; version = "invalid"; OS = OS_BAD; }; @@ -69,11 +70,13 @@ namespace DFHack Addresses = rhs.Addresses; VTables = rhs.VTables; base = rhs.base; + rebase_delta = rhs.rebase_delta; version = rhs.version; OS = rhs.OS; }; uint32_t getBase () const { return base; }; + int getRebaseDelta() const { return rebase_delta; } void setBase (const uint32_t _base) { base = _base; }; void rebaseTo(const uint32_t new_base) { @@ -81,6 +84,7 @@ namespace DFHack int64_t newx = new_base; int64_t rebase = newx - old; base = new_base; + rebase_delta += rebase; for (auto iter = Addresses.begin(); iter != Addresses.end(); ++iter) iter->second += rebase; for (auto iter = VTables.begin(); iter != VTables.end(); ++iter)