aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1992-10-06 09:33:15 +0000
committerJohn Gilmore <gnu@cygnus>1992-10-06 09:33:15 +0000
commitb5af69c3366b775b8fbf2e4cd51c3e39cb9330da (patch)
tree0a42c4daa04315a301139ec6370444a5d16b406d /gdb
parent48ab6c0e1d3d4b2d8091d3e25b4a6c0dff270288 (diff)
downloadbinutils-b5af69c3366b775b8fbf2e4cd51c3e39cb9330da.zip
binutils-b5af69c3366b775b8fbf2e4cd51c3e39cb9330da.tar.gz
binutils-b5af69c3366b775b8fbf2e4cd51c3e39cb9330da.tar.bz2
* language.c, language.h: Move saved_language out to global
expected_language. Set expected_language when user expectation changes. * language.c (language_info): Don't print type/range checking gub. * main.c (main): Set expected language. (execute_command): Check against expected language. * symfile.c (set_initial_language): Set expected language.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/language.c29
-rw-r--r--gdb/language.h5
-rw-r--r--gdb/main.c97
4 files changed, 104 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0eda108..00aae15 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
Tue Oct 6 02:23:17 1992 John Gilmore (gnu@cygnus.com)
+ * language.c, language.h: Move saved_language out to global
+ expected_language. Set expected_language when user expectation
+ changes.
+ * language.c (language_info): Don't print type/range checking gub.
+ * main.c (main): Set expected language.
+ (execute_command): Check against expected language.
+ * symfile.c (set_initial_language): Set expected language.
+
* configure.in, config/i386sol2.{mh,mt}: Preliminary Solaris-x86 conf.
Fri Sep 4 00:34:30 1992 Per Bothner (bothner@rtl.cygnus.com)
diff --git a/gdb/language.c b/gdb/language.c
index 2ecb150..e835445 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -102,6 +102,11 @@ enum type_check type_check = type_check_off;
const struct language_defn *current_language = &unknown_language_defn;
enum language_mode language_mode = language_mode_auto;
+/* The language that the user expects to be typing in (the language
+ of main(), or the last language we notified them about, or C). */
+
+const struct language_defn *expected_language;
+
/* The list of supported languages. The list itself is malloc'd. */
static const struct language_defn **languages;
@@ -176,6 +181,7 @@ modula-2 Use the Modula-2 language\n");
flang = get_frame_language();
if (flang!=language_unknown)
set_language(flang);
+ expected_language = current_language;
return;
} else {
/* Enter manual mode. Set the specified language. */
@@ -183,6 +189,7 @@ modula-2 Use the Modula-2 language\n");
current_language = languages[i];
set_type_range ();
set_lang_str();
+ expected_language = current_language;
return;
}
}
@@ -394,17 +401,25 @@ set_range_str()
/* Print out the current language settings: language, range and
type checking. If QUIETLY, print only what has changed. */
+
void
language_info (quietly)
int quietly;
{
- /* FIXME: quietly is ignored at the moment. */
- printf("Current Language: %s\n",language);
- show_language_command((char *)0, 1);
- printf("Type checking: %s\n",type);
- show_type_command((char *)0, 1);
- printf("Range checking: %s\n",range);
- show_range_command((char *)0, 1);
+ if (quietly && expected_language == current_language)
+ return;
+
+ expected_language = current_language;
+ printf("Current language: %s\n",language);
+ show_language_command((char *)0, 1);
+
+ if (!quietly)
+ {
+ printf("Type checking: %s\n",type);
+ show_type_command((char *)0, 1);
+ printf("Range checking: %s\n",range);
+ show_range_command((char *)0, 1);
+ }
}
/* Return the result of a binary operation. */
diff --git a/gdb/language.h b/gdb/language.h
index 16030a5..95eef2b 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -95,6 +95,11 @@ const struct op_print
extern const struct language_defn *current_language;
+/* Pointer to the language_defn expected by the user, e.g. the language
+ of main(), or the language we last mentioned in a message, or C. */
+
+extern const struct language_defn *expected_language;
+
/* language_mode ==
language_mode_auto: current_language automatically set upon selection
of scope (e.g. stack frame)
diff --git a/gdb/main.c b/gdb/main.c
index 825a6b6..7fcedf9 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -704,6 +704,7 @@ GDB manual (available as on-line info or a printed manual).\n", stderr);
"set width 0" won't fail if no language is explicitly set in a config file
or implicitly set by reading an executable during startup. */
set_language (language_c);
+ expected_language = current_language; /* don't warn about the change. */
/* Read and execute $HOME/.gdbinit file, if it exists. This is done
*before* all the command line arguments are processed; it sets
@@ -860,6 +861,34 @@ GDB manual (available as on-line info or a printed manual).\n", stderr);
/* No exit -- exit is through quit_command. */
}
+void
+execute_user_command (c, args)
+ struct cmd_list_element *c;
+ char *args;
+{
+ register struct command_line *cmdlines;
+ struct cleanup *old_chain;
+
+ if (args)
+ error ("User-defined commands cannot take arguments.");
+
+ cmdlines = c->user_commands;
+ if (cmdlines == 0)
+ /* Null command */
+ return;
+
+ /* Set the instream to 0, indicating execution of a
+ user-defined function. */
+ old_chain = make_cleanup (source_cleanup, instream);
+ instream = (FILE *) 0;
+ while (cmdlines)
+ {
+ execute_command (cmdlines->line, 0);
+ cmdlines = cmdlines->next;
+ }
+ do_cleanups (old_chain);
+}
+
/* Execute the line P as a command.
Pass FROM_TTY as second argument to the defining function. */
@@ -871,7 +900,6 @@ execute_command (p, from_tty)
register struct cmd_list_element *c;
register struct command_line *cmdlines;
register enum language flang;
- static const struct language_defn *saved_language = 0;
static int warned = 0;
free_all_values ();
@@ -888,28 +916,13 @@ execute_command (p, from_tty)
c = lookup_cmd (&p, cmdlist, "", 0, 1);
/* Pass null arg rather than an empty one. */
arg = *p ? p : 0;
+
+ /* If this command has been hooked, run the hook first. */
+ if (c->hook)
+ execute_user_command (c->hook, (char *)0);
+
if (c->class == class_user)
- {
- struct cleanup *old_chain;
-
- if (*p)
- error ("User-defined commands cannot take arguments.");
- cmdlines = c->user_commands;
- if (cmdlines == 0)
- /* Null command */
- return;
-
- /* Set the instream to 0, indicating execution of a
- user-defined function. */
- old_chain = make_cleanup (source_cleanup, instream);
- instream = (FILE *) 0;
- while (cmdlines)
- {
- execute_command (cmdlines->line, 0);
- cmdlines = cmdlines->next;
- }
- do_cleanups (old_chain);
- }
+ execute_user_command (c, arg);
else if (c->type == set_cmd || c->type == show_cmd)
do_setshow_command (arg, from_tty & caution, c);
else if (c->function.cfunc == NO_FUNCTION)
@@ -919,13 +932,11 @@ execute_command (p, from_tty)
}
/* Tell the user if the language has changed (except first time). */
- if (current_language != saved_language)
+ if (current_language != expected_language)
{
if (language_mode == language_mode_auto) {
- if (saved_language)
- language_info (1); /* Print what changed. */
+ language_info (1); /* Print what changed. */
}
- saved_language = current_language;
warned = 0;
}
@@ -1748,8 +1759,10 @@ define_command (comname, from_tty)
int from_tty;
{
register struct command_line *cmds;
- register struct cmd_list_element *c, *newc;
+ register struct cmd_list_element *c, *newc, *hookc;
char *tem = comname;
+#define HOOK_STRING "hook-"
+#define HOOK_LEN 5
validate_comname (comname);
@@ -1768,9 +1781,29 @@ define_command (comname, from_tty)
error ("Command \"%s\" not redefined.", c->name);
}
+ /* If this new command is a hook, then mark the command which it
+ is hooking. Note that we allow hooking `help' commands, so that
+ we can hook the `stop' pseudo-command. */
+
+ if (!strncmp (comname, HOOK_STRING, HOOK_LEN))
+ {
+ /* Look up cmd it hooks, and verify that we got an exact match. */
+ tem = comname+HOOK_LEN;
+ hookc = lookup_cmd (&tem, cmdlist, "", -1, 0);
+ if (hookc && 0 != strcmp (comname+HOOK_LEN, hookc->name))
+ hookc = 0;
+ if (!hookc)
+ {
+ warning ("Your new `%s' command does not hook any existing command.",
+ comname);
+ if (!query ("Proceed? ", (char *)0))
+ error ("Not confirmed.");
+ }
+ }
+
comname = savestring (comname, strlen (comname));
- /* If the rest of the commands will be case insensetive, this one
+ /* If the rest of the commands will be case insensitive, this one
should behave in the same manner. */
for (tem = comname; *tem; tem++)
if (isupper(*tem)) *tem = tolower(*tem);
@@ -1791,6 +1824,14 @@ End with a line saying just \"end\".\n", comname);
(c && c->class == class_user)
? c->doc : savestring ("User-defined.", 13), &cmdlist);
newc->user_commands = cmds;
+
+ /* If this new command is a hook, then mark both commands as being
+ tied. */
+ if (hookc)
+ {
+ hookc->hook = newc; /* Target gets hooked. */
+ newc->hookee = hookc; /* We are marked as hooking target cmd. */
+ }
}
static void