]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change coredump note names for FreeBSD
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 22 May 2022 11:05:10 +0000 (13:05 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 22 May 2022 11:05:10 +0000 (13:05 +0200)
Was not able to load vgcore files with lldb on FreeBSD.

I think that there is a way to go for lldb / FreeBSD to be able to fully read vgcore files.
See
https://www.moritz.systems/blog/lldb-core-dump-support-improvements/

coregrind/m_coredump/coredump-elf.c

index 0d22d01cbba6cd1030cd0e27514964cf5a15e38e..4a8c29c529a75900680260a49da99a9d2cf9671f 100644 (file)
@@ -699,6 +699,15 @@ void dump_one_thread(struct note **notelist, const vki_siginfo_t *si, ThreadId t
 {
    vki_elf_fpregset_t  fpu;
    struct vki_elf_prstatus prstatus;
+   const HChar* name;
+#  if   !defined(VGO_freebsd)
+   name = "CORE";
+#  else
+   /* lldb on FreeBSD expects a prstatus with name "FreeBSD"
+    * see llvm::Error ProcessElfCore::parseFreeBSDNotes(llvm::ArrayRef<CoreNote> notes) in ProcessElfCore.cpp
+    * Otherwise it exits with "Could not find NT_PRSTATUS note in core file." */
+   name = "FreeBSD";
+#  endif
    VG_(memset)(&fpu, 0, sizeof(fpu));
    VG_(memset)(&prstatus, 0, sizeof(prstatus));
 #     if defined(VGP_x86_linux) && !defined(VGPV_x86_linux_android)
@@ -716,7 +725,7 @@ void dump_one_thread(struct note **notelist, const vki_siginfo_t *si, ThreadId t
          && !defined(VGPV_mips32_linux_android) \
          && !defined(VGPV_arm64_linux_android) \
          && !defined(VGP_nanomips_linux)
-      add_note(notelist, "CORE", NT_FPREGSET, &fpu, sizeof(fpu));
+      add_note(notelist, name, NT_FPREGSET, &fpu, sizeof(fpu));
 #     endif
 
       fill_prstatus(&VG_(threads)[tid], &prstatus, si);
@@ -724,7 +733,7 @@ void dump_one_thread(struct note **notelist, const vki_siginfo_t *si, ThreadId t
          && !defined(VGPV_x86_linux_android) \
          && !defined(VGPV_mips32_linux_android) \
          && !defined(VGPV_arm64_linux_android)
-      add_note(notelist, "CORE", NT_PRSTATUS, &prstatus, sizeof(prstatus));
+      add_note(notelist, name, NT_PRSTATUS, &prstatus, sizeof(prstatus));
 #     endif
 }