Eliminate the 'the_core_target' global

(previously called 'core_target', but since renamed because
'core_target' is the name of the target_ops class now.)

This eliminates the "the_core_target" global, as preparation for being
able to have more than one core loaded.  When we get there, we will
instantiate one core_target object per core instead.

Essentially, this replaces the reference to the_core_target in
core_file_command by a reference to core_bfd, which is per
program_space.

Currently, core_file_command calls 'the_core_target->detach()' even if
the core target is not open and pushed on the target stack.  If it is
indeed not open, then the practical effect is that
core_target::detach() prints "No core file now.".  That is preserved
by printing that directly from within core_file_command if not
debugging a core.

gdb/ChangeLog:
2018-05-11  Pedro Alves  <palves@redhat.com>

	* corefile.c (core_file_command): Move to corelow.c.
	* corelow.c (the_core_target): Delete.
	(core_file_command): Moved from corefile.c.  Check exec_bfd
	instead of the_core_target.  Use target_detach instead of calling
	into the_core_target directly.
	(maybe_say_no_core_file_now): New.
	(core_target::detach): Use it.
	(_initialize_corelow): Remove references to the_core_target.
	* gdbcore.h (the_core_target): Delete.
This commit is contained in:
Pedro Alves
2018-05-11 19:10:14 +01:00
parent e540a5a223
commit 451953fa44
4 changed files with 43 additions and 33 deletions

View File

@@ -51,24 +51,6 @@ static int exec_file_hook_count = 0; /* Size of array. */
/* Backward compatability with old way of specifying core files. */
void
core_file_command (const char *filename, int from_tty)
{
dont_repeat (); /* Either way, seems bogus. */
if (!filename)
{
gdb_assert (the_core_target != NULL);
the_core_target->detach (current_inferior (), from_tty);
}
else
core_target_open (filename, from_tty);
}
/* If there are two or more functions that wish to hook into
exec_file_command, this function will call all of the hook
functions. */