* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
-Index: gdb-7.7.50.20140609/gdb/exceptions.h
+Index: gdb-7.9.50.20150531/gdb/exec.c
===================================================================
---- gdb-7.7.50.20140609.orig/gdb/exceptions.h 2014-06-13 20:26:46.988804553 +0200
-+++ gdb-7.7.50.20140609/gdb/exceptions.h 2014-06-13 20:27:01.930820057 +0200
-@@ -100,6 +100,9 @@ enum errors {
- /* Requested feature, method, mechanism, etc. is not supported. */
- NOT_SUPPORTED_ERROR,
-
-+ /* Attempt to load a core file as executable. */
-+ IS_CORE_ERROR,
-+
- /* Add more errors here. */
- NR_ERRORS
- };
-Index: gdb-7.7.50.20140609/gdb/exec.c
-===================================================================
---- gdb-7.7.50.20140609.orig/gdb/exec.c 2014-06-13 20:26:44.831802315 +0200
-+++ gdb-7.7.50.20140609/gdb/exec.c 2014-06-13 20:27:17.282836454 +0200
+--- 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 <fcntl.h>
#include "readline/readline.h"
-@@ -231,12 +232,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))
{
}
if (build_section_table (exec_bfd, §ions, §ions_end))
-Index: gdb-7.7.50.20140609/gdb/main.c
+Index: gdb-7.9.50.20150531/gdb/main.c
===================================================================
---- gdb-7.7.50.20140609.orig/gdb/main.c 2014-06-13 20:26:44.831802315 +0200
-+++ gdb-7.7.50.20140609/gdb/main.c 2014-06-13 20:26:46.990804555 +0200
-@@ -341,6 +341,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)
{
-@@ -854,6 +884,8 @@ captured_main (void *data)
+@@ -923,6 +954,8 @@ captured_main (void *data)
{
symarg = argv[optind];
execarg = argv[optind];
optind++;
}
-@@ -1017,11 +1049,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_const (symbol_file_add_main, symarg,
- !batch_flag, RETURN_MASK_ALL);
+ !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
+ };