target_stack -> current_top_target() throughout

The recent C++ification of target_ops replaced references to the old
"current_target" squashed target throughout with references to a
"target_stack" pointer.  I had picked the "target_stack" name very
early in the multi-target work, and managed to stick with it, even
though it's a bit of a misnomer, since it isn't really a "target
stack" object, but a pointer into the current top target in the stack.
As I'm splitting more pieces off of the multi-target branch, I've come
to think that it's better to rename it now.  A following patch will
introduce a new class to represent a target stack, and "target_stack"
would be _its_ ideal name.  (In the branch, the class is called
a_target_stack to work around the clash.)

Thus this commit renames target_stack to current_top_target and
replaces all references throughout.  Also, while at it,
current_top_target is made a function instead of a pointer, to make it
possible to change its internal implementation without leaking
implementation details out.  In a couple patches, the implementation
of the function will change to refer to a target stack object, and
then further down the multi-target work, it'll change again to find
the right target stack for the current inferior.

gdb/ChangeLog:
2018-06-07  Pedro Alves  <palves@redhat.com>

	* target.h (target_stack): Delete.
	(current_top_target): Declare function.
	* target.c (target_stack): Delete.
	(g_current_top_target): New.
	(current_top_target): New function.
	* auxv.c: Use current_top_target instead of target_stack
	throughout.
	* avr-tdep.c: Likewise.
	* breakpoint.c: Likewise.
	* corefile.c: Likewise.
	* elfread.c: Likewise.
	* eval.c: Likewise.
	* exceptions.c: Likewise.
	* frame.c: Likewise.
	* gdbarch-selftests.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* ia64-tdep.c: Likewise.
	* ia64-vms-tdep.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* linespec.c: Likewise.
	* linux-tdep.c: Likewise.
	* minsyms.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-linux-tdep.c: Likewise.
	* procfs.c: Likewise.
	* regcache.c: Likewise.
	* remote.c: Likewise.
	* rs6000-tdep.c: Likewise.
	* s390-linux-nat.c: Likewise.
	* s390-tdep.c: Likewise.
	* solib-aix.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* solib-target.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* spu-tdep.c: Likewise.
	* symfile.c: Likewise.
	* symtab.c: Likewise.
	* target-descriptions.c: Likewise.
	* target-memory.c: Likewise.
	* target.c: Likewise.
	* target.h: Likewise.
	* tracefile-tfile.c: Likewise.
	* tracepoint.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* windows-tdep.c: Likewise.
	* mi/mi-main.c: Likewise.
This commit is contained in:
Pedro Alves
2018-06-07 17:27:46 +01:00
parent c7110220be
commit 8b88a78e63
49 changed files with 378 additions and 305 deletions

View File

@@ -402,8 +402,8 @@ linux_is_uclinux (void)
{
CORE_ADDR dummy;
return (target_auxv_search (target_stack, AT_NULL, &dummy) > 0
&& target_auxv_search (target_stack, AT_PAGESZ, &dummy) == 0);
return (target_auxv_search (current_top_target (), AT_NULL, &dummy) > 0
&& target_auxv_search (current_top_target (), AT_PAGESZ, &dummy) == 0);
}
static int
@@ -1423,7 +1423,8 @@ linux_spu_make_corefile_notes (bfd *obfd, char *note_data, int *note_size)
/* Determine list of SPU ids. */
gdb::optional<gdb::byte_vector>
spu_ids = target_read_alloc (target_stack, TARGET_OBJECT_SPU, NULL);
spu_ids = target_read_alloc (current_top_target (),
TARGET_OBJECT_SPU, NULL);
if (!spu_ids)
return note_data;
@@ -1439,7 +1440,7 @@ linux_spu_make_corefile_notes (bfd *obfd, char *note_data, int *note_size)
xsnprintf (annex, sizeof annex, "%d/%s", fd, spu_files[j]);
gdb::optional<gdb::byte_vector> spu_data
= target_read_alloc (target_stack, TARGET_OBJECT_SPU, annex);
= target_read_alloc (current_top_target (), TARGET_OBJECT_SPU, annex);
if (spu_data && !spu_data->empty ())
{
@@ -1661,7 +1662,7 @@ linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch)
gdb::byte_vector buf (TYPE_LENGTH (siginfo_type));
bytes_read = target_read (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL,
bytes_read = target_read (current_top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL,
buf.data (), 0, TYPE_LENGTH (siginfo_type));
if (bytes_read != TYPE_LENGTH (siginfo_type))
buf.clear ();
@@ -1970,7 +1971,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
/* Auxillary vector. */
gdb::optional<gdb::byte_vector> auxv =
target_read_alloc (target_stack, TARGET_OBJECT_AUXV, NULL);
target_read_alloc (current_top_target (), TARGET_OBJECT_AUXV, NULL);
if (auxv && !auxv->empty ())
{
note_data = elfcore_write_note (obfd, note_data, note_size,
@@ -2253,7 +2254,7 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
char filename[100];
long pid;
if (target_auxv_search (target_stack, AT_SYSINFO_EHDR, &range->start) <= 0)
if (target_auxv_search (current_top_target (), AT_SYSINFO_EHDR, &range->start) <= 0)
return 0;
/* It doesn't make sense to access the host's /proc when debugging a
@@ -2443,14 +2444,14 @@ linux_displaced_step_location (struct gdbarch *gdbarch)
local-store address and is thus not usable as displaced stepping
location. The auxiliary vector gets us the PowerPC-side entry
point address instead. */
if (target_auxv_search (target_stack, AT_ENTRY, &addr) <= 0)
if (target_auxv_search (current_top_target (), AT_ENTRY, &addr) <= 0)
throw_error (NOT_SUPPORTED_ERROR,
_("Cannot find AT_ENTRY auxiliary vector entry."));
/* Make certain that the address points at real code, and not a
function descriptor. */
addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr,
target_stack);
current_top_target ());
/* Inferior calls also use the entry point as a breakpoint location.
We don't want displaced stepping to interfere with those