aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index c7979a2..c2a1f8a 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -44,7 +44,7 @@
#include <ctype.h>
#include <sys/stat.h>
-#include "solist.h"
+#include "solib.h"
#include <algorithm>
#include "gdbsupport/pathstuff.h"
#include "cli/cli-style.h"
@@ -218,28 +218,32 @@ validate_exec_file (int from_tty)
if (exec_file_mismatch_mode == exec_file_mismatch_off)
return;
+ /* If there's no current executable, then there's nothing to
+ validate against, so we're done. */
const char *current_exec_file = current_program_space->exec_filename ();
- struct inferior *inf = current_inferior ();
- /* Try to determine a filename from the process itself. */
- const char *pid_exec_file = target_pid_to_exec_file (inf->pid);
- bool build_id_mismatch = false;
-
- /* If we cannot validate the exec file, return. */
- if (current_exec_file == NULL || pid_exec_file == NULL)
+ if (current_exec_file == nullptr)
return;
- /* Try validating via build-id, if available. This is the most
- reliable check. */
+ /* Try to determine a filename from the process itself. If we
+ cannot get an executable from the process, then no validation is
+ possible. */
+ const char *pid_exec_file
+ = target_pid_to_exec_file (current_inferior ()->pid);
+ if (pid_exec_file == nullptr)
+ return;
- /* In case current_exec_file was changed, reopen_exec_file ensures
- an up to date build_id (will do nothing if the file timestamp
- did not change). If exec file changed, reopen_exec_file has
- allocated another file name, so get_exec_file again. */
+ /* In case current_exec_file was changed, reopen_exec_file ensures an up
+ to date build_id (will do nothing if the file timestamp did not
+ change). If exec file changed, reopen_exec_file has allocated another
+ file name, so get_exec_file again. */
reopen_exec_file ();
current_exec_file = current_program_space->exec_filename ();
+ /* Try validating via build-id, if available. This is the most reliable
+ check. */
const bfd_build_id *exec_file_build_id
= build_id_bfd_get (current_program_space->exec_bfd ());
+ bool build_id_mismatch = false;
if (exec_file_build_id != nullptr)
{
/* Prepend the target prefix, to force gdb_bfd_open to open the
@@ -334,6 +338,14 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
gdb::unique_xmalloc_ptr<char> exec_file_host
= exec_file_find (exec_file_target, NULL);
+ if (exec_file_host == nullptr)
+ {
+ warning (_("No executable has been specified, and target executable "
+ "%ps could not be found. Try using the \"%ps\" command."),
+ styled_string (file_name_style.style (), exec_file_target),
+ styled_string (command_style.style (), "file"));
+ return;
+ }
if (defer_bp_reset)
add_flags |= SYMFILE_DEFER_BP_RESET;
@@ -1065,9 +1077,7 @@ exec_target::find_memory_regions (find_memory_region_ftype func, void *data)
return objfile_find_memory_regions (this, func, data);
}
-void _initialize_exec ();
-void
-_initialize_exec ()
+INIT_GDB_FILE (exec)
{
struct cmd_list_element *c;