Skip to content

Commit f5994f1

Browse files
committed
Fix empty register set when trying to get size of register
GetSharedRegisterInfoVector is a function to get the singleton of total register info. Also, PrivateGetRegisterCount assumes that we have already filled the object in GetSharedRegisterInfoVector and panic when the object is empty. However, the actually function possess the register info is GetRegisterInfo_i386. Originally, I plan to solve this by only referencing object in GetSharedRegisterInfoVector. However, RegisterInfos_x86_64.h requires the symbol with name g_register_infos in current scope so that the header can append x86_64 registers after it. As a result, I decide to copy the info to the object in GetSharedRegisterInfoVector. Also, reorder the header order and provide tests for debugging 32bit binary on 64bit platform.
1 parent 05a3f76 commit f5994f1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lldb/source/Host/freebsd/Host.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <dlfcn.h>
1919
#include <execinfo.h>
2020

21-
#include "llvm/Object/ELF.h"
22-
2321
#include "lldb/Host/FileSystem.h"
2422
#include "lldb/Host/Host.h"
2523
#include "lldb/Host/HostInfo.h"
@@ -32,6 +30,7 @@
3230
#include "lldb/Utility/Status.h"
3331
#include "lldb/Utility/StreamString.h"
3432

33+
#include "llvm/Object/ELF.h"
3534
#include "llvm/TargetParser/Host.h"
3635

3736
namespace lldb_private {

lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ static std::vector<lldb_private::RegisterInfo> &GetSharedRegisterInfoVector() {
7676

7777
static const RegisterInfo *
7878
GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
79-
static std::vector<lldb_private::RegisterInfo> g_register_infos(
80-
GetSharedRegisterInfoVector());
79+
static std::vector<lldb_private::RegisterInfo> g_register_infos;
8180

8281
// Allocate RegisterInfo only once
8382
if (g_register_infos.empty()) {
@@ -93,6 +92,9 @@ GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
9392
#define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
9493
#include "RegisterInfos_x86_64.h"
9594
#undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
95+
std::vector<lldb_private::RegisterInfo> &shared_regs =
96+
GetSharedRegisterInfoVector();
97+
shared_regs = g_register_infos;
9698
}
9799

98100
return &g_register_infos[0];

0 commit comments

Comments
 (0)