[Lldb-commits] [PATCH] D101893: [Process/elf-core] Read PID from FreeBSD prpsinfo
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed May 12 02:52:03 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71e66da04cf1: [Process/elf-core] Read PID from FreeBSD prpsinfo (authored by mgorny).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101893/new/
https://reviews.llvm.org/D101893
Files:
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===================================================================
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -404,12 +404,8 @@
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void ParseFreeBSDPrStatus(ThreadData &thread_data,
const DataExtractor &data,
- const ArchSpec &arch) {
+ bool lp64) {
lldb::offset_t offset = 0;
- bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
- arch.GetMachine() == llvm::Triple::mips64 ||
- arch.GetMachine() == llvm::Triple::ppc64 ||
- arch.GetMachine() == llvm::Triple::x86_64);
int pr_version = data.GetU32(&offset);
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -433,6 +429,27 @@
thread_data.gpregset = DataExtractor(data, offset, len);
}
+// Parse a FreeBSD NT_PRPSINFO note - see FreeBSD sys/procfs.h for details.
+static void ParseFreeBSDPrPsInfo(ProcessElfCore &process,
+ const DataExtractor &data,
+ bool lp64) {
+ lldb::offset_t offset = 0;
+ int pr_version = data.GetU32(&offset);
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ if (log) {
+ if (pr_version > 1)
+ LLDB_LOGF(log, "FreeBSD PRPSINFO unexpected version %d", pr_version);
+ }
+
+ // Skip pr_psinfosz, pr_fname, pr_psargs
+ offset += 108;
+ if (lp64)
+ offset += 4;
+
+ process.SetID(data.GetU32(&offset)); // pr_pid
+}
+
static llvm::Error ParseNetBSDProcInfo(const DataExtractor &data,
uint32_t &cpi_nlwps,
uint32_t &cpi_signo,
@@ -512,6 +529,11 @@
}
llvm::Error ProcessElfCore::parseFreeBSDNotes(llvm::ArrayRef<CoreNote> notes) {
+ ArchSpec arch = GetArchitecture();
+ bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
+ arch.GetMachine() == llvm::Triple::mips64 ||
+ arch.GetMachine() == llvm::Triple::ppc64 ||
+ arch.GetMachine() == llvm::Triple::x86_64);
bool have_prstatus = false;
bool have_prpsinfo = false;
ThreadData thread_data;
@@ -532,10 +554,11 @@
switch (note.info.n_type) {
case ELF::NT_PRSTATUS:
have_prstatus = true;
- ParseFreeBSDPrStatus(thread_data, note.data, GetArchitecture());
+ ParseFreeBSDPrStatus(thread_data, note.data, lp64);
break;
case ELF::NT_PRPSINFO:
have_prpsinfo = true;
+ ParseFreeBSDPrPsInfo(*this, note.data, lp64);
break;
case ELF::NT_FREEBSD_THRMISC: {
lldb::offset_t offset = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101893.344746.patch
Type: text/x-patch
Size: 2806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210512/461456be/attachment-0001.bin>
More information about the lldb-commits
mailing list