aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 71514d5..8978c8a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1,6 +1,6 @@
/* Memory-access and commands for "inferior" process, for GDB.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ Copyright (C) 1986-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -27,6 +27,7 @@
#include "gdbsupport/environ.h"
#include "value.h"
#include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
#include "symfile.h"
#include "gdbcore.h"
#include "target.h"
@@ -223,14 +224,11 @@ strip_bg_char (const char *args, int *bg_char_p)
return make_unique_xstrdup (args);
}
-/* Common actions to take after creating any sort of inferior, by any
- means (running, attaching, connecting, et cetera). The target
- should be stopped. */
+/* See inferior.h. */
void
-post_create_inferior (int from_tty)
+post_create_inferior (int from_tty, bool set_pspace_solib_ops)
{
-
/* Be sure we own the terminal in case write operations are performed. */
target_terminal::ours_for_output ();
@@ -260,6 +258,10 @@ post_create_inferior (int from_tty)
throw;
}
+ if (set_pspace_solib_ops)
+ current_program_space->set_solib_ops
+ (gdbarch_make_solib_ops (current_inferior ()->arch ()));
+
if (current_program_space->exec_bfd ())
{
const unsigned solib_add_generation
@@ -383,7 +385,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
/* Clean up any leftovers from other runs. Some other things from
this function should probably be moved into target_pre_inferior. */
- target_pre_inferior (from_tty);
+ target_pre_inferior ();
/* The comment here used to read, "The exec file is re-read every
time we do a generic_mourn_inferior, so we just have to worry
@@ -481,7 +483,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
/* Pass zero for FROM_TTY, because at this point the "run" command
has done its thing; now we are setting up the running program. */
- post_create_inferior (0);
+ post_create_inferior (0, true);
/* Queue a pending event so that the program stops immediately. */
if (run_how == RUN_STOP_AT_FIRST_INSN)
@@ -516,12 +518,6 @@ run_command (const char *args, int from_tty)
static void
start_command (const char *args, int from_tty)
{
- /* Some languages such as Ada need to search inside the program
- minimal symbols for the location where to put the temporary
- breakpoint before starting. */
- if (!have_minimal_symbols ())
- error (_("No symbol table loaded. Use the \"file\" command."));
-
/* Run the program until reaching the main procedure... */
run_command_1 (args, from_tty, RUN_STOP_AT_MAIN);
}
@@ -535,8 +531,8 @@ starti_command (const char *args, int from_tty)
run_command_1 (args, from_tty, RUN_STOP_AT_FIRST_INSN);
}
-static int
-proceed_thread_callback (struct thread_info *thread, void *arg)
+static bool
+proceed_thread_callback (struct thread_info *thread)
{
/* We go through all threads individually instead of compressing
into a single target `resume_all' request, because some threads
@@ -548,15 +544,15 @@ proceed_thread_callback (struct thread_info *thread, void *arg)
thread stopped until I say otherwise', then we can optimize
this. */
if (thread->state != THREAD_STOPPED)
- return 0;
+ return false;
if (!thread->inf->has_execution ())
- return 0;
+ return false;
switch_to_thread (thread);
clear_proceed_status (0);
proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
- return 0;
+ return false;
}
static void
@@ -613,7 +609,7 @@ continue_1 (int all_threads)
scoped_disable_commit_resumed disable_commit_resumed
("continue all threads in non-stop");
- iterate_over_threads (proceed_thread_callback, nullptr);
+ iterate_over_threads (proceed_thread_callback);
if (current_ui->prompt_state == PROMPT_BLOCKED)
{
@@ -992,7 +988,7 @@ prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
Use inlined_subroutine info to make the range more narrow. */
if (inline_skipped_frames (tp) > 0)
{
- symbol *sym = inline_skipped_symbol (tp);
+ const symbol *sym = inline_skipped_symbol (tp);
if (sym->aclass () == LOC_BLOCK)
{
const block *block = sym->value_block ();
@@ -1078,7 +1074,8 @@ jump_command (const char *arg, int from_tty)
{
/* If multiple sal-objects were found, try dropping those that aren't
from the current symtab. */
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
sals.erase (std::remove_if (sals.begin (), sals.end (),
[&] (const symtab_and_line &sal)
{
@@ -1102,7 +1099,9 @@ jump_command (const char *arg, int from_tty)
find_pc_mapped_section (sal.pc));
if (fn != nullptr && sfn != fn)
{
- if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,
+ if (!query (_("Line %ps is not in `%s'. Jump anyway? "),
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
fn->print_name ()))
{
error (_("Not confirmed."));
@@ -1359,7 +1358,7 @@ until_next_command (int from_tty)
if (!func)
{
- struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc);
+ bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc);
if (msymbol.minsym == nullptr)
error (_("Execution is not within a known function."));
@@ -1996,10 +1995,9 @@ info_program_command (const char *args, int from_tty)
}
if (from_tty)
- {
- gdb_printf (_("Type \"info stack\" or \"info "
- "registers\" for more information.\n"));
- }
+ gdb_printf (_("Type \"%ps\" or \"%ps\" for more information.\n"),
+ styled_string (command_style.style (), "info stack"),
+ styled_string (command_style.style (), "info registers"));
}
static void
@@ -2118,9 +2116,10 @@ static const char path_var_name[] = "PATH";
static void
path_info (const char *args, int from_tty)
{
- gdb_puts ("Executable and object file path: ");
- gdb_puts (current_inferior ()->environment.get (path_var_name));
- gdb_puts ("\n");
+ const char *env = current_inferior ()->environment.get (path_var_name);
+
+ gdb_printf (_("Executable and object file path: %s\n"),
+ env != nullptr ? env : "");
}
/* Add zero or more directories to the front of the execution path. */
@@ -2508,7 +2507,7 @@ setup_inferior (int from_tty)
/* Take any necessary post-attaching actions for this platform. */
target_post_attach (inferior_ptid.pid ());
- post_create_inferior (from_tty);
+ post_create_inferior (from_tty, true);
}
/* What to do after the first program stops after attaching. */
@@ -2628,7 +2627,7 @@ attach_command (const char *args, int from_tty)
/* Clean up any leftovers from other runs. Some other things from
this function should probably be moved into target_pre_inferior. */
- target_pre_inferior (from_tty);
+ target_pre_inferior ();
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (args, &async_exec);
args = stripped.get ();
@@ -2827,7 +2826,7 @@ detach_command (const char *args, int from_tty)
/* If the solist is global across inferiors, don't clear it when we
detach from a single inferior. */
if (!gdbarch_has_global_solist (inf->arch ()))
- no_shared_libraries (nullptr, from_tty);
+ no_shared_libraries (inf->pspace);
if (deprecated_detach_hook)
deprecated_detach_hook ();
@@ -2853,7 +2852,7 @@ disconnect_command (const char *args, int from_tty)
query_if_trace_running (from_tty);
disconnect_tracing ();
target_disconnect (args, from_tty);
- no_shared_libraries (nullptr, from_tty);
+ no_shared_libraries (current_program_space);
init_thread_list ();
update_previous_thread ();
if (deprecated_detach_hook)
@@ -2877,7 +2876,7 @@ stop_current_target_threads_ns (ptid_t ptid)
all-stop mode, we will only get one stop event --- it's undefined
which thread will report the event. */
set_stop_requested (current_inferior ()->process_target (),
- ptid, 1);
+ ptid, true);
}
/* See inferior.h. */
@@ -3082,9 +3081,7 @@ use \"set args\" without arguments.\n\
\n\
To start the inferior without using a shell, use \"set startup-with-shell off\"."
-void _initialize_infcmd ();
-void
-_initialize_infcmd ()
+INIT_GDB_FILE (infcmd)
{
static struct cmd_list_element *info_proc_cmdlist;
struct cmd_list_element *c = nullptr;
@@ -3112,7 +3109,7 @@ Follow this command with any number of args, to be passed to the program."),
get_args_value,
show_args_command,
&setlist, &showlist);
- set_cmd_completer (args_set_show.set, filename_completer);
+ set_cmd_completer (args_set_show.set, deprecated_filename_completer);
auto cwd_set_show
= add_setshow_string_noescape_cmd ("cwd", class_run, _("\
@@ -3128,7 +3125,7 @@ working directory."),
set_cwd_value, get_inferior_cwd,
show_cwd_command,
&setlist, &showlist);
- set_cmd_completer (cwd_set_show.set, filename_completer);
+ set_cmd_completer (cwd_set_show.set, deprecated_filename_completer);
c = add_cmd ("environment", no_class, environment_info, _("\
The environment to give the program, or one variable's value.\n\
@@ -3162,7 +3159,7 @@ This path is equivalent to the $PATH shell variable. It is a list of\n\
directories, separated by colons. These directories are searched to find\n\
fully linked executable files and separately compiled object files as \
needed."));
- set_cmd_completer (c, filename_completer);
+ set_cmd_completer (c, deprecated_filename_completer);
c = add_cmd ("paths", no_class, path_info, _("\
Current search path for finding object files.\n\
@@ -3279,8 +3276,10 @@ frame."));
add_com_alias ("u", until_cmd, class_run, 1);
c = add_com ("advance", class_run, advance_command, _("\
-Continue the program up to the given location (same form as args for break \
-command).\n\
+Continue the program up to the given location.\n\
+Usage: advance LOCSPEC\n\
+The argument is a location specification, i.e., the same forms\n\
+accepted by the 'break' command.\n\
Execution will also stop upon exit from the current stack frame."));
set_cmd_completer (c, location_completer);
@@ -3312,18 +3311,18 @@ Specifying -a and an ignore count simultaneously is an error."));
= add_com ("run", class_run, run_command, _("\
Start debugged program.\n"
RUN_ARGS_HELP));
- set_cmd_completer (run_cmd, filename_completer);
+ set_cmd_completer (run_cmd, deprecated_filename_completer);
add_com_alias ("r", run_cmd, class_run, 1);
c = add_com ("start", class_run, start_command, _("\
Start the debugged program stopping at the beginning of the main procedure.\n"
RUN_ARGS_HELP));
- set_cmd_completer (c, filename_completer);
+ set_cmd_completer (c, deprecated_filename_completer);
c = add_com ("starti", class_run, starti_command, _("\
Start the debugged program stopping at the first instruction.\n"
RUN_ARGS_HELP));
- set_cmd_completer (c, filename_completer);
+ set_cmd_completer (c, deprecated_filename_completer);
add_com ("interrupt", class_run, interrupt_command,
_("Interrupt the execution of the debugged program.\n\