X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fexec.c;h=615fb2b5dbc9f23a8b44bda5367dd362fbef1233;hb=ad69edbb4b230582ecd1863e68d0c2044f5ad901;hp=b1c4ca179987a0bdfaf1ff7089476c1199c9a1cb;hpb=57810aa7e8032c598897454daea14ed17df0f89d;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/exec.c b/gdb/exec.c index b1c4ca1799..615fb2b5db 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -49,6 +49,13 @@ void (*deprecated_file_changed_hook) (const char *); +static const target_info exec_target_info = { + "exec", + N_("Local exec file"), + N_("Use an executable file as a target.\n\ +Specify the filename of the executable file.") +}; + /* The target vector for executable files. */ struct exec_target final : public target_ops @@ -56,20 +63,9 @@ struct exec_target final : public target_ops exec_target () { to_stratum = file_stratum; } - const char *shortname () override - { return "exec"; } - - const char *longname () override - { return _("Local exec file"); } + const target_info &info () const override + { return exec_target_info; } - const char *doc () override - { - return _("\ -Use an executable file as a target.\n\ -Specify the filename of the executable file."); - } - - void open (const char *, int) override; void close () override; enum target_xfer_status xfer_partial (enum target_object object, const char *annex, @@ -99,8 +95,8 @@ show_write_files (struct ui_file *file, int from_tty, } -void -exec_target::open (const char *args, int from_tty) +static void +exec_target_open (const char *args, int from_tty) { target_preopen (from_tty); exec_file_attach (args, from_tty); @@ -153,11 +149,8 @@ void try_open_exec_file (const char *exec_file_host, struct inferior *inf, symfile_add_flags add_flags) { - struct cleanup *old_chain; struct gdb_exception prev_err = exception_none; - old_chain = make_cleanup (free_current_contents, &prev_err.message); - /* exec_file_attach and symbol_file_add_main may throw an error if the file cannot be opened either locally or remotely. @@ -169,6 +162,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, Even without a symbol file, the remote-based debugging session should continue normally instead of ending abruptly. Hence we catch thrown errors/exceptions in the following code. */ + std::string saved_message; TRY { /* We must do this step even if exec_file_host is NULL, so that @@ -184,7 +178,10 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, /* Save message so it doesn't get trashed by the catch below. */ if (err.message != NULL) - prev_err.message = xstrdup (err.message); + { + saved_message = err.message; + prev_err.message = saved_message.c_str (); + } } END_CATCH @@ -201,8 +198,6 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, } END_CATCH } - - do_cleanups (old_chain); } /* See gdbcore.h. */ @@ -366,7 +361,7 @@ exec_file_attach (const char *filename, int from_tty) exec_close (); error (_("\"%s\": not in executable format: %s"), scratch_pathname, - gdb_bfd_errmsg (bfd_get_error (), matching)); + gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); } if (build_section_table (exec_bfd, §ions, §ions_end)) @@ -1090,5 +1085,5 @@ Show writing into executable and core files."), NULL, show_write_files, &setlist, &showlist); - add_target_with_completer (&exec_ops, filename_completer); + add_target (exec_target_info, exec_target_open, filename_completer); }