Add error propagation into Unwinder/Elf objects.
The backtrace offline code uses these error codes to diagnose errors.
In addtion, I've had cases where seeing these errors would help diagnose
failures.
This also allows us to add a few features to indicate why an unwind
terminated (such as max frames exceeded).
Bug: 65682279
Test: Updated unit tests pass.
Change-Id: If82b5092698e8a194016d670efff1320f9b44d50
diff --git a/libunwindstack/Elf.cpp b/libunwindstack/Elf.cpp
index 220e549..f120da2 100644
--- a/libunwindstack/Elf.cpp
+++ b/libunwindstack/Elf.cpp
@@ -134,6 +134,26 @@
return true;
}
+void Elf::GetLastError(ErrorData* data) {
+ if (valid_) {
+ *data = interface_->last_error();
+ }
+}
+
+ErrorCode Elf::GetLastErrorCode() {
+ if (valid_) {
+ return interface_->LastErrorCode();
+ }
+ return ERROR_NONE;
+}
+
+uint64_t Elf::GetLastErrorAddress() {
+ if (valid_) {
+ return interface_->LastErrorAddress();
+ }
+ return 0;
+}
+
// The relative pc is always relative to the start of the map from which it comes.
bool Elf::Step(uint64_t rel_pc, uint64_t adjusted_rel_pc, uint64_t elf_offset, Regs* regs,
Memory* process_memory, bool* finished) {