This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4c437c4289c: [lldb] [Process/elf-core] Fix reading
NetBSD/i386 core dumps (authored by mgorny).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101091/new/
https://reviews.llvm.org/D101091
Files:
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test
Index: lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/Core/x86-32-netbsd-gp.test
@@ -0,0 +1,3 @@
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-netbsd.core | FileCheck %p/Inputs/x86-32-gp.check
+
+register read --all
Index: lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/Core/x86-32-netbsd-addr.test
@@ -0,0 +1,13 @@
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-netbsd.core | FileCheck %s
+
+register read --all
+# CHECK-DAG: eip = 0x08048955
+# CHECK-DAG: eflags = 0x00010282
+# CHECK-DAG: cs = 0x00000037
+# CHECK-DAG: fs = 0x0000004f
+# CHECK-DAG: gs = 0x0000008b
+# CHECK-DAG: ss = 0x0000004f
+# CHECK-DAG: ds = 0x0000004f
+# CHECK-DAG: es = 0x0000004f
+
+# TODO: fix reading fp registers
Index: lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
===================================================================
--- lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -20,6 +20,7 @@
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
#include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
@@ -107,6 +108,9 @@
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
break;
+ case llvm::Triple::x86:
+ reg_interface = new RegisterContextNetBSD_i386(arch);
+ break;
case llvm::Triple::x86_64:
reg_interface = new RegisterContextNetBSD_x86_64(arch);
break;
Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===================================================================
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -55,6 +55,10 @@
enum { NT_REGS = 33, NT_FPREGS = 35 };
}
+namespace I386 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
+}
+
} // namespace NETBSD
namespace OPENBSD {
@@ -106,6 +110,7 @@
{llvm::Triple::Linux, llvm::Triple::x86, llvm::ELF::NT_PRXFPREG},
{llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
{llvm::Triple::NetBSD, llvm::Triple::aarch64, NETBSD::AARCH64::NT_FPREGS},
+ {llvm::Triple::NetBSD, llvm::Triple::x86, NETBSD::I386::NT_FPREGS},
{llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
{llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
};
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
@@ -664,6 +664,32 @@
thread_data.notes.push_back(note);
}
} break;
+ case llvm::Triple::x86: {
+ // Assume order PT_GETREGS, PT_GETFPREGS
+ if (note.info.n_type == NETBSD::I386::NT_REGS) {
+ // If this is the next thread, push the previous one first.
+ if (had_nt_regs) {
+ m_thread_data.push_back(thread_data);
+ thread_data = ThreadData();
+ had_nt_regs = false;
+ }
+
+ thread_data.gpregset = note.data;
+ thread_data.tid = tid;
+ if (thread_data.gpregset.GetByteSize() == 0)
+ return llvm::make_error<llvm::StringError>(
+ "Could not find general purpose registers note in core file.",
+ llvm::inconvertibleErrorCode());
+ had_nt_regs = true;
+ } else if (note.info.n_type == NETBSD::I386::NT_FPREGS) {
+ if (!had_nt_regs || tid != thread_data.tid)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Unexpected order "
+ "of NOTEs PT_GETFPREG before PT_GETREG",
+ llvm::inconvertibleErrorCode());
+ thread_data.notes.push_back(note);
+ }
+ } break;
case llvm::Triple::x86_64: {
// Assume order PT_GETREGS, PT_GETFPREGS
if (note.info.n_type == NETBSD::AMD64::NT_REGS) {
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits