Add ability to read jit gdb data.
Changes:
- New JitDebug class to handle all of the jit gdb interface.
- Add unit tests for all, along with new offline test using debug data.
- Add new Memory type called MemoryOfflineParts that has multiple
MemoryOffline objects to support the offline test.
- Update the tools to use the JitDebug object.
- Modify libbacktrace to use the JitDebug, but only looking in libart.so
and libartd.so.
- Change the Format32Bits to Is32Bit since it's more accurate and I use
it in a different context where original name didn't make sense.
- Add a new function to find global variables in an elf file
(GetGlobalVariable).
- Add a new function to determine if a pc is valid for this elf (IsValidPc).
Bug: 68396769
Test: Ran new unit tests. Added new offline test that uses jit debug data.
Test: Ran art test that generates jit data and verified a crash unwinds
Test: through the jit data.
Change-Id: I6e7ee2f5bab2242028a06feece156dff21c0a974
diff --git a/libunwindstack/tests/ElfFake.h b/libunwindstack/tests/ElfFake.h
index abf9927..099026c 100644
--- a/libunwindstack/tests/ElfFake.h
+++ b/libunwindstack/tests/ElfFake.h
@@ -21,6 +21,7 @@
#include <deque>
#include <string>
+#include <unordered_map>
#include <unwindstack/Elf.h>
#include <unwindstack/ElfInterface.h>
@@ -55,6 +56,9 @@
void FakeSetLoadBias(uint64_t load_bias) { load_bias_ = load_bias; }
void FakeSetInterface(ElfInterface* interface) { interface_.reset(interface); }
+ void FakeSetGnuDebugdataInterface(ElfInterface* interface) {
+ gnu_debugdata_interface_.reset(interface);
+ }
};
class ElfInterfaceFake : public ElfInterface {
@@ -67,9 +71,14 @@
bool GetSoname(std::string*) override { return false; }
bool GetFunctionName(uint64_t, uint64_t, std::string*, uint64_t*) override;
+ bool GetGlobalVariable(const std::string&, uint64_t*) override;
bool Step(uint64_t, uint64_t, Regs*, Memory*, bool*) override;
+ void FakeSetGlobalVariable(const std::string& global, uint64_t offset) {
+ globals_[global] = offset;
+ }
+
static void FakePushFunctionData(const FunctionData data) { functions_.push_back(data); }
static void FakePushStepData(const StepData data) { steps_.push_back(data); }
@@ -79,6 +88,8 @@
}
private:
+ std::unordered_map<std::string, uint64_t> globals_;
+
static std::deque<FunctionData> functions_;
static std::deque<StepData> steps_;
};