aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c99
1 files changed, 58 insertions, 41 deletions
diff --git a/gdb/top.c b/gdb/top.c
index d6bf1d4..72d1953 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1,6 +1,6 @@
/* Top level stuff for GDB, the GNU debugger.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ Copyright (C) 1986-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -85,10 +85,6 @@
extern void initialize_all_files (void);
-#define PROMPT(X) the_prompts.prompt_stack[the_prompts.top + X].prompt
-#define PREFIX(X) the_prompts.prompt_stack[the_prompts.top + X].prefix
-#define SUFFIX(X) the_prompts.prompt_stack[the_prompts.top + X].suffix
-
/* Default command line prompt. This is overridden in some configs. */
#ifndef DEFAULT_PROMPT
@@ -385,10 +381,10 @@ check_frame_language_change (void)
/* 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. */
- /* FIXME: This should be cacheing the frame and only running when
+ /* FIXME: This should be caching the frame and only running when
the frame changes. */
- if (has_stack_frames ())
+ if (warn_frame_lang_mismatch && has_stack_frames ())
{
enum language flang;
@@ -419,7 +415,7 @@ wait_sync_command_done (void)
point. */
scoped_enable_commit_resumed enable ("sync wait");
- while (gdb_do_one_event () >= 0)
+ while (current_interpreter ()->do_one_event () >= 0)
if (ui->prompt_state != PROMPT_BLOCKED)
break;
}
@@ -549,12 +545,10 @@ execute_command (const char *p, int from_tty)
that can be followed by its args), report the list of
subcommands. */
{
- std::string prefixname = c->prefixname ();
- std::string prefixname_no_space
- = prefixname.substr (0, prefixname.length () - 1);
+ std::string prefixname = c->prefixname_no_space ();
gdb_printf
("\"%s\" must be followed by the name of a subcommand.\n",
- prefixname_no_space.c_str ());
+ prefixname.c_str ());
help_list (*c->subcommands, prefixname.c_str (), all_commands,
gdb_stdout);
}
@@ -632,19 +626,9 @@ execute_fn_to_string (std::string &res, std::function<void(void)> fn,
{
string_file str_file (term_out);
- try
- {
- execute_fn_to_ui_file (&str_file, fn);
- }
- catch (...)
- {
- /* Finally. */
- res = str_file.release ();
- throw;
- }
+ SCOPE_EXIT { res = str_file.release (); };
- /* And finally. */
- res = str_file.release ();
+ execute_fn_to_ui_file (&str_file, fn);
}
/* See top.h. */
@@ -1047,7 +1031,7 @@ gdb_readline_wrapper (const char *prompt)
(*after_char_processing_hook) ();
gdb_assert (after_char_processing_hook == NULL);
- while (gdb_do_one_event () >= 0)
+ while (current_interpreter ()->do_one_event () >= 0)
if (gdb_readline_wrapper_done)
break;
@@ -1064,11 +1048,14 @@ static int operate_saved_history = -1;
static void
gdb_rl_operate_and_get_next_completion (void)
{
- int delta = where_history () - operate_saved_history;
+ if (operate_saved_history != -1)
+ {
+ int delta = where_history () - operate_saved_history;
- /* The `key' argument to rl_get_previous_history is ignored. */
- rl_get_previous_history (delta, 0);
- operate_saved_history = -1;
+ /* The `key' argument to rl_get_previous_history is ignored. */
+ rl_get_previous_history (delta, 0);
+ operate_saved_history = -1;
+ }
/* readline doesn't automatically update the display for us. */
rl_redisplay ();
@@ -1093,9 +1080,10 @@ gdb_rl_operate_and_get_next (int count, int key)
/* Find the current line, and find the next line to use. */
where = where_history();
- if ((history_is_stifled () && (history_length >= history_max_entries))
- || (where >= history_length - 1))
+ if (history_is_stifled () && history_length >= history_max_entries)
operate_saved_history = where;
+ else if (where >= history_length - 1)
+ operate_saved_history = -1;
else
operate_saved_history = where + 1;
@@ -1340,8 +1328,9 @@ There is NO WARRANTY, to the extent permitted by law.",
if (!interactive)
return;
- gdb_printf (stream, ("\nType \"show copying\" and "
- "\"show warranty\" for details.\n"));
+ gdb_printf (stream, ("\nType \"%ps\" and \"%ps\" for details.\n"),
+ styled_string (command_style.style (), "show copying"),
+ styled_string (command_style.style (), "show warranty"));
/* After the required info we print the configuration information. */
@@ -1357,8 +1346,8 @@ There is NO WARRANTY, to the extent permitted by law.",
}
gdb_printf (stream, "\".\n");
- gdb_printf (stream, _("Type \"show configuration\" "
- "for configuration details.\n"));
+ gdb_printf (stream, _("Type \"%ps\" for configuration details.\n"),
+ styled_string (command_style.style (), "show configuration"));
if (REPORT_BUGS_TO[0])
{
@@ -1374,10 +1363,11 @@ resources online at:\n <%ps>."),
styled_string (file_name_style.style (),
"http://www.gnu.org/software/gdb/documentation/"));
gdb_printf (stream, "\n\n");
- gdb_printf (stream, _("For help, type \"help\".\n"));
+ gdb_printf (stream, _("For help, type \"%ps\".\n"),
+ styled_string (command_style.style (), "help"));
gdb_printf (stream,
- _("Type \"apropos word\" to search for commands \
-related to \"word\"."));
+ _("Type \"%ps\" to search for commands related to \"word\"."),
+ styled_string (command_style.style (), "apropos word"));
}
/* Print the details of GDB build-time configuration. */
@@ -1389,6 +1379,11 @@ This GDB was configured as follows:\n\
configure --host=%s --target=%s\n\
"), host_name, target_name);
+#ifdef ENABLE_TARGETS
+ gdb_printf (stream, _("\
+ --enable-targets=%s\n"), ENABLE_TARGETS);
+#endif
+
gdb_printf (stream, _("\
--with-auto-load-dir=%s\n\
--with-auto-load-safe-path=%s\n\
@@ -1606,6 +1601,16 @@ This GDB was configured as follows:\n\
(\"Relocatable\" means the directory can be moved with the GDB installation\n\
tree, and GDB will still find it.)\n\
"));
+
+ gdb_printf (stream, "\n");
+ gdb_printf (stream, _("GNU Readline library version: %s\t%s\n"),
+ rl_library_version,
+#ifdef HAVE_READLINE_READLINE_H
+ "(system)"
+#else
+ "(internal)"
+#endif
+ );
}
@@ -2123,6 +2128,17 @@ show_startup_quiet (struct ui_file *file, int from_tty,
}
static void
+init_colorsupport_var ()
+{
+ const std::vector<color_space> &cs = colorsupport ();
+ std::string s;
+ for (color_space c : cs)
+ s.append (s.empty () ? "" : ",").append (color_space_name (c));
+ struct internalvar *colorsupport_var = create_internalvar ("_colorsupport");
+ set_internalvar_string (colorsupport_var, s.c_str ());
+}
+
+static void
init_main (void)
{
/* Initialize the prompt to a simple "(gdb) " prompt or to whatever
@@ -2326,11 +2342,12 @@ gdb_init ()
during startup. */
set_language (language_c);
expected_language = current_language; /* Don't warn about the change. */
+
+ /* Create $_colorsupport convenience variable. */
+ init_colorsupport_var ();
}
-void _initialize_top ();
-void
-_initialize_top ()
+INIT_GDB_FILE (top)
{
/* Determine a default value for the history filename. */
const char *tmpenv = getenv ("GDBHISTFILE");