X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Ftop.c;h=f68d618631e9a6418f22d589749a01ec069a0a65;hb=2c500098f2a2ade0966e2ac10e0e714474cfcd92;hp=6f0f9a10a65c9ffbdf513c6cb11ea0878a5e40af;hpb=52f0bd74b2d084346e08abf2c7d9b5435fc1a9d5;p=binutils-gdb.git diff --git a/gdb/top.c b/gdb/top.c index 6f0f9a10a65..f68d618631e 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1,7 +1,7 @@ /* Top level stuff for GDB, the GNU debugger. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -47,8 +47,8 @@ #include "gdb_assert.h" /* readline include files */ -#include -#include +#include "readline/readline.h" +#include "readline/history.h" /* readline defines this. */ #undef savestring @@ -147,7 +147,7 @@ int baud_rate = -1; In mid-1996, remote_timeout was moved from remote.c to top.c and it began being used in other remote-* targets. It appears that the default was changed to 20 seconds at that time, perhaps because the - Hitachi E7000 ICE didn't always respond in a timely manner. + Renesas E7000 ICE didn't always respond in a timely manner. But if 5 seconds is a long time to sit and wait for retransmissions, 20 seconds is far worse. This demonstrates the difficulty of using @@ -193,7 +193,7 @@ static void stop_sig (int); If the UI fails to initialize and it wants GDB to continue using the default UI, then it should clear this hook before returning. */ -void (*init_ui_hook) (char *argv0); +void (*deprecated_init_ui_hook) (char *argv0); /* This hook is called from within gdb's many mini-event loops which could steal control from a real user interface's event loop. It returns @@ -204,92 +204,93 @@ int (*ui_loop_hook) (int); /* Called instead of command_loop at top level. Can be invoked via throw_exception(). */ -void (*command_loop_hook) (void); +void (*deprecated_command_loop_hook) (void); /* Called from print_frame_info to list the line we stopped in. */ -void (*print_frame_info_listing_hook) (struct symtab * s, int line, - int stopline, int noerror); +void (*deprecated_print_frame_info_listing_hook) (struct symtab * s, int line, + int stopline, int noerror); /* Replaces most of query. */ -int (*query_hook) (const char *, va_list); +int (*deprecated_query_hook) (const char *, va_list); /* Replaces most of warning. */ -void (*warning_hook) (const char *, va_list); +void (*deprecated_warning_hook) (const char *, va_list); -/* These three functions support getting lines of text from the user. They - are used in sequence. First readline_begin_hook is called with a text - string that might be (for example) a message for the user to type in a - sequence of commands to be executed at a breakpoint. If this function - calls back to a GUI, it might take this opportunity to pop up a text - interaction window with this message. Next, readline_hook is called - with a prompt that is emitted prior to collecting the user input. - It can be called multiple times. Finally, readline_end_hook is called - to notify the GUI that we are done with the interaction window and it - can close it. */ +/* These three functions support getting lines of text from the user. + They are used in sequence. First deprecated_readline_begin_hook is + called with a text string that might be (for example) a message for + the user to type in a sequence of commands to be executed at a + breakpoint. If this function calls back to a GUI, it might take + this opportunity to pop up a text interaction window with this + message. Next, deprecated_readline_hook is called with a prompt + that is emitted prior to collecting the user input. It can be + called multiple times. Finally, deprecated_readline_end_hook is + called to notify the GUI that we are done with the interaction + window and it can close it. */ -void (*readline_begin_hook) (char *, ...); -char *(*readline_hook) (char *); -void (*readline_end_hook) (void); +void (*deprecated_readline_begin_hook) (char *, ...); +char *(*deprecated_readline_hook) (char *); +void (*deprecated_readline_end_hook) (void); /* Called as appropriate to notify the interface of the specified breakpoint conditions. */ -void (*create_breakpoint_hook) (struct breakpoint * bpt); -void (*delete_breakpoint_hook) (struct breakpoint * bpt); -void (*modify_breakpoint_hook) (struct breakpoint * bpt); +void (*deprecated_create_breakpoint_hook) (struct breakpoint * bpt); +void (*deprecated_delete_breakpoint_hook) (struct breakpoint * bpt); +void (*deprecated_modify_breakpoint_hook) (struct breakpoint * bpt); /* Called as appropriate to notify the interface that we have attached to or detached from an already running process. */ -void (*attach_hook) (void); -void (*detach_hook) (void); +void (*deprecated_attach_hook) (void); +void (*deprecated_detach_hook) (void); /* Called during long calculations to allow GUI to repair window damage, and to check for stop buttons, etc... */ -void (*interactive_hook) (void); +void (*deprecated_interactive_hook) (void); /* Called when the registers have changed, as a hint to a GUI to minimize window update. */ -void (*registers_changed_hook) (void); +void (*deprecated_registers_changed_hook) (void); /* Tell the GUI someone changed the register REGNO. -1 means that the caller does not know which register changed or that several registers have changed (see value_assign). */ -void (*register_changed_hook) (int regno); +void (*deprecated_register_changed_hook) (int regno); /* Tell the GUI someone changed LEN bytes of memory at ADDR */ -void (*memory_changed_hook) (CORE_ADDR addr, int len); +void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len); /* Called when going to wait for the target. Usually allows the GUI to run while waiting for target events. */ -ptid_t (*target_wait_hook) (ptid_t ptid, - struct target_waitstatus * status); +ptid_t (*deprecated_target_wait_hook) (ptid_t ptid, + struct target_waitstatus * status); /* Used by UI as a wrapper around command execution. May do various things like enabling/disabling buttons, etc... */ -void (*call_command_hook) (struct cmd_list_element * c, char *cmd, - int from_tty); +void (*deprecated_call_command_hook) (struct cmd_list_element * c, char *cmd, + int from_tty); /* Called after a `set' command has finished. Is only run if the `set' command succeeded. */ -void (*set_hook) (struct cmd_list_element * c); +void (*deprecated_set_hook) (struct cmd_list_element * c); /* Called when the current thread changes. Argument is thread id. */ -void (*context_hook) (int id); +void (*deprecated_context_hook) (int id); /* Takes control from error (). Typically used to prevent longjmps out of the middle of the GUI. Usually used in conjunction with a catch routine. */ -NORETURN void (*error_hook) (void) ATTR_NORETURN; +NORETURN void (*deprecated_error_hook) (void) ATTR_NORETURN; /* One should use catch_errors rather than manipulating these @@ -383,6 +384,7 @@ catcher (catch_exceptions_ftype *func, int *func_val, enum return_reason *func_caught, char *errstring, + char **gdberrmsg, return_mask mask) { SIGJMP_BUF *saved_catch; @@ -428,7 +430,14 @@ catcher (catch_exceptions_ftype *func, if (!caught) val = (*func) (func_uiout, func_args); else - val = 0; + { + val = 0; + /* If caller wants a copy of the low-level error message, make one. + This is used in the case of a silent error whereby the caller + may optionally want to issue the message. */ + if (gdberrmsg) + *gdberrmsg = error_last_message (); + } catch_return = saved_catch; /* FIXME: cagney/1999-11-05: A correct FUNC implementation will @@ -476,7 +485,25 @@ catch_exceptions (struct ui_out *uiout, { int val; enum return_reason caught; - catcher (func, uiout, func_args, &val, &caught, errstring, mask); + catcher (func, uiout, func_args, &val, &caught, errstring, NULL, mask); + gdb_assert (val >= 0); + gdb_assert (caught <= 0); + if (caught < 0) + return caught; + return val; +} + +int +catch_exceptions_with_msg (struct ui_out *uiout, + catch_exceptions_ftype *func, + void *func_args, + char *errstring, + char **gdberrmsg, + return_mask mask) +{ + int val; + enum return_reason caught; + catcher (func, uiout, func_args, &val, &caught, errstring, gdberrmsg, mask); gdb_assert (val >= 0); gdb_assert (caught <= 0); if (caught < 0) @@ -506,7 +533,8 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, struct catch_errors_args args; args.func = func; args.func_args = func_args; - catcher (do_catch_errors, uiout, &args, &val, &caught, errstring, mask); + catcher (do_catch_errors, uiout, &args, &val, &caught, errstring, + NULL, mask); if (caught != 0) return 0; return val; @@ -669,10 +697,10 @@ execute_command (char *p, int from_tty) /* If the target is running, we allow only a limited set of commands. */ if (event_loop_p && target_can_async_p () && target_executing) - if (!strcmp (c->name, "help") - && !strcmp (c->name, "pwd") - && !strcmp (c->name, "show") - && !strcmp (c->name, "stop")) + if (strcmp (c->name, "help") != 0 + && strcmp (c->name, "pwd") != 0 + && strcmp (c->name, "show") != 0 + && strcmp (c->name, "stop") != 0) error ("Cannot execute this command while the target is running."); /* Pass null arg rather than an empty one. */ @@ -710,8 +738,8 @@ execute_command (char *p, int from_tty) do_setshow_command (arg, from_tty & caution, c); else if (!cmd_func_p (c)) error ("That is not a command, just a help topic."); - else if (call_command_hook) - call_command_hook (c, arg, from_tty & caution); + else if (deprecated_call_command_hook) + deprecated_call_command_hook (c, arg, from_tty & caution); else cmd_func (c, arg, from_tty & caution); @@ -1207,9 +1235,9 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) } /* Don't use fancy stuff if not talking to stdin. */ - if (readline_hook && instream == NULL) + if (deprecated_readline_hook && instream == NULL) { - rl = (*readline_hook) (local_prompt); + rl = (*deprecated_readline_hook) (local_prompt); } else if (command_editing_p && instream == stdin && ISATTY (instream)) { @@ -1266,7 +1294,7 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) #define SERVER_COMMAND_LENGTH 7 server_command = (p - linebuffer > SERVER_COMMAND_LENGTH) - && STREQN (linebuffer, "server ", SERVER_COMMAND_LENGTH); + && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0; if (server_command) { /* Note that we don't set `line'. Between this and the check in @@ -1359,7 +1387,7 @@ print_gdb_version (struct ui_file *stream) /* Second line is a copyright notice. */ - fprintf_filtered (stream, "Copyright 2003 Free Software Foundation, Inc.\n"); + fprintf_filtered (stream, "Copyright 2004 Free Software Foundation, Inc.\n"); /* Following the copyright is a brief statement that the program is free software, that users are free to copy and change it on @@ -1375,7 +1403,7 @@ There is absolutely no warranty for GDB. Type \"show warranty\" for details.\n" /* After the required info we print the configuration information. */ fprintf_filtered (stream, "This GDB was configured as \""); - if (!STREQ (host_name, target_name)) + if (strcmp (host_name, target_name) != 0) { fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_name); } @@ -1425,7 +1453,7 @@ quit_confirm (void) /* This is something of a hack. But there's no reliable way to see if a GUI is running. The `use_windows' variable doesn't cut it. */ - if (init_ui_hook) + if (deprecated_init_ui_hook) s = "A debugging session is active.\nDo you still want to close the debugger?"; else if (attach_flag) s = "The program is running. Quit anyway (and detach it)? "; @@ -1461,7 +1489,7 @@ quit_target (void *arg) } /* UDI wants this, to kill the TIP. */ - target_close (1); + target_close (¤t_target, 1); /* Save the history information if it is appropriate to do so. */ if (write_history_p && history_filename) @@ -1478,6 +1506,7 @@ void quit_force (char *args, int from_tty) { int exit_code = 0; + struct qt_args qt; /* An optional expression may be used to cause gdb to terminate with the value of that expression. */ @@ -1488,8 +1517,11 @@ quit_force (char *args, int from_tty) exit_code = (int) value_as_long (val); } + qt.args = args; + qt.from_tty = from_tty; + /* We want to handle any quit errors and exit regardless. */ - catch_errors (quit_target, args, + catch_errors (quit_target, &qt, "Quitting: ", RETURN_MASK_ALL); exit (exit_code); @@ -1504,7 +1536,6 @@ input_from_terminal_p (void) return gdb_has_a_terminal () && (instream == stdin) & caution; } -/* ARGSUSED */ static void dont_repeat_command (char *ignored, int from_tty) { @@ -1590,7 +1621,6 @@ show_commands (char *args, int from_tty) } /* Called by do_setshow_command. */ -/* ARGSUSED */ static void set_history_size_command (char *args, int from_tty, struct cmd_list_element *c) { @@ -1605,7 +1635,6 @@ set_history_size_command (char *args, int from_tty, struct cmd_list_element *c) } } -/* ARGSUSED */ void set_history (char *args, int from_tty) { @@ -1613,7 +1642,6 @@ set_history (char *args, int from_tty) help_list (sethistlist, "set history ", -1, gdb_stdout); } -/* ARGSUSED */ void show_history (char *args, int from_tty) { @@ -1623,7 +1651,6 @@ show_history (char *args, int from_tty) int info_verbose = 0; /* Default verbose msgs off */ /* Called by do_setshow_command. An elaborate joke. */ -/* ARGSUSED */ void set_verbose (char *args, int from_tty, struct cmd_list_element *c) { @@ -1720,8 +1747,7 @@ init_main (void) /* Setup important stuff for command line editing. */ rl_completion_entry_function = readline_line_completion_function; - rl_completer_word_break_characters = - get_gdb_completer_word_break_characters (); + rl_completer_word_break_characters = default_word_break_characters (); rl_completer_quote_characters = get_gdb_completer_quote_characters (); rl_readline_name = "gdb"; rl_terminal_name = getenv ("TERM"); @@ -1880,8 +1906,9 @@ gdb_init (char *argv0) set_language (language_c); expected_language = current_language; /* don't warn about the change. */ - /* Allow another UI to initialize. If the UI fails to initialize, and - it wants GDB to revert to the CLI, it should clear init_ui_hook. */ - if (init_ui_hook) - init_ui_hook (argv0); + /* Allow another UI to initialize. If the UI fails to initialize, + and it wants GDB to revert to the CLI, it should clear + deprecated_init_ui_hook. */ + if (deprecated_init_ui_hook) + deprecated_init_ui_hook (argv0); }