diff mbox

Use elfcore_write_linux_prstatus in gdb

Message ID 20160121092855.GJ17028@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Jan. 21, 2016, 9:28 a.m. UTC
The gdb side.  Nothing fancy here, and no support for targets that
need gdbarch_elfcore_write_linux_prstatus, mips n32, sparc64 if
writing any of pr_{u,s,cu,cs}time, and probably x86-64 x32.

Comments

Pedro Alves Jan. 21, 2016, 12:25 p.m. UTC | #1
On 01/21/2016 09:28 AM, Alan Modra wrote:
> The gdb side.  Nothing fancy here, and no support for targets that
> need gdbarch_elfcore_write_linux_prstatus, mips n32, sparc64 if
> writing any of pr_{u,s,cu,cs}time, and probably x86-64 x32.

Thanks a lot for doing all this!  I don't have spare cycles either to
drive this all the way to completion for all archs, I think we can still
move forward with it, by adding a stop-gap implementation those
archs, which just calls elfcore_write_prstatus.  I'll send it along
in a bit.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 4ac6b90..981f8db 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -704,6 +704,9 @@  M:char *:make_corefile_notes:bfd *obfd, int *note_size:obfd, note_size
 # default.
 F:char *:elfcore_write_linux_prpsinfo:bfd *obfd, char *note_data, int *note_size, const struct elf_internal_linux_prpsinfo *info:obfd, note_data, note_size, info
 
+# prstatus, as for prpsinfo
+F:char *:elfcore_write_linux_prstatus:bfd *obfd, char *note_data, int *note_size, const struct elf_internal_linux_prstatus *info:obfd, note_data, note_size, info
+
 # Find core file memory regions
 M:int:find_memory_regions:find_memory_region_ftype func, void *data:func, data
 
@@ -1248,6 +1251,7 @@  struct stap_parse_info;
 struct parser_state;
 struct ravenscar_arch_ops;
 struct elf_internal_linux_prpsinfo;
+struct elf_internal_linux_prstatus;
 struct mem_range;
 struct syscalls_info;
 struct thread_info;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 29f5f3c..03a273e 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1564,9 +1564,31 @@  linux_collect_regset_section_cb (const char *sect_name, int size,
 
   /* PRSTATUS still needs to be treated specially.  */
   if (strcmp (sect_name, ".reg") == 0)
-    data->note_data = (char *) elfcore_write_prstatus
-      (data->obfd, data->note_data, data->note_size, data->lwp,
-       gdb_signal_to_host (data->stop_signal), buf);
+    {
+      struct elf_internal_linux_prstatus prstatus;
+
+      memset (&prstatus, 0, sizeof (prstatus));
+      prstatus.pr_reg = buf;
+      prstatus.pr_reg_size = size;
+      prstatus.pr_pid = data->lwp;
+      prstatus.pr_cursig = gdb_signal_to_host (data->stop_signal);
+      if (gdbarch_elfcore_write_linux_prstatus_p (data->gdbarch))
+	data->note_data = gdbarch_elfcore_write_linux_prstatus (data->gdbarch,
+								data->obfd,
+								data->note_data,
+								data->note_size,
+								&prstatus);
+      else if (gdbarch_ptr_bit (data->gdbarch) == 64)
+	data->note_data = elfcore_write_linux_prstatus64 (data->obfd,
+							  data->note_data,
+							  data->note_size,
+							  &prstatus);
+      else
+	data->note_data = elfcore_write_linux_prstatus32 (data->obfd,
+							  data->note_data,
+							  data->note_size,
+							  &prstatus);
+    }
   else
     data->note_data = (char *) elfcore_write_register_note
       (data->obfd, data->note_data, data->note_size,