Author: Tatsuo Nomura Date: 2020-09-27T12:36:09+02:00 New Revision: e779427757f233ef7bbb381289c63f2399ecca92
URL: https://github.com/llvm/llvm-project/commit/e779427757f233ef7bbb381289c63f2399ecca92 DIFF: https://github.com/llvm/llvm-project/commit/e779427757f233ef7bbb381289c63f2399ecca92.diff LOG: Fix MIPS and MIPS64 ABI to use ConstString in their register info arrays. RegInfoBasedABI::GetRegisterInfoByName was failing because mips/mips64 ABIs don't use ConstString in their register info array. Reviewed By: #lldb, teemperor Differential Revision: https://reviews.llvm.org/D88375 Added: Modified: lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp index d66e0926ad99..a209fa760556 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp @@ -75,7 +75,7 @@ enum dwarf_regnums { 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 RegisterInfo g_register_infos[] = { 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; } diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp index 751555722dac..9a07c3398e19 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp @@ -75,7 +75,7 @@ enum dwarf_regnums { 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 RegisterInfo g_register_infos_mips64[] = { 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; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits