Split vDSO range lookup to a gdbarch hook

We have a case in solib-svr4.c where we could reuse symfile-mem.c's
vDSO range lookup.  Since symfile-mem.c is not present in all
configurations solib-svr4.c is, move that lookup to a gdbarch hook.

This has the minor (good) side effect that we stop even trying the
target_auxv_search lookup against targets that don't have a concept of
a vDSO, in case symfile-mem.c happens to be linked in the build
(--enable-targets=all).

Tested on x86_64 Fedora 20.

gdb/
2014-10-10  Pedro Alves  <palves@redhat.com>

	* arch-utils.c (default_vsyscall_range): New function.
	* arch-utils.h (default_vsyscall_range): New declaration.
	* gdbarch.sh (vsyscall_range): New hook.
	* gdbarch.h, gdbarch.c: Regenerate.
	* linux-tdep.c (linux_vsyscall_range): New function.
	(linux_init_abi): Install linux_vsyscall_range as
	vsyscall_range gdbarch hook.
	* memrange.c (address_in_mem_range): New function.
	* memrange.h (address_in_mem_range): New declaration.
	* symfile-mem.c (find_vdso_size): Delete function.
	(add_vsyscall_page): Use gdbarch_vsyscall_range.
This commit is contained in:
Pedro Alves 2014-10-10 15:57:13 +01:00
parent 31cc0b807b
commit 3437254d7b
10 changed files with 120 additions and 26 deletions

View file

@ -1796,6 +1796,40 @@ linux_gdb_signal_to_target (struct gdbarch *gdbarch,
return -1;
}
/* Rummage through mappings to find a mapping's size. */
static int
find_mapping_size (CORE_ADDR vaddr, unsigned long size,
int read, int write, int exec, int modified,
void *data)
{
struct mem_range *range = data;
if (vaddr == range->start)
{
range->length = size;
return 1;
}
return 0;
}
/* Implementation of the "vsyscall_range" gdbarch hook. */
static int
linux_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
{
if (target_auxv_search (&current_target, AT_SYSINFO_EHDR, &range->start) <= 0)
return 0;
/* This is installed by linux_init_abi below, so should always be
available. */
gdb_assert (gdbarch_find_memory_regions_p (target_gdbarch ()));
range->length = 0;
gdbarch_find_memory_regions (gdbarch, find_mapping_size, range);
return 1;
}
/* To be called from the various GDB_OSABI_LINUX handlers for the
various GNU/Linux architectures and machine types. */
@ -1813,6 +1847,7 @@ linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
linux_gdb_signal_from_target);
set_gdbarch_gdb_signal_to_target (gdbarch,
linux_gdb_signal_to_target);
set_gdbarch_vsyscall_range (gdbarch, linux_vsyscall_range);
}
/* Provide a prototype to silence -Wmissing-prototypes. */