aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/main.c')
-rw-r--r--gdb/main.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/gdb/main.c b/gdb/main.c
index e4a40c5..1806ca0 100644
--- a/gdb/main.c
+++ b/gdb/main.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.
@@ -58,6 +58,7 @@
#include "observable.h"
#include "serial.h"
#include "cli-out.h"
+#include "bt-utils.h"
/* The selected interpreter. */
std::string interpreter_p;
@@ -398,7 +399,7 @@ start_event_loop ()
try
{
- result = gdb_do_one_event ();
+ result = current_interpreter ()->do_one_event ();
}
catch (const gdb_exception_forced_quit &ex)
{
@@ -643,9 +644,9 @@ captured_main_1 (struct captured_main_args *context)
int save_auto_load;
int ret = 1;
- const char *no_color = getenv ("NO_COLOR");
- if (no_color != nullptr && *no_color != '\0')
- cli_styling = false;
+ /* Check for environment variables which might cause GDB to start with
+ styling disabled. */
+ disable_styling_from_environment ();
#ifdef HAVE_USEFUL_SBRK
/* Set this before constructing scoped_command_stats. */
@@ -671,11 +672,14 @@ captured_main_1 (struct captured_main_args *context)
/* Ensure stderr is unbuffered. A Cygwin pty or pipe is implemented
as a Windows pipe, and Windows buffers on pipes. */
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+ windows_initialize_console ();
#endif
/* Note: `error' cannot be called before this point, because the
caller will crash when trying to print the exception. */
main_ui = new ui (stdin, stdout, stderr);
+ gdb_internal_backtrace_init_str ();
current_ui = main_ui;
gdb_stdtarg = gdb_stderr;
@@ -703,7 +707,7 @@ captured_main_1 (struct captured_main_args *context)
/* Prefix warning messages with the command name. */
gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
- = xstrprintf ("%s: warning: ", gdb_program_name);
+ = xstrprintf ("%s: ", gdb_program_name);
warning_pre_print = tmp_warn_preprint.get ();
current_directory = getcwd (NULL, 0);
@@ -1025,7 +1029,7 @@ captured_main_1 (struct captured_main_args *context)
quiet = 1;
/* Disable all output styling when running in batch mode. */
- cli_styling = 0;
+ disable_cli_styling ();
}
}
@@ -1076,7 +1080,8 @@ captured_main_1 (struct captured_main_args *context)
execarg = argv[optind];
++optind;
current_inferior ()->set_args
- (gdb::array_view<char * const> (&argv[optind], argc - optind));
+ (gdb::array_view<char * const> (&argv[optind], argc - optind),
+ startup_with_shell);
}
else
{
@@ -1121,7 +1126,7 @@ captured_main_1 (struct captured_main_args *context)
/* Do these (and anything which might call wrap_here or *_filtered)
after initialize_all_files() but before the interpreter has been
- installed. Otherwize the help/version messages will be eaten by
+ installed. Otherwise the help/version messages will be eaten by
the interpreter's output handler. */
if (print_version)
@@ -1166,7 +1171,7 @@ captured_main_1 (struct captured_main_args *context)
/* Set off error and warning messages with a blank line. */
tmp_warn_preprint.reset ();
- warning_pre_print = _("\nwarning: ");
+ warning_pre_print = "\n";
/* Read and execute the system-wide gdbinit file, if it exists.
This is done *before* all the command line arguments are
@@ -1233,7 +1238,8 @@ captured_main_1 (struct captured_main_args *context)
if (corearg != NULL)
{
- ret = catch_command_errors (core_file_command, corearg,
+ ret = catch_command_errors (core_file_command,
+ make_quoted_string (corearg).c_str (),
!batch_flag);
}
else if (pidarg != NULL)
@@ -1251,16 +1257,18 @@ captured_main_1 (struct captured_main_args *context)
ret = catch_command_errors (attach_command, pid_or_core_arg,
!batch_flag);
if (ret == 0)
- ret = catch_command_errors (core_file_command,
- pid_or_core_arg,
- !batch_flag);
+ ret = catch_command_errors
+ (core_file_command,
+ make_quoted_string (pid_or_core_arg).c_str (),
+ !batch_flag);
}
else
{
/* Can't be a pid, better be a corefile. */
- ret = catch_command_errors (core_file_command,
- pid_or_core_arg,
- !batch_flag);
+ ret = catch_command_errors
+ (core_file_command,
+ make_quoted_string (pid_or_core_arg).c_str (),
+ !batch_flag);
}
}
@@ -1268,7 +1276,7 @@ captured_main_1 (struct captured_main_args *context)
current_inferior ()->set_tty (ttyarg);
/* Error messages should no longer be distinguished with extra output. */
- warning_pre_print = _("warning: ");
+ warning_pre_print = "";
/* Read the .gdbinit file in the current directory, *if* it isn't
the same as the $HOME/.gdbinit file (it should exist, also). */
@@ -1491,10 +1499,11 @@ At startup, GDB reads the following init files and executes their commands:\n\
&& local_gdbinit.empty ())
gdb_printf (stream, _("\
None found.\n"));
- gdb_puts (_("\n\
-For more information, type \"help\" from within GDB, or consult the\n\
+ gdb_printf (stream, _("\n\
+For more information, type \"%ps\" from within GDB, or consult the\n\
GDB manual (available as on-line info or a printed manual).\n\
-"), stream);
+"),
+ styled_string (command_style.style (), "stream"));
if (REPORT_BUGS_TO[0] && stream == gdb_stdout)
gdb_printf (stream, _("\n\
Report bugs to %ps.\n\