[Lldb-commits] [PATCH] D88375: Fix MIPS and MIPS64 ABI to use ConstString in thier register info arrays.
Tatsuo Nomura via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun Sep 27 02:57:14 PDT 2020
tatsuo created this revision.
tatsuo added reviewers: LLDB, jasonmolenda.
Herald added subscribers: lldb-commits, atanasyan, jrtc27, arichardson, sdardis.
Herald added a project: LLDB.
tatsuo requested review of this revision.
Herald added a subscriber: JDevlieghere.
RegInfoBasedABI::GetRegisterInfoByName was failing because mips/mips64 ABIs don't use ConstString in their register info array.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88375
Files:
lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
===================================================================
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -75,7 +75,7 @@
dwarf_pc
};
-static const RegisterInfo g_register_infos_mips64[] = {
+static RegisterInfo g_register_infos_mips64[] = {
// NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
// DWARF GENERIC PROCESS PLUGIN
// LLDB NATIVE
@@ -542,9 +542,24 @@
static const uint32_t k_num_register_infos =
llvm::array_lengthof(g_register_infos_mips64);
+static bool g_register_info_names_constified = false;
const lldb_private::RegisterInfo *
ABISysV_mips64::GetRegisterInfoArray(uint32_t &count) {
+ // Make the C-string names and alt_names for the register infos into const
+ // C-string values by having the ConstString unique the names in the global
+ // constant C-string pool.
+ if (!g_register_info_names_constified) {
+ g_register_info_names_constified = true;
+ for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+ if (g_register_infos_mips64[i].name)
+ g_register_infos_mips64[i].name =
+ ConstString(g_register_infos_mips64[i].name).GetCString();
+ if (g_register_infos_mips64[i].alt_name)
+ g_register_infos_mips64[i].alt_name =
+ ConstString(g_register_infos_mips64[i].alt_name).GetCString();
+ }
+ }
count = k_num_register_infos;
return g_register_infos_mips64;
}
Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
===================================================================
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
@@ -75,7 +75,7 @@
dwarf_pc
};
-static const RegisterInfo g_register_infos[] = {
+static RegisterInfo g_register_infos[] = {
// NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
// DWARF GENERIC PROCESS PLUGINS
// LLDB NATIVE VALUE REGS INVALIDATE REGS
@@ -542,9 +542,24 @@
static const uint32_t k_num_register_infos =
llvm::array_lengthof(g_register_infos);
+static bool g_register_info_names_constified = false;
const lldb_private::RegisterInfo *
ABISysV_mips::GetRegisterInfoArray(uint32_t &count) {
+ // Make the C-string names and alt_names for the register infos into const
+ // C-string values by having the ConstString unique the names in the global
+ // constant C-string pool.
+ if (!g_register_info_names_constified) {
+ g_register_info_names_constified = true;
+ for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+ if (g_register_infos[i].name)
+ g_register_infos[i].name =
+ ConstString(g_register_infos[i].name).GetCString();
+ if (g_register_infos[i].alt_name)
+ g_register_infos[i].alt_name =
+ ConstString(g_register_infos[i].alt_name).GetCString();
+ }
+ }
count = k_num_register_infos;
return g_register_infos;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88375.294543.patch
Type: text/x-patch
Size: 3084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200927/cec5afdc/attachment.bin>
More information about the lldb-commits
mailing list