aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index e9b58ce..e4b3e5b 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -25,6 +25,7 @@
#include "inferior.h"
#include "infrun.h"
#include "gdbsupport/environ.h"
+#include "gdbsupport/common-inferior.h"
#include "value.h"
#include "cli/cli-cmds.h"
#include "cli/cli-style.h"
@@ -39,7 +40,6 @@
#include "reggroups.h"
#include "block.h"
#include "solib.h"
-#include <ctype.h>
#include "observable.h"
#include "target-descriptions.h"
#include "user-regs.h"
@@ -111,13 +111,9 @@ static void
show_inferior_tty_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- /* Note that we ignore the passed-in value in favor of computing it
- directly. */
- const std::string &inferior_tty = current_inferior ()->tty ();
-
gdb_printf (file,
_("Terminal for future runs of program being debugged "
- "is \"%s\".\n"), inferior_tty.c_str ());
+ "is \"%s\".\n"), value);
}
/* Store the new value passed to 'set args'. */
@@ -142,11 +138,9 @@ static void
show_args_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- /* Ignore the passed in value, pull the argument directly from the
- inferior. However, these should always be the same. */
gdb_printf (file, _("\
Argument list to give program being debugged when it is started is \"%s\".\n"),
- current_inferior ()->args ().c_str ());
+ value);
}
/* See gdbsupport/common-inferior.h. */
@@ -171,9 +165,7 @@ static void
show_cwd_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- const std::string &cwd = current_inferior ()->cwd ();
-
- if (cwd.empty ())
+ if (strlen (value) == 0)
gdb_printf (file,
_("\
You have not set the inferior's current working directory.\n\
@@ -183,7 +175,7 @@ server's cwd if remote debugging.\n"));
gdb_printf (file,
_("Current working directory that will be used "
"when starting the inferior is \"%s\".\n"),
- cwd.c_str ());
+ value);
}
@@ -209,7 +201,7 @@ strip_bg_char (const char *args, int *bg_char_p)
if (p[-1] == '&')
{
p--;
- while (p > args && isspace (p[-1]))
+ while (p > args && c_isspace (p[-1]))
p--;
*bg_char_p = 1;
@@ -224,14 +216,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 ();
@@ -261,6 +250,11 @@ 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 (),
+ current_program_space));
+
if (current_program_space->exec_bfd ())
{
const unsigned solib_add_generation
@@ -482,7 +476,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)
@@ -493,6 +487,11 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
thr->set_pending_waitstatus (ws);
}
+ /* Still call clear_proceed_status; in schedule multiple mode the proceed
+ can resume threads from other inferiors, which might need clearing
+ prior to a proceed call. */
+ clear_proceed_status (0);
+
/* Start the target running. Do not use -1 continuation as it would skip
breakpoint right at the entry point. */
proceed (regcache_read_pc (get_thread_regcache (inferior_thread ())),
@@ -988,7 +987,7 @@ prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
if (inline_skipped_frames (tp) > 0)
{
const symbol *sym = inline_skipped_symbol (tp);
- if (sym->aclass () == LOC_BLOCK)
+ if (sym->loc_class () == LOC_BLOCK)
{
const block *block = sym->value_block ();
if (block->end () < tp->control.step_range_end)
@@ -1196,20 +1195,20 @@ signal_command (const char *signum_exp, int from_tty)
thread_info *current = inferior_thread ();
- for (thread_info *tp : all_non_exited_threads (resume_target, resume_ptid))
+ for (thread_info &tp : all_non_exited_threads (resume_target, resume_ptid))
{
- if (tp == current)
+ if (&tp == current)
continue;
- if (tp->stop_signal () != GDB_SIGNAL_0
- && signal_pass_state (tp->stop_signal ()))
+ if (tp.stop_signal () != GDB_SIGNAL_0
+ && signal_pass_state (tp.stop_signal ()))
{
if (!must_confirm)
gdb_printf (_("Note:\n"));
gdb_printf (_(" Thread %s previously stopped with signal %s, %s.\n"),
- print_thread_id (tp),
- gdb_signal_to_name (tp->stop_signal ()),
- gdb_signal_to_string (tp->stop_signal ()));
+ print_thread_id (&tp),
+ gdb_signal_to_name (tp.stop_signal ()),
+ gdb_signal_to_string (tp.stop_signal ()));
must_confirm = 1;
}
}
@@ -2306,12 +2305,12 @@ registers_info (const char *addr_exp, int fpregs)
resembling a register following it. */
if (addr_exp[0] == '$')
addr_exp++;
- if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
+ if (c_isspace ((*addr_exp)) || (*addr_exp) == '\0')
error (_("Missing register name"));
/* Find the start/end of this register name/num/group. */
start = addr_exp;
- while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
+ while ((*addr_exp) != '\0' && !c_isspace ((*addr_exp)))
addr_exp++;
end = addr_exp;
@@ -2472,12 +2471,12 @@ proceed_after_attach (inferior *inf)
/* Backup current thread and selected frame. */
scoped_restore_current_thread restore_thread;
- for (thread_info *thread : inf->non_exited_threads ())
- if (!thread->executing ()
- && !thread->stop_requested
- && thread->stop_signal () == GDB_SIGNAL_0)
+ for (thread_info &thread : inf->non_exited_threads ())
+ if (!thread.executing ()
+ && !thread.stop_requested
+ && thread.stop_signal () == GDB_SIGNAL_0)
{
- switch_to_thread (thread);
+ switch_to_thread (&thread);
clear_proceed_status (0);
proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
}
@@ -2506,7 +2505,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. */
@@ -2581,10 +2580,10 @@ attach_post_wait (int from_tty, enum attach_post_wait_mode mode)
stop. For consistency, always select the thread with
lowest GDB number, which should be the main thread, if it
still exists. */
- for (thread_info *thread : current_inferior ()->non_exited_threads ())
- if (thread->inf->num < lowest->inf->num
- || thread->per_inf_num < lowest->per_inf_num)
- lowest = thread;
+ for (thread_info &thread : current_inferior ()->non_exited_threads ())
+ if (thread.inf->num < lowest->inf->num
+ || thread.per_inf_num < lowest->per_inf_num)
+ lowest = &thread;
switch_to_thread (lowest);
}
@@ -3080,9 +3079,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;