Add elf_local_rip to UnwindContext (debug tool)

This commit is contained in:
Théophile Bastian 2018-04-12 13:24:31 +02:00
parent 4369a4f3cc
commit 242bfce9e1
2 changed files with 14 additions and 0 deletions

View file

@ -107,6 +107,9 @@ class DwarfInterpret {
uintptr_t rip;
uintptr_t rsp;
uintptr_t rbp;
/// This context's `RIP` minus its ELF file load offset
uintptr_t elf_local_rip() const;
};
public: // methods
@ -180,6 +183,12 @@ class DwarfInterpret {
*/
UnwindContext unwind_context(const UnwindContext& ctx);
/** Get the offset for the instruction pointer.
*
* This offset is such that `actual_rip - pc_offset` is the ELF-local
* PC (ie. what readelf gives). */
uintptr_t get_pc_offset() const { return pc_offset; }
private:
DwarfInterpret(const MemoryMap::MapEntry& memory_object);

View file

@ -36,6 +36,11 @@ using namespace dwarf;
MemoryMap DwarfInterpret::memory_map;
map<int, unique_ptr<DwarfInterpret> > DwarfInterpret::instances;
uintptr_t DwarfInterpret::UnwindContext::elf_local_rip() const {
return rip - DwarfInterpret::acquire(rip).get_pc_offset();
}
DwarfInterpret::DwarfInterpret(const MemoryMap::MapEntry& memory_object)
: map_entry(memory_object)
{