aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/corelow.c37
-rw-r--r--gdb/gdbarch.c32
-rw-r--r--gdb/gdbarch.h10
-rwxr-xr-xgdb/gdbarch.sh5
-rw-r--r--gdb/linux-tdep.c21
6 files changed, 92 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c006224698..35762a90a2c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2017-07-07 John Baldwin <jhb@FreeBSD.org>
+ * corelow.c (get_core_siginfo): Remove.
+ (core_xfer_partial): Use the gdbarch "core_xfer_siginfo" method
+ instead of get_core_siginfo.
+ * gdbarch.sh (core_xfer_siginfo): New gdbarch callback.
+ * gdbarch.h: Re-generate.
+ * gdbarch.c: Re-generate.
+ * linux-tdep.c (linux_core_xfer_siginfo): New.
+ (linux_init_abi): Install gdbarch "core_xfer_siginfo" method.
+
+2017-07-07 John Baldwin <jhb@FreeBSD.org>
+
* corelow.c (thread_section_name): Move to ...
* gdbcore.h (thread_section_name): ... here.
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 578c910bb58..5dbabc79e60 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -668,25 +668,6 @@ 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, ULONGEST len)
-{
- thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
- asection *section = bfd_get_section_by_name (abfd, section_name.c_str ());
- if (section == NULL)
- return -1;
-
- if (!bfd_get_section_contents (abfd, section, readbuf, offset, len))
- return -1;
-
- return len;
-}
-
static enum target_xfer_status
core_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
@@ -874,12 +855,20 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
case TARGET_OBJECT_SIGNAL_INFO:
if (readbuf)
{
- LONGEST l = get_core_siginfo (core_bfd, readbuf, offset, len);
-
- if (l > 0)
+ if (core_gdbarch
+ && gdbarch_core_xfer_siginfo_p (core_gdbarch))
{
- *xfered_len = len;
- return TARGET_XFER_OK;
+ LONGEST l = gdbarch_core_xfer_siginfo (core_gdbarch, readbuf,
+ offset, len);
+
+ if (l >= 0)
+ {
+ *xfered_len = l;
+ if (l == 0)
+ return TARGET_XFER_EOF;
+ else
+ return TARGET_XFER_OK;
+ }
}
}
return TARGET_XFER_E_IO;
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index e5efdfbb265..24521b5e231 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -287,6 +287,7 @@ struct gdbarch
gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix;
gdbarch_core_pid_to_str_ftype *core_pid_to_str;
gdbarch_core_thread_name_ftype *core_thread_name;
+ gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo;
const char * gcore_bfd_target;
int vtable_function_descriptors;
int vbit_in_delta;
@@ -646,6 +647,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of core_xfer_shared_libraries_aix, has predicate. */
/* Skip verify of core_pid_to_str, has predicate. */
/* Skip verify of core_thread_name, has predicate. */
+ /* Skip verify of core_xfer_siginfo, has predicate. */
/* Skip verify of gcore_bfd_target, has predicate. */
/* Skip verify of vtable_function_descriptors, invalid_p == 0 */
/* Skip verify of vbit_in_delta, invalid_p == 0 */
@@ -884,6 +886,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: core_xfer_shared_libraries_aix = <%s>\n",
host_address_to_string (gdbarch->core_xfer_shared_libraries_aix));
fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_core_xfer_siginfo_p() = %d\n",
+ gdbarch_core_xfer_siginfo_p (gdbarch));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: core_xfer_siginfo = <%s>\n",
+ host_address_to_string (gdbarch->core_xfer_siginfo));
+ fprintf_unfiltered (file,
"gdbarch_dump: decr_pc_after_break = %s\n",
core_addr_to_string_nz (gdbarch->decr_pc_after_break));
fprintf_unfiltered (file,
@@ -3797,6 +3805,30 @@ set_gdbarch_core_thread_name (struct gdbarch *gdbarch,
}
int
+gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->core_xfer_siginfo != NULL;
+}
+
+LONGEST
+gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->core_xfer_siginfo != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_core_xfer_siginfo called\n");
+ return gdbarch->core_xfer_siginfo (gdbarch, readbuf, offset, len);
+}
+
+void
+set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch,
+ gdbarch_core_xfer_siginfo_ftype core_xfer_siginfo)
+{
+ gdbarch->core_xfer_siginfo = core_xfer_siginfo;
+}
+
+int
gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index ab7561f8516..1c95301f6f2 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -933,6 +933,16 @@ typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch,
extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr);
extern void set_gdbarch_core_thread_name (struct gdbarch *gdbarch, gdbarch_core_thread_name_ftype *core_thread_name);
+/* Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
+ from core file into buffer READBUF with length LEN. Return the number
+ of bytes read (zero indicates EOF, a negative value indicates failure). */
+
+extern int gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch);
+
+typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo);
+
/* BFD target to use when generating a core file. */
extern int gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 22f5715037b..3aab17f958c 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -755,6 +755,11 @@ M;const char *;core_pid_to_str;ptid_t ptid;ptid
# How the core target extracts the name of a thread from a core file.
M;const char *;core_thread_name;struct thread_info *thr;thr
+# Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
+# from core file into buffer READBUF with length LEN. Return the number
+# of bytes read (zero indicates EOF, a negative value indicates failure).
+M;LONGEST;core_xfer_siginfo;gdb_byte *readbuf, ULONGEST offset, ULONGEST len; readbuf, offset, len
+
# BFD target to use when generating a core file.
V;const char *;gcore_bfd_target;;;0;0;;;pstring (gdbarch->gcore_bfd_target)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 2792cbd4c80..5c7f8a07582 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1127,6 +1127,26 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
error (_("unable to handle request"));
}
+/* Read siginfo data from the core, if possible. Returns -1 on
+ failure. Otherwise, returns the number of bytes read. READBUF,
+ OFFSET, and LEN are all as specified by the to_xfer_partial
+ interface. */
+
+static LONGEST
+linux_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
+ ULONGEST offset, ULONGEST len)
+{
+ thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
+ asection *section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
+ if (section == NULL)
+ return -1;
+
+ if (!bfd_get_section_contents (core_bfd, section, readbuf, offset, len))
+ return -1;
+
+ return len;
+}
+
typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
ULONGEST offset, ULONGEST inode,
int read, int write,
@@ -2516,6 +2536,7 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_core_pid_to_str (gdbarch, linux_core_pid_to_str);
set_gdbarch_info_proc (gdbarch, linux_info_proc);
set_gdbarch_core_info_proc (gdbarch, linux_core_info_proc);
+ set_gdbarch_core_xfer_siginfo (gdbarch, linux_core_xfer_siginfo);
set_gdbarch_find_memory_regions (gdbarch, linux_find_memory_regions);
set_gdbarch_make_corefile_notes (gdbarch, linux_make_corefile_notes);
set_gdbarch_has_shared_address_space (gdbarch,