summaryrefslogtreecommitdiffstats
path: root/libunwindstack/include
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2018-03-14 18:16:22 -0700
committerChristopher Ferris <cferris@google.com>2018-03-16 23:38:07 -0700
commit11e96fe48a74e6ab97d4de899684d3a61a9d1129 (patch)
tree6a056073b680ed6fe25fb406e5f2b316b991ee3e /libunwindstack/include
parenta411fc65d1fc4c2c1c44d5d0860b31a018b8c9fd (diff)
downloadsystem_core-11e96fe48a74e6ab97d4de899684d3a61a9d1129.tar.gz
system_core-11e96fe48a74e6ab97d4de899684d3a61a9d1129.tar.bz2
system_core-11e96fe48a74e6ab97d4de899684d3a61a9d1129.zip
Always set the sp reg to the cfa for DWARF.
There are a few places where it is assumed that this register is set to the cfa value when interpreting DWARF information. Add a testcase for unwinding art_quick_osr_stub on ARM. Bug: 73954823 Test: Ran libunwindstack/libbacktrace unit tests. Test: Random debuggerd -b of process on a hikey. Test: Ran the 137 art test on host. Change-Id: Ida6ccdc38c3cfeea6b57fe861a0cc127b150b790
Diffstat (limited to 'libunwindstack/include')
-rw-r--r--libunwindstack/include/unwindstack/Regs.h23
-rw-r--r--libunwindstack/include/unwindstack/RegsArm.h12
-rw-r--r--libunwindstack/include/unwindstack/RegsArm64.h12
-rw-r--r--libunwindstack/include/unwindstack/RegsGetLocal.h6
-rw-r--r--libunwindstack/include/unwindstack/RegsMips.h12
-rw-r--r--libunwindstack/include/unwindstack/RegsMips64.h12
-rw-r--r--libunwindstack/include/unwindstack/RegsX86.h12
-rw-r--r--libunwindstack/include/unwindstack/RegsX86_64.h12
8 files changed, 55 insertions, 46 deletions
diff --git a/libunwindstack/include/unwindstack/Regs.h b/libunwindstack/include/unwindstack/Regs.h
index b0e7ea152..4bac47313 100644
--- a/libunwindstack/include/unwindstack/Regs.h
+++ b/libunwindstack/include/unwindstack/Regs.h
@@ -45,8 +45,8 @@ class Regs {
int16_t value;
};
- Regs(uint16_t total_regs, uint16_t sp_reg, const Location& return_loc)
- : total_regs_(total_regs), sp_reg_(sp_reg), return_loc_(return_loc) {}
+ Regs(uint16_t total_regs, const Location& return_loc)
+ : total_regs_(total_regs), return_loc_(return_loc) {}
virtual ~Regs() = default;
virtual ArchEnum Arch() = 0;
@@ -57,6 +57,9 @@ class Regs {
virtual uint64_t pc() = 0;
virtual uint64_t sp() = 0;
+ virtual void set_pc(uint64_t pc) = 0;
+ virtual void set_sp(uint64_t sp) = 0;
+
uint64_t dex_pc() { return dex_pc_; }
void set_dex_pc(uint64_t dex_pc) { dex_pc_ = dex_pc; }
@@ -64,13 +67,10 @@ class Regs {
virtual bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) = 0;
- virtual void SetFromRaw() = 0;
-
virtual bool SetPcFromReturnAddress(Memory* process_memory) = 0;
virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) = 0;
- uint16_t sp_reg() { return sp_reg_; }
uint16_t total_regs() { return total_regs_; }
static ArchEnum CurrentArch();
@@ -80,7 +80,6 @@ class Regs {
protected:
uint16_t total_regs_;
- uint16_t sp_reg_;
Location return_loc_;
uint64_t dex_pc_ = 0;
};
@@ -88,16 +87,10 @@ class Regs {
template <typename AddressType>
class RegsImpl : public Regs {
public:
- RegsImpl(uint16_t total_regs, uint16_t sp_reg, Location return_loc)
- : Regs(total_regs, sp_reg, return_loc), regs_(total_regs) {}
+ RegsImpl(uint16_t total_regs, Location return_loc)
+ : Regs(total_regs, return_loc), regs_(total_regs) {}
virtual ~RegsImpl() = default;
- uint64_t pc() override { return pc_; }
- uint64_t sp() override { return sp_; }
-
- void set_pc(AddressType pc) { pc_ = pc; }
- void set_sp(AddressType sp) { sp_ = sp; }
-
bool Is32Bit() override { return sizeof(AddressType) == sizeof(uint32_t); }
inline AddressType& operator[](size_t reg) { return regs_[reg]; }
@@ -111,8 +104,6 @@ class RegsImpl : public Regs {
}
protected:
- AddressType pc_;
- AddressType sp_;
std::vector<AddressType> regs_;
};
diff --git a/libunwindstack/include/unwindstack/RegsArm.h b/libunwindstack/include/unwindstack/RegsArm.h
index 5af90d3f5..31e6797fa 100644
--- a/libunwindstack/include/unwindstack/RegsArm.h
+++ b/libunwindstack/include/unwindstack/RegsArm.h
@@ -34,17 +34,21 @@ class RegsArm : public RegsImpl<uint32_t> {
RegsArm();
virtual ~RegsArm() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);
diff --git a/libunwindstack/include/unwindstack/RegsArm64.h b/libunwindstack/include/unwindstack/RegsArm64.h
index cb05732ee..0c45ebab8 100644
--- a/libunwindstack/include/unwindstack/RegsArm64.h
+++ b/libunwindstack/include/unwindstack/RegsArm64.h
@@ -34,17 +34,21 @@ class RegsArm64 : public RegsImpl<uint64_t> {
RegsArm64();
virtual ~RegsArm64() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);
diff --git a/libunwindstack/include/unwindstack/RegsGetLocal.h b/libunwindstack/include/unwindstack/RegsGetLocal.h
index 557eace32..81c0af374 100644
--- a/libunwindstack/include/unwindstack/RegsGetLocal.h
+++ b/libunwindstack/include/unwindstack/RegsGetLocal.h
@@ -51,8 +51,6 @@ inline __always_inline void RegsGetLocal(Regs* regs) {
: [base] "+r"(reg_data)
:
: "memory");
-
- regs->SetFromRaw();
}
#elif defined(__aarch64__)
@@ -83,8 +81,6 @@ inline __always_inline void RegsGetLocal(Regs* regs) {
: [base] "+r"(reg_data)
:
: "x12", "x13", "memory");
-
- regs->SetFromRaw();
}
#elif defined(__i386__) || defined(__x86_64__) || defined(__mips__)
@@ -93,8 +89,6 @@ extern "C" void AsmGetRegs(void* regs);
inline void RegsGetLocal(Regs* regs) {
AsmGetRegs(regs->RawData());
-
- regs->SetFromRaw();
}
#endif
diff --git a/libunwindstack/include/unwindstack/RegsMips.h b/libunwindstack/include/unwindstack/RegsMips.h
index 8e3c01f20..709f9e2c7 100644
--- a/libunwindstack/include/unwindstack/RegsMips.h
+++ b/libunwindstack/include/unwindstack/RegsMips.h
@@ -34,17 +34,21 @@ class RegsMips : public RegsImpl<uint32_t> {
RegsMips();
virtual ~RegsMips() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);
diff --git a/libunwindstack/include/unwindstack/RegsMips64.h b/libunwindstack/include/unwindstack/RegsMips64.h
index 8c2d4437f..1de83ea9d 100644
--- a/libunwindstack/include/unwindstack/RegsMips64.h
+++ b/libunwindstack/include/unwindstack/RegsMips64.h
@@ -34,17 +34,21 @@ class RegsMips64 : public RegsImpl<uint64_t> {
RegsMips64();
virtual ~RegsMips64() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);
diff --git a/libunwindstack/include/unwindstack/RegsX86.h b/libunwindstack/include/unwindstack/RegsX86.h
index 1bc145d97..586c9d85c 100644
--- a/libunwindstack/include/unwindstack/RegsX86.h
+++ b/libunwindstack/include/unwindstack/RegsX86.h
@@ -35,19 +35,23 @@ class RegsX86 : public RegsImpl<uint32_t> {
RegsX86();
virtual ~RegsX86() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
void SetFromUcontext(x86_ucontext_t* ucontext);
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);
diff --git a/libunwindstack/include/unwindstack/RegsX86_64.h b/libunwindstack/include/unwindstack/RegsX86_64.h
index 4cd45d4b9..061f479a0 100644
--- a/libunwindstack/include/unwindstack/RegsX86_64.h
+++ b/libunwindstack/include/unwindstack/RegsX86_64.h
@@ -35,19 +35,23 @@ class RegsX86_64 : public RegsImpl<uint64_t> {
RegsX86_64();
virtual ~RegsX86_64() = default;
- virtual ArchEnum Arch() override final;
+ ArchEnum Arch() override final;
uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
- void SetFromRaw() override;
-
bool SetPcFromReturnAddress(Memory* process_memory) override;
bool StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_memory) override;
void SetFromUcontext(x86_64_ucontext_t* ucontext);
- virtual void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
static Regs* Read(void* data);