[Lldb-commits] [lldb] 86a58f1 - [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 16 03:00:25 PDT 2021
Author: Michał Górny
Date: 2021-09-16T12:00:20+02:00
New Revision: 86a58f10284dea118703ecde0ef5b9a4f6e4d8be
URL: https://github.com/llvm/llvm-project/commit/86a58f10284dea118703ecde0ef5b9a4f6e4d8be
DIFF: https://github.com/llvm/llvm-project/commit/86a58f10284dea118703ecde0ef5b9a4f6e4d8be.diff
LOG: [lldb] [DynamicRegisterInfo] Pass name/alt_name via RegisterInfo
Remove the name and alt_name parameters from AddRegister() and instead
pass them via RegisterInfo.name and .alt_name fields. This makes
the API simpler and removes some duplication.
Differential Revision: https://reviews.llvm.org/D109872
Added:
Modified:
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index f3dfa5d57fc85..cc79260d0797f 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -396,14 +396,10 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
}
void DynamicRegisterInfo::AddRegister(RegisterInfo ®_info,
- ConstString ®_name,
- ConstString ®_alt_name,
ConstString &set_name) {
assert(!m_finalized);
const uint32_t reg_num = m_regs.size();
- reg_info.name = reg_name.AsCString();
assert(reg_info.name);
- reg_info.alt_name = reg_alt_name.AsCString(nullptr);
uint32_t i;
if (reg_info.value_regs) {
for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index 7e90454c6d9d9..663fbab578100 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -36,8 +36,6 @@ class DynamicRegisterInfo {
const lldb_private::ArchSpec &arch);
void AddRegister(lldb_private::RegisterInfo ®_info,
- lldb_private::ConstString ®_name,
- lldb_private::ConstString ®_alt_name,
lldb_private::ConstString &set_name);
void Finalize(const lldb_private::ArchSpec &arch);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 5c3f9b4baeae2..c050efbc36545 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -992,19 +992,12 @@ void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
}
}
for (i = 0; i < num_registers; ++i) {
- ConstString name;
- ConstString alt_name;
- if (g_register_infos[i].name && g_register_infos[i].name[0])
- name.SetCString(g_register_infos[i].name);
- if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0])
- alt_name.SetCString(g_register_infos[i].alt_name);
-
if (i <= 15 || i == 25)
- AddRegister(g_register_infos[i], name, alt_name, gpr_reg_set);
+ AddRegister(g_register_infos[i], gpr_reg_set);
else if (i <= 24)
- AddRegister(g_register_infos[i], name, alt_name, sfp_reg_set);
+ AddRegister(g_register_infos[i], sfp_reg_set);
else
- AddRegister(g_register_infos[i], name, alt_name, vfp_reg_set);
+ AddRegister(g_register_infos[i], vfp_reg_set);
}
} else {
// Add composite registers to our primordial registers, then.
@@ -1040,8 +1033,6 @@ void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
// If "match" is true, then we can add extra registers.
if (match) {
for (i = 0; i < num_composites; ++i) {
- ConstString name;
- ConstString alt_name;
const uint32_t first_primordial_reg =
g_comp_register_infos[i].value_regs[0];
const char *reg_name = g_register_infos[first_primordial_reg].name;
@@ -1054,9 +1045,7 @@ void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters(bool from_scratch) {
// The name matches the existing primordial entry. Find and
// assign the offset, and then add this composite register entry.
g_comp_register_infos[i].byte_offset = reg_info->byte_offset;
- name.SetCString(g_comp_register_infos[i].name);
- AddRegister(g_comp_register_infos[i], name, alt_name,
- vfp_reg_set);
+ AddRegister(g_comp_register_infos[i], vfp_reg_set);
}
}
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 87ad0a377ae2e..79c54bce13372 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -578,13 +578,14 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
}
reg_info.name = reg_name.AsCString();
+ reg_info.alt_name = alt_name.AsCString();
// We have to make a temporary ABI here, and not use the GetABI because
// this code gets called in DidAttach, when the target architecture
// (and consequently the ABI we'll get from the process) may be wrong.
if (ABISP abi_sp = ABI::FindPlugin(shared_from_this(), arch_to_use))
abi_sp->AugmentRegisterInfo(reg_info);
- m_register_info_sp->AddRegister(reg_info, reg_name, alt_name, set_name);
+ m_register_info_sp->AddRegister(reg_info, set_name);
} else {
break; // ensure exit before reg_num is incremented
}
@@ -4554,9 +4555,10 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
reg_num_remote = reg_info.kinds[eRegisterKindProcessPlugin] + 1;
++reg_num_local;
reg_info.name = reg_name.AsCString();
+ reg_info.alt_name = alt_name.AsCString();
if (abi_sp)
abi_sp->AugmentRegisterInfo(reg_info);
- dyn_reg_info.AddRegister(reg_info, reg_name, alt_name, set_name);
+ dyn_reg_info.AddRegister(reg_info, set_name);
return true; // Keep iterating through all "reg" elements
});
More information about the lldb-commits
mailing list