From 9015683b1c9a8d301cd846fcc8bf73726310bd4f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 8 Nov 2012 21:16:43 +0000 Subject: gdb * linux-tdep.c (linux_make_siginfo_note): New function. (linux_make_corefile_notes): Use it. * corelow.c (get_core_siginfo): New function. (core_xfer_partial) : New case. gdb/testsuite * gdb.base/siginfo-obj.exp: Create core file. Test siginfo from core files, if possible. * gdb.base/siginfo-thread.c: New file * gdb.base/siginfo-thread.exp: New file bfd * elf.c (elfcore_grok_note) : New case; make pseudosection. --- gdb/corelow.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'gdb/corelow.c') diff --git a/gdb/corelow.c b/gdb/corelow.c index 2080068e514..99611ba2cbf 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -656,6 +656,36 @@ add_to_spuid_list (bfd *abfd, asection *asect, void *list_p) list->pos += 4; } +/* Read siginfo data from the core, if possible. Returns -1 on + failure. Otherwise, returns the number of bytes read. ABFD is the + core file's BFD; READBUF, OFFSET, and LEN are all as specified by + the to_xfer_partial interface. */ + +static LONGEST +get_core_siginfo (bfd *abfd, gdb_byte *readbuf, ULONGEST offset, LONGEST len) +{ + asection *section; + long pid; + char *section_name; + const char *name = ".note.linuxcore.siginfo"; + + if (ptid_get_lwp (inferior_ptid)) + section_name = xstrprintf ("%s/%ld", name, + ptid_get_lwp (inferior_ptid)); + else + section_name = xstrdup (name); + + section = bfd_get_section_by_name (abfd, section_name); + xfree (section_name); + if (section == NULL) + return -1; + + if (!bfd_get_section_contents (abfd, section, readbuf, offset, len)) + return -1; + + return len; +} + static LONGEST core_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, @@ -794,6 +824,11 @@ core_xfer_partial (struct target_ops *ops, enum target_object object, } return -1; + case TARGET_OBJECT_SIGNAL_INFO: + if (readbuf) + return get_core_siginfo (core_bfd, readbuf, offset, len); + return -1; + default: if (ops->beneath != NULL) return ops->beneath->to_xfer_partial (ops->beneath, object, -- cgit v1.2.1