[Lldb-commits] [lldb] r187040 - elf-core: Document offset constants in FreeBSD prstatus parser

Ed Maste emaste at freebsd.org
Wed Jul 24 07:23:37 PDT 2013


Author: emaste
Date: Wed Jul 24 09:23:37 2013
New Revision: 187040

URL: http://llvm.org/viewvc/llvm-project?rev=187040&view=rev
Log:
elf-core: Document offset constants in FreeBSD prstatus parser

Also accomodate struct padding based on arch, for later i386 work.

Modified:
    lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=187040&r1=187039&r2=187040&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Wed Jul 24 09:23:37 2013
@@ -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);
 
-    offset = 36;
-    thread_data->signo = data.GetU32(&offset);
-    offset = 48;
-    len = data.GetByteSize() - offset;
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+    if (log)
+    {
+        if (pr_version > 1)
+            log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
+    }
+
+    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);
 }
 





More information about the lldb-commits mailing list