[Lldb-commits] [PATCH] D109879: [lldb] [DynamicRegisterInfo] Unset value_regs/invalidate_regs before Finalize()
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 20 01:39:15 PDT 2021
mgorny updated this revision to Diff 373511.
mgorny retitled this revision from "[lldb] [DynamicRegisterInfo] Replace value_regs/invalidate_regs in AddRegister()" to "[lldb] [DynamicRegisterInfo] Unset value_regs/invalidate_regs before Finalize()".
mgorny edited the summary of this revision.
mgorny added a comment.
Unset the pointers instead.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109879/new/
https://reviews.llvm.org/D109879
Files:
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
Index: lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
===================================================================
--- lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Process/Utility/DynamicRegisterInfoTest.cpp
@@ -123,3 +123,29 @@
ASSERT_REG(i1, 16, {}, {b1});
ASSERT_REG(i2, 8, {b2}, {b1, i1});
}
+
+TEST(DynamicRegisterInfoTest, no_finalize_regs) {
+ TestDynamicRegisterInfo info;
+
+ // Add regular registers
+ uint32_t b1 = info.AddTestRegister("b1", 8);
+ uint32_t b2 = info.AddTestRegister("b2", 8);
+
+ // Add a few sub-registers
+ uint32_t s1 = info.AddTestRegister("s1", 4, {b1});
+ uint32_t s2 = info.AddTestRegister("s2", 4, {b2});
+
+ // Add a register with invalidate_regs
+ uint32_t i1 = info.AddTestRegister("i1", 8, {}, {b1});
+
+ // Add a register with indirect invalidate regs to be expanded
+ // TODO: why is it done conditionally to value_regs?
+ uint32_t i2 = info.AddTestRegister("i2", 4, {b2}, {i1});
+
+ ASSERT_REG(b1, LLDB_INVALID_INDEX32);
+ ASSERT_REG(b2, LLDB_INVALID_INDEX32);
+ ASSERT_REG(s1, LLDB_INVALID_INDEX32);
+ ASSERT_REG(s2, LLDB_INVALID_INDEX32);
+ ASSERT_REG(i1, LLDB_INVALID_INDEX32);
+ ASSERT_REG(i2, LLDB_INVALID_INDEX32);
+}
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
===================================================================
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -35,7 +35,7 @@
size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
const lldb_private::ArchSpec &arch);
- void AddRegister(lldb_private::RegisterInfo ®_info,
+ void AddRegister(lldb_private::RegisterInfo reg_info,
lldb_private::ConstString &set_name);
void Finalize(const lldb_private::ArchSpec &arch);
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -395,7 +395,7 @@
return m_regs.size();
}
-void DynamicRegisterInfo::AddRegister(RegisterInfo ®_info,
+void DynamicRegisterInfo::AddRegister(RegisterInfo reg_info,
ConstString &set_name) {
assert(!m_finalized);
const uint32_t reg_num = m_regs.size();
@@ -404,10 +404,16 @@
if (reg_info.value_regs) {
for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
+
+ // invalidate until Finalize() is called
+ reg_info.value_regs = nullptr;
}
if (reg_info.invalidate_regs) {
for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
+
+ // invalidate until Finalize() is called
+ reg_info.invalidate_regs = nullptr;
}
if (reg_info.dynamic_size_dwarf_expr_bytes) {
for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109879.373511.patch
Type: text/x-patch
Size: 3130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210920/49d4da91/attachment.bin>
More information about the lldb-commits
mailing list