aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2013-07-24 14:23:37 +0000
committerEd Maste <emaste@freebsd.org>2013-07-24 14:23:37 +0000
commit0422ad8e5e92222f1cd6b5d139d2fed0104015c2 (patch)
tree2e9f26eb4fd808fbae6036faf1b72dc5abfce54b
parent9ec50222b2c80e7943e9e6c8a99028b086de9a20 (diff)
downloadlldb-0422ad8e5e92222f1cd6b5d139d2fed0104015c2.tar.gz
elf-core: Document offset constants in FreeBSD prstatus parser
Also accomodate struct padding based on arch, for later i386 work. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187040 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index bfc68a633..a73a1d645 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -435,17 +435,31 @@ struct ELFNote
}
};
+// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void
ParseFreeBSDPrStatus(ThreadData *thread_data, DataExtractor &data,
ArchSpec &arch)
{
- lldb::offset_t offset;
- size_t len;
+ lldb::offset_t offset = 0;
+ bool have_padding = (arch.GetMachine() == llvm::Triple::x86_64);
+ int pr_version = data.GetU32(&offset);
+
+ Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+ if (log)
+ {
+ if (pr_version > 1)
+ log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
+ }
- offset = 36;
- thread_data->signo = data.GetU32(&offset);
- offset = 48;
- len = data.GetByteSize() - offset;
+ if (have_padding)
+ offset += 4;
+ offset += 28; // pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
+ thread_data->signo = data.GetU32(&offset); // pr_cursig
+ offset += 4; // pr_pid
+ if (have_padding)
+ offset += 4;
+
+ size_t len = data.GetByteSize() - offset;
thread_data->gpregset = DataExtractor(data, offset, len);
}