Skip to content

Commit a4b7b3f

Browse files
committed
Move all the ELF Nix' flavors to the SigInfo, but don't emit unless we read 0 from NT_SIGINFO
1 parent babd0e1 commit a4b7b3f

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,16 @@ using namespace lldb_private;
4949

5050
// Construct a Thread object with given data
5151
ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
52-
: Thread(process, td.tid), m_thread_reg_ctx_sp(),
53-
m_gpregset_data(td.gpregset), m_notes(td.notes), m_siginfo(std::move(td.siginfo)) {}
52+
: Thread(process, td.tid), m_thread_reg_ctx_sp(), m_thread_name(td.name),
53+
m_gpregset_data(td.gpregset), m_notes(td.notes),
54+
m_siginfo(std::move(td.siginfo)) {}
5455

5556
ThreadElfCore::~ThreadElfCore() { DestroyThread(); }
5657

5758
void ThreadElfCore::RefreshStateAfterStop() {
5859
GetRegisterContext()->InvalidateIfNeeded(false);
5960
}
6061

61-
62-
6362
RegisterContextSP ThreadElfCore::GetRegisterContext() {
6463
if (!m_reg_context_sp) {
6564
m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
@@ -246,9 +245,15 @@ bool ThreadElfCore::CalculateStopInfo() {
246245
if (!unix_signals_sp)
247246
return false;
248247

248+
const char *sig_description;
249+
std::string description = m_siginfo.GetDescription(*unix_signals_sp);
250+
if (description.empty())
251+
sig_description = nullptr;
252+
else
253+
sig_description = description.c_str();
254+
249255
SetStopInfo(StopInfo::CreateStopReasonWithSignal(
250-
*this, m_siginfo.si_signo,
251-
m_siginfo.GetDescription(*unix_signals_sp).c_str(), m_siginfo.si_code));
256+
*this, m_siginfo.si_signo, sig_description, m_siginfo.si_code));
252257

253258
SetStopInfo(m_stop_info_sp);
254259
return true;
@@ -561,6 +566,8 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, const ArchSpec &arch,
561566
return error;
562567
}
563568

569+
// Set that we've parsed the siginfo from a SIGINFO note.
570+
note_type = eNT_SIGINFO;
564571
// Parsing from a 32 bit ELF core file, and populating/reusing the structure
565572
// properly, because the struct is for the 64 bit version
566573
offset_t offset = 0;
@@ -592,18 +599,20 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, const ArchSpec &arch,
592599
return error;
593600
}
594601

595-
std::string
596-
ELFLinuxSigInfo::GetDescription(const lldb_private::UnixSignals &unix_signals) const {
597-
if (unix_signals.GetShouldStop(si_signo) && sigfault.si_addr != 0) {
602+
std::string ELFLinuxSigInfo::GetDescription(
603+
const lldb_private::UnixSignals &unix_signals) const {
604+
if (unix_signals.GetShouldStop(si_signo) && note_type == eNT_SIGINFO) {
598605
if (sigfault.bounds._addr_bnd._upper != 0)
599606
return unix_signals.GetSignalDescription(
600-
si_signo, si_code, sigfault.si_addr,
601-
sigfault.bounds._addr_bnd._lower,
607+
si_signo, si_code, sigfault.si_addr, sigfault.bounds._addr_bnd._lower,
602608
sigfault.bounds._addr_bnd._upper);
603609
else
604610
return unix_signals.GetSignalDescription(si_signo, si_code,
605-
sigfault.si_addr);
611+
sigfault.si_addr);
606612
}
607613

608-
return unix_signals.GetSignalDescription(si_signo, si_code);
614+
// This looks weird, but there is an existing pattern where we don't pass a
615+
// description to keep up with that, we return empty here, and then the above
616+
// function will set the description whether or not this is empty.
617+
return std::string();
609618
}

lldb/source/Plugins/Process/elf-core/ThreadElfCore.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,16 @@ struct ELFLinuxSigInfo {
9898
} bounds;
9999
} sigfault;
100100

101+
enum { eUnspecified, eNT_SIGINFO } note_type;
102+
101103
ELFLinuxSigInfo();
102104

103105
lldb_private::Status Parse(const lldb_private::DataExtractor &data,
104106
const lldb_private::ArchSpec &arch,
105107
const lldb_private::UnixSignals &unix_signals);
106108

107-
std::string GetDescription(const lldb_private::UnixSignals &unix_signals) const;
109+
std::string
110+
GetDescription(const lldb_private::UnixSignals &unix_signals) const;
108111

109112
// Return the bytesize of the structure
110113
// 64 bit - just sizeof
@@ -114,7 +117,7 @@ struct ELFLinuxSigInfo {
114117
static size_t GetSize(const lldb_private::ArchSpec &arch);
115118
};
116119

117-
static_assert(sizeof(ELFLinuxSigInfo) == 48,
120+
static_assert(sizeof(ELFLinuxSigInfo) == 56,
118121
"sizeof ELFLinuxSigInfo is not correct!");
119122

120123
// PRPSINFO structure's size differs based on architecture.
@@ -196,7 +199,8 @@ class ThreadElfCore : public lldb_private::Thread {
196199
m_thread_name.clear();
197200
}
198201

199-
void CreateStopFromSigInfo(const ELFLinuxSigInfo &siginfo, const lldb_private::UnixSignals &unix_signals);
202+
void CreateStopFromSigInfo(const ELFLinuxSigInfo &siginfo,
203+
const lldb_private::UnixSignals &unix_signals);
200204

201205
protected:
202206
// Member variables.

0 commit comments

Comments
 (0)