* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
-Index: gdb-7.2.50.20110218/gdb/exceptions.h
+Index: gdb-7.9.50.20150531/gdb/exec.c
===================================================================
---- gdb-7.2.50.20110218.orig/gdb/exceptions.h 2011-02-14 12:35:44.000000000 +0100
-+++ gdb-7.2.50.20110218/gdb/exceptions.h 2011-02-18 10:45:31.000000000 +0100
-@@ -85,6 +85,9 @@ enum errors {
- traceframe. */
- NOT_AVAILABLE_ERROR,
-
-+ /* Attempt to load a core file as executable. */
-+ IS_CORE_ERROR,
-+
- /* Add more errors here. */
- NR_ERRORS
- };
-Index: gdb-7.2.50.20110218/gdb/exec.c
-===================================================================
---- gdb-7.2.50.20110218.orig/gdb/exec.c 2011-02-14 23:08:48.000000000 +0100
-+++ gdb-7.2.50.20110218/gdb/exec.c 2011-02-18 10:45:16.000000000 +0100
-@@ -34,6 +34,7 @@
- #include "arch-utils.h"
- #include "gdbthread.h"
+--- gdb-7.9.50.20150531.orig/gdb/exec.c 2015-05-31 03:48:29.000000000 +0200
++++ gdb-7.9.50.20150531/gdb/exec.c 2015-05-31 20:07:35.092878685 +0200
+@@ -35,6 +35,7 @@
#include "progspace.h"
+ #include "gdb_bfd.h"
+ #include "gcore.h"
+#include "exceptions.h"
#include <fcntl.h>
#include "readline/readline.h"
-@@ -253,12 +254,27 @@ exec_file_attach (char *filename, int fr
+@@ -298,12 +299,27 @@ exec_file_attach (const char *filename,
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
+ gdb_bfd_errmsg (bfd_get_error (), matching));
}
- /* FIXME - This should only be run for RS6000, but the ifdef is a poor
-Index: gdb-7.2.50.20110218/gdb/main.c
+ if (build_section_table (exec_bfd, §ions, §ions_end))
+Index: gdb-7.9.50.20150531/gdb/main.c
===================================================================
---- gdb-7.2.50.20110218.orig/gdb/main.c 2011-02-18 10:44:17.000000000 +0100
-+++ gdb-7.2.50.20110218/gdb/main.c 2011-02-18 10:45:16.000000000 +0100
-@@ -243,6 +243,36 @@ captured_command_loop (void *data)
- return 1;
- }
+--- gdb-7.9.50.20150531.orig/gdb/main.c 2015-05-31 20:07:34.183872824 +0200
++++ gdb-7.9.50.20150531/gdb/main.c 2015-05-31 20:10:05.095845935 +0200
+@@ -435,6 +435,37 @@ typedef struct cmdarg {
+ /* Define type VEC (cmdarg_s). */
+ DEF_VEC_O (cmdarg_s);
+/* Call exec_file_attach. If it detected FILENAME is a core file call
+ core_file_command. Print the original exec_file_attach error only if
+ core_file_command failed to find a matching executable. */
+
+static void
-+exec_or_core_file_attach (char *filename, int from_tty)
++exec_or_core_file_attach (const char *filename, int from_tty)
+{
+ volatile struct gdb_exception e;
+
+ gdb_assert (exec_bfd == NULL);
+
-+ TRY_CATCH (e, RETURN_MASK_ALL)
++ TRY
+ {
+ exec_file_attach (filename, from_tty);
+ }
-+ if (e.reason < 0)
++ CATCH (e, RETURN_MASK_ALL)
+ {
+ if (e.error == IS_CORE_ERROR)
+ {
-+ core_file_command (filename, from_tty);
++ core_file_command ((char *) filename, from_tty);
+
+ /* Iff the core file found its executable suppress the error message
+ from exec_file_attach. */
+ }
+ throw_exception (e);
+ }
++ END_CATCH
+}
+
static int
captured_main (void *data)
{
-@@ -727,6 +757,8 @@ captured_main (void *data)
+@@ -923,6 +954,8 @@ captured_main (void *data)
{
symarg = argv[optind];
execarg = argv[optind];
optind++;
}
-@@ -868,11 +900,25 @@ captured_main (void *data)
+@@ -1080,11 +1113,25 @@ captured_main (void *data)
&& symarg != NULL
&& strcmp (execarg, symarg) == 0)
{
-+ catch_command_errors_ftype *func;
++ catch_command_errors_const_ftype *func;
+
+ /* Call exec_or_core_file_attach only if the file was specified as
+ a command line argument (and not an a command line option). */
/* The exec file and the symbol-file are the same. If we can't
open it, better only print one error message.
- catch_command_errors returns non-zero on success! */
-- if (catch_command_errors (exec_file_attach, execarg,
-- !batch_flag, RETURN_MASK_ALL))
+- if (catch_command_errors_const (exec_file_attach, execarg,
+- !batch_flag))
+ catch_command_errors returns non-zero on success!
+ Do not load EXECARG as a symbol file if it has been already processed
+ as a core file. */
-+ if (catch_command_errors (func, execarg, !batch_flag, RETURN_MASK_ALL)
++ if (catch_command_errors_const (func, execarg, !batch_flag)
+ && core_bfd == NULL)
- catch_command_errors (symbol_file_add_main, symarg,
- !batch_flag, RETURN_MASK_ALL);
+ catch_command_errors_const (symbol_file_add_main, symarg,
+ !batch_flag);
}
+Index: gdb-7.9.50.20150531/gdb/common/common-exceptions.h
+===================================================================
+--- gdb-7.9.50.20150531.orig/gdb/common/common-exceptions.h 2015-05-31 03:48:29.000000000 +0200
++++ gdb-7.9.50.20150531/gdb/common/common-exceptions.h 2015-05-31 20:07:35.093878692 +0200
+@@ -105,6 +105,9 @@ enum errors {
+ "_ERROR" is appended to the name. */
+ MAX_COMPLETIONS_REACHED_ERROR,
+
++ /* Attempt to load a core file as executable. */
++ IS_CORE_ERROR,
++
+ /* Add more errors here. */
+ NR_ERRORS
+ };