|
|
59b2e3 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
59b2e3 |
From: Keith Seitz <keiths@redhat.com>
|
|
|
59b2e3 |
Date: Mon, 27 Jul 2020 19:38:20 -0400
|
|
|
59b2e3 |
Subject: gdb-rhbz1842691-corefile-mem-access-10of15.patch
|
|
|
59b2e3 |
|
|
|
59b2e3 |
;; gcore command: Place all file-backed mappings in NT_FILE note
|
|
|
59b2e3 |
;; Kevin Buettner, RH BZ 1842961
|
|
|
59b2e3 |
|
|
|
59b2e3 |
Author: Kevin Buettner <kevinb@redhat.com>
|
|
|
59b2e3 |
Date: Wed Jul 1 06:34:50 2020 -0700
|
|
|
59b2e3 |
|
|
|
59b2e3 |
gcore command: Place all file-backed mappings in NT_FILE note
|
|
|
59b2e3 |
|
|
|
59b2e3 |
When making a core file with the GDB's gcore command on Linux,
|
|
|
59b2e3 |
the same criteria used for determining which mappings should be
|
|
|
59b2e3 |
dumped were also being used for determining which entries should
|
|
|
59b2e3 |
be placed in the NT_FILE note. This is wrong; we want to place
|
|
|
59b2e3 |
all file-backed mappings in this note.
|
|
|
59b2e3 |
|
|
|
59b2e3 |
The predicate function, dump_mapping_p, was used to determine whether
|
|
|
59b2e3 |
or not to dump a mapping from within linux_find_memory_regions_full.
|
|
|
59b2e3 |
This commit leaves this predicate in place, but adds a new parameter,
|
|
|
59b2e3 |
should_dump_mapping_p, to linux_find_memory_regions_full. It then
|
|
|
59b2e3 |
calls should_dump_mapping_p instead of dump_mapping_p. dump_mapping_p
|
|
|
59b2e3 |
is passed to linux_find_memory_regions_full at one call site; at the
|
|
|
59b2e3 |
other call site, dump_note_entry_p is passed instead.
|
|
|
59b2e3 |
|
|
|
59b2e3 |
gdb/ChangeLog:
|
|
|
59b2e3 |
|
|
|
59b2e3 |
* linux-tdep.c (dump_note_entry_p): New function.
|
|
|
59b2e3 |
(linux_dump_mapping_p_ftype): New typedef.
|
|
|
59b2e3 |
(linux_find_memory_regions_full): Add new parameter,
|
|
|
59b2e3 |
should_dump_mapping_p.
|
|
|
59b2e3 |
(linux_find_memory_regions): Adjust call to
|
|
|
59b2e3 |
linux_find_memory_regions_full.
|
|
|
59b2e3 |
(linux_make_mappings_core_file_notes): Use dump_note_entry_p in
|
|
|
59b2e3 |
call to linux_find_memory_regions_full.
|
|
|
59b2e3 |
|
|
|
59b2e3 |
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
|
|
|
59b2e3 |
--- a/gdb/linux-tdep.c
|
|
|
59b2e3 |
+++ b/gdb/linux-tdep.c
|
|
|
59b2e3 |
@@ -732,6 +732,25 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
|
|
|
59b2e3 |
return dump_p;
|
|
|
59b2e3 |
}
|
|
|
59b2e3 |
|
|
|
59b2e3 |
+/* As above, but return true only when we should dump the NT_FILE
|
|
|
59b2e3 |
+ entry. */
|
|
|
59b2e3 |
+
|
|
|
59b2e3 |
+static int
|
|
|
59b2e3 |
+dump_note_entry_p (filter_flags filterflags, const struct smaps_vmflags *v,
|
|
|
59b2e3 |
+ int maybe_private_p, int mapping_anon_p, int mapping_file_p,
|
|
|
59b2e3 |
+ const char *filename, ULONGEST addr, ULONGEST offset)
|
|
|
59b2e3 |
+{
|
|
|
59b2e3 |
+ /* vDSO and vsyscall mappings will end up in the core file. Don't
|
|
|
59b2e3 |
+ put them in the NT_FILE note. */
|
|
|
59b2e3 |
+ if (strcmp ("[vdso]", filename) == 0
|
|
|
59b2e3 |
+ || strcmp ("[vsyscall]", filename) == 0)
|
|
|
59b2e3 |
+ return 0;
|
|
|
59b2e3 |
+
|
|
|
59b2e3 |
+ /* Otherwise, any other file-based mapping should be placed in the
|
|
|
59b2e3 |
+ note. */
|
|
|
59b2e3 |
+ return filename != nullptr;
|
|
|
59b2e3 |
+}
|
|
|
59b2e3 |
+
|
|
|
59b2e3 |
/* Implement the "info proc" command. */
|
|
|
59b2e3 |
|
|
|
59b2e3 |
static void
|
|
|
59b2e3 |
@@ -1246,10 +1265,20 @@ typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
|
|
|
59b2e3 |
const char *filename,
|
|
|
59b2e3 |
void *data);
|
|
|
59b2e3 |
|
|
|
59b2e3 |
+typedef int linux_dump_mapping_p_ftype (filter_flags filterflags,
|
|
|
59b2e3 |
+ const struct smaps_vmflags *v,
|
|
|
59b2e3 |
+ int maybe_private_p,
|
|
|
59b2e3 |
+ int mapping_anon_p,
|
|
|
59b2e3 |
+ int mapping_file_p,
|
|
|
59b2e3 |
+ const char *filename,
|
|
|
59b2e3 |
+ ULONGEST addr,
|
|
|
59b2e3 |
+ ULONGEST offset);
|
|
|
59b2e3 |
+
|
|
|
59b2e3 |
/* List memory regions in the inferior for a corefile. */
|
|
|
59b2e3 |
|
|
|
59b2e3 |
static int
|
|
|
59b2e3 |
linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|
|
59b2e3 |
+ linux_dump_mapping_p_ftype *should_dump_mapping_p,
|
|
|
59b2e3 |
linux_find_memory_region_ftype *func,
|
|
|
59b2e3 |
void *obfd)
|
|
|
59b2e3 |
{
|
|
|
59b2e3 |
@@ -1400,9 +1429,10 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|
|
59b2e3 |
}
|
|
|
59b2e3 |
|
|
|
59b2e3 |
if (has_anonymous)
|
|
|
59b2e3 |
- should_dump_p = dump_mapping_p (filterflags, &v, priv,
|
|
|
59b2e3 |
- mapping_anon_p, mapping_file_p,
|
|
|
59b2e3 |
- filename, addr, offset);
|
|
|
59b2e3 |
+ should_dump_p = should_dump_mapping_p (filterflags, &v, priv,
|
|
|
59b2e3 |
+ mapping_anon_p,
|
|
|
59b2e3 |
+ mapping_file_p,
|
|
|
59b2e3 |
+ filename, addr, offset);
|
|
|
59b2e3 |
else
|
|
|
59b2e3 |
{
|
|
|
59b2e3 |
/* Older Linux kernels did not support the "Anonymous:" counter.
|
|
|
59b2e3 |
@@ -1466,6 +1496,7 @@ linux_find_memory_regions (struct gdbarch *gdbarch,
|
|
|
59b2e3 |
data.obfd = obfd;
|
|
|
59b2e3 |
|
|
|
59b2e3 |
return linux_find_memory_regions_full (gdbarch,
|
|
|
59b2e3 |
+ dump_mapping_p,
|
|
|
59b2e3 |
linux_find_memory_regions_thunk,
|
|
|
59b2e3 |
&data);
|
|
|
59b2e3 |
}
|
|
|
59b2e3 |
@@ -1561,7 +1592,9 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
|
|
|
59b2e3 |
pack_long (buf, long_type, 1);
|
|
|
59b2e3 |
obstack_grow (&data_obstack, buf, TYPE_LENGTH (long_type));
|
|
|
59b2e3 |
|
|
|
59b2e3 |
- linux_find_memory_regions_full (gdbarch, linux_make_mappings_callback,
|
|
|
59b2e3 |
+ linux_find_memory_regions_full (gdbarch,
|
|
|
59b2e3 |
+ dump_note_entry_p,
|
|
|
59b2e3 |
+ linux_make_mappings_callback,
|
|
|
59b2e3 |
&mapping_data);
|
|
|
59b2e3 |
|
|
|
59b2e3 |
if (mapping_data.file_count != 0)
|