[Lldb-commits] [lldb] [lldb] Add isConstant mode for FA locations (PR #110726)
Felipe de Azevedo Piovezan via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 2 07:11:48 PDT 2024
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/110726
>From a23540f5a793d7c9bb115f06a5af0266f8cfb038 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Tue, 24 Sep 2024 09:26:29 -0700
Subject: [PATCH 1/3] [lldb] Add isConstant mode for FA locations
This is similar to 9fe455fd0c7d, but for FA locations instead of register
locations.
This is useful for unwind plans that cannot create abstract unwind rules, but
instead must inspect the state of the program to determine the current CFA.
---
lldb/include/lldb/Symbol/UnwindPlan.h | 12 ++++++++++++
lldb/source/Symbol/UnwindPlan.cpp | 4 ++++
lldb/source/Target/RegisterContextUnwind.cpp | 6 ++++++
3 files changed, 22 insertions(+)
diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h
index e1567c7357d0b5..48c9bef76857c0 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -215,6 +215,7 @@ class UnwindPlan {
isRegisterDereferenced, // FA = [reg]
isDWARFExpression, // FA = eval(dwarf_expr)
isRaSearch, // FA = SP + offset + ???
+ isConstant, // FA = constant
};
FAValue() : m_value() {}
@@ -259,6 +260,15 @@ class UnwindPlan {
m_value.expr.length = len;
}
+ bool IsConstant() const { return m_type == isConstant; }
+
+ void SetIsConstant(uint64_t constant) {
+ m_type = isConstant;
+ m_value.constant = constant;
+ }
+
+ uint64_t GetConstant() const { return m_value.constant; }
+
uint32_t GetRegisterNumber() const {
if (m_type == isRegisterDereferenced || m_type == isRegisterPlusOffset)
return m_value.reg.reg_num;
@@ -329,6 +339,8 @@ class UnwindPlan {
} expr;
// For m_type == isRaSearch
int32_t ra_search_offset;
+ // For m_type = isConstant
+ uint64_t constant;
} m_value;
}; // class FAValue
diff --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp
index a06e7cfd7f5446..25e3676761436e 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -187,6 +187,8 @@ operator==(const UnwindPlan::Row::FAValue &rhs) const {
return !memcmp(m_value.expr.opcodes, rhs.m_value.expr.opcodes,
m_value.expr.length);
break;
+ case isConstant:
+ return m_value.constant == rhs.m_value.constant;
}
}
return false;
@@ -214,6 +216,8 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
case isRaSearch:
s.Printf("RaSearch at SP%+d", m_value.ra_search_offset);
break;
+ case isConstant:
+ s.Printf("0x%" PRIx64, m_value.constant);
}
}
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index b683ea7237de04..8f4def9840712f 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2088,6 +2088,12 @@ bool RegisterContextUnwind::ReadFrameAddress(
UnwindLogMsg("No suitable CFA found");
break;
}
+ case UnwindPlan::Row::FAValue::isConstant: {
+ address = fa.GetConstant();
+ address = abi_sp->FixCodeAddress(address);
+ UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
+ return true;
+ }
default:
return false;
}
>From a4b409d2baa364e7c9b78bc4403410fef211ab69 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Tue, 1 Oct 2024 12:20:17 -0700
Subject: [PATCH 2/3] fixup! [lldb] Add isConstant mode for FA locations
---
lldb/source/Target/RegisterContextUnwind.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index 8f4def9840712f..6cec24f6affc78 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2090,7 +2090,8 @@ bool RegisterContextUnwind::ReadFrameAddress(
}
case UnwindPlan::Row::FAValue::isConstant: {
address = fa.GetConstant();
- address = abi_sp->FixCodeAddress(address);
+ if (abi_sp)
+ address = abi_sp->FixCodeAddress(address);
UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
return true;
}
>From d1cd2a22b6d12f80cf9b2d08c3145c6ff5cb1ef8 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Wed, 2 Oct 2024 07:11:30 -0700
Subject: [PATCH 3/3] fixup! use process method fix address fixup
---
lldb/source/Target/RegisterContextUnwind.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index 6cec24f6affc78..9a4a8db84a9fa5 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -2090,8 +2090,7 @@ bool RegisterContextUnwind::ReadFrameAddress(
}
case UnwindPlan::Row::FAValue::isConstant: {
address = fa.GetConstant();
- if (abi_sp)
- address = abi_sp->FixCodeAddress(address);
+ address = m_thread.GetProcess()->FixDataAddress(address);
UnwindLogMsg("CFA value set by constant is 0x%" PRIx64, address);
return true;
}
More information about the lldb-commits
mailing list