* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
-Index: gdb-7.5.91.20130323/gdb/exceptions.h
+Index: gdb-7.9.50.20150531/gdb/exec.c
===================================================================
---- gdb-7.5.91.20130323.orig/gdb/exceptions.h 2013-03-22 21:41:45.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/exceptions.h 2013-03-23 19:49:05.738459185 +0100
-@@ -90,6 +90,9 @@ enum errors {
- aborted as the inferior state is no longer valid. */
- TARGET_CLOSE_ERROR,
-
-+ /* Attempt to load a core file as executable. */
-+ IS_CORE_ERROR,
-+
- /* Add more errors here. */
- NR_ERRORS
- };
-Index: gdb-7.5.91.20130323/gdb/exec.c
-===================================================================
---- gdb-7.5.91.20130323.orig/gdb/exec.c 2013-01-31 19:37:37.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/exec.c 2013-03-23 19:48:53.284575912 +0100
-@@ -34,6 +34,7 @@
- #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"
-@@ -240,12 +241,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.5.91.20130323/gdb/main.c
+ if (build_section_table (exec_bfd, §ions, §ions_end))
+Index: gdb-7.9.50.20150531/gdb/main.c
===================================================================
---- gdb-7.5.91.20130323.orig/gdb/main.c 2013-03-23 19:48:18.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/main.c 2013-03-23 19:48:53.285575901 +0100
-@@ -296,6 +296,36 @@ typedef struct cmdarg {
+--- 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);
+ 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)
{
-@@ -796,6 +826,8 @@ captured_main (void *data)
+@@ -923,6 +954,8 @@ captured_main (void *data)
{
symarg = argv[optind];
execarg = argv[optind];
optind++;
}
-@@ -951,11 +983,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
+ };