From bd099407658f0f5ebbfe8444d233f3e03ba088ef Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 19 Sep 1991 08:51:16 +0000 Subject: [PATCH] * main.c (execute_command): Warn as language changes automatically. (main): If error() is called during early initialization, print its message and then exit(1) from GDB. --- gdb/main.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/gdb/main.c b/gdb/main.c index 2c4f133..353e7b1 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -27,6 +27,7 @@ int fclose (); #include "signals.h" #include "target.h" #include "breakpoint.h" +#include "language.h" #include "getopt.h" @@ -80,6 +81,8 @@ extern char *version; extern char *error_pre_print; +extern char lang_frame_mismatch_warn[]; /* language.c */ + /* Flag for whether we want all the "from_tty" gubbish printed. */ int caution = 1; /* Default is yes, sigh. */ @@ -144,7 +147,7 @@ static char dirbuf[MAXPATHLEN]; /* Function to call before reading a command, if nonzero. The function receives two args: an input stream, and a prompt string. */ - + void (*window_hook) (); extern int frame_file_full_name; @@ -338,6 +341,11 @@ main (argc, argv) alloca (4 - i); #endif + /* If error() is called from initialization code, just exit */ + if (setjmp (to_top_level)) { + exit(1); + } + cmdsize = 1; cmdarg = (char **) xmalloc (cmdsize * sizeof (*cmdarg)); ncmd = 0; @@ -542,7 +550,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr); print_gdb_version (); if (symarg) printf_filtered (".."); - wrap_here(); + wrap_here(""); fflush (stdout); /* Force to screen during slow operations */ } @@ -705,6 +713,9 @@ execute_command (p, from_tty) { register struct cmd_list_element *c; register struct command_line *cmdlines; + register enum language flang; + static enum language current = language_unknown; + static int warned = 0; free_all_values (); @@ -748,7 +759,31 @@ execute_command (p, from_tty) error ("That is not a command, just a help topic."); else (*c->function) (arg, from_tty & caution); + } + + /* Tell the user if the language has changed */ + if (working_lang != current) + { + if (language_mode == language_mode_auto) { + if (current != language_unknown) + language_info (); } + current = working_lang; + warned = 0; + } + + /* Warn the user if the working language does not match the + language of the current frame. Only warn the user if we are + actually running the program, i.e. there is a stack. */ + if (target_has_stack) + { + flang = get_frame_language(); + if(!warned && flang != language_unknown && flang != working_lang) + { + printf_filtered ("%s\n", lang_frame_mismatch_warn); + warned = 1; + } + } } /* ARGSUSED */ -- 2.7.4