Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Memory-access and commands for "inferior" process, for GDB. |
990a07ab | 2 | |
6aba47ca | 3 | Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, |
9b254dd1 | 4 | 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
7b6bb8da | 5 | 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
c906108c | 6 | |
c5aa993b | 7 | This file is part of GDB. |
c906108c | 8 | |
c5aa993b JM |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 12 | (at your option) any later version. |
c906108c | 13 | |
c5aa993b JM |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
c906108c | 18 | |
c5aa993b | 19 | You should have received a copy of the GNU General Public License |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
21 | |
22 | #include "defs.h" | |
5af949e3 | 23 | #include "arch-utils.h" |
c906108c SS |
24 | #include <signal.h> |
25 | #include "gdb_string.h" | |
26 | #include "symtab.h" | |
27 | #include "gdbtypes.h" | |
28 | #include "frame.h" | |
29 | #include "inferior.h" | |
30 | #include "environ.h" | |
31 | #include "value.h" | |
32 | #include "gdbcmd.h" | |
1adeb98a | 33 | #include "symfile.h" |
c906108c SS |
34 | #include "gdbcore.h" |
35 | #include "target.h" | |
36 | #include "language.h" | |
37 | #include "symfile.h" | |
38 | #include "objfiles.h" | |
c94fdfd0 | 39 | #include "completer.h" |
8b93c638 | 40 | #include "ui-out.h" |
6426a772 | 41 | #include "event-top.h" |
96baa820 | 42 | #include "parser-defs.h" |
36160dc4 | 43 | #include "regcache.h" |
f9418c0f | 44 | #include "reggroups.h" |
fe898f56 | 45 | #include "block.h" |
a77053c2 | 46 | #include "solib.h" |
f9418c0f | 47 | #include <ctype.h> |
92ad9cd9 | 48 | #include "gdb_assert.h" |
281b533b | 49 | #include "observer.h" |
424163ea | 50 | #include "target-descriptions.h" |
ad842144 | 51 | #include "user-regs.h" |
32c1e744 | 52 | #include "exceptions.h" |
700b53b1 | 53 | #include "cli/cli-decode.h" |
a0ef4274 | 54 | #include "gdbthread.h" |
79a45b7d | 55 | #include "valprint.h" |
edb3359d | 56 | #include "inline-frame.h" |
573cda03 | 57 | #include "tracepoint.h" |
09cee04b | 58 | #include "inf-loop.h" |
be34f849 | 59 | #include "continuations.h" |
f8eba3c6 | 60 | #include "linespec.h" |
d5551862 | 61 | |
a58dd373 | 62 | /* Functions exported for general use, in inferior.h: */ |
c906108c | 63 | |
a14ed312 | 64 | void all_registers_info (char *, int); |
c906108c | 65 | |
a14ed312 | 66 | void registers_info (char *, int); |
c906108c | 67 | |
a58dd373 EZ |
68 | void nexti_command (char *, int); |
69 | ||
70 | void stepi_command (char *, int); | |
c906108c | 71 | |
a14ed312 | 72 | void continue_command (char *, int); |
c906108c | 73 | |
a58dd373 EZ |
74 | void interrupt_target_command (char *args, int from_tty); |
75 | ||
76 | /* Local functions: */ | |
77 | ||
78 | static void nofp_registers_info (char *, int); | |
79 | ||
c055b101 CV |
80 | static void print_return_value (struct type *func_type, |
81 | struct type *value_type); | |
11cf8741 | 82 | |
a14ed312 | 83 | static void until_next_command (int); |
c906108c | 84 | |
a14ed312 | 85 | static void until_command (char *, int); |
c906108c | 86 | |
a14ed312 | 87 | static void path_info (char *, int); |
c906108c | 88 | |
a14ed312 | 89 | static void path_command (char *, int); |
c906108c | 90 | |
a14ed312 | 91 | static void unset_command (char *, int); |
c906108c | 92 | |
a14ed312 | 93 | static void float_info (char *, int); |
c906108c | 94 | |
6ad8ae5c DJ |
95 | static void disconnect_command (char *, int); |
96 | ||
a14ed312 | 97 | static void unset_environment_command (char *, int); |
c906108c | 98 | |
a14ed312 | 99 | static void set_environment_command (char *, int); |
c906108c | 100 | |
a14ed312 | 101 | static void environment_info (char *, int); |
c906108c | 102 | |
a14ed312 | 103 | static void program_info (char *, int); |
c906108c | 104 | |
a14ed312 | 105 | static void finish_command (char *, int); |
c906108c | 106 | |
a14ed312 | 107 | static void signal_command (char *, int); |
c906108c | 108 | |
a14ed312 | 109 | static void jump_command (char *, int); |
c906108c | 110 | |
a14ed312 | 111 | static void step_1 (int, int, char *); |
3e43a32a MS |
112 | static void step_once (int skip_subroutines, int single_inst, |
113 | int count, int thread); | |
c906108c | 114 | |
a14ed312 | 115 | static void next_command (char *, int); |
c906108c | 116 | |
a14ed312 | 117 | static void step_command (char *, int); |
c906108c | 118 | |
a14ed312 | 119 | static void run_command (char *, int); |
c906108c | 120 | |
a14ed312 | 121 | static void run_no_args_command (char *args, int from_tty); |
392a587b | 122 | |
a14ed312 | 123 | static void go_command (char *line_no, int from_tty); |
392a587b | 124 | |
a14ed312 | 125 | static int strip_bg_char (char **); |
43ff13b4 | 126 | |
a14ed312 | 127 | void _initialize_infcmd (void); |
c906108c | 128 | |
c906108c | 129 | #define ERROR_NO_INFERIOR \ |
8a3fe4f8 | 130 | if (!target_has_execution) error (_("The program is not being run.")); |
c906108c | 131 | |
3e43a32a MS |
132 | /* Scratch area where string containing arguments to give to the |
133 | program will be stored by 'set args'. As soon as anything is | |
134 | stored, notice_args_set will move it into per-inferior storage. | |
1777feb0 | 135 | Arguments are separated by spaces. Empty string (pointer to '\0') |
3e43a32a | 136 | means no args. */ |
c906108c | 137 | |
3f81c18a | 138 | static char *inferior_args_scratch; |
c906108c | 139 | |
3f81c18a VP |
140 | /* Scratch area where 'set inferior-tty' will store user-provided value. |
141 | We'll immediate copy it into per-inferior storage. */ | |
552c04a7 | 142 | |
3f81c18a | 143 | static char *inferior_io_terminal_scratch; |
c906108c SS |
144 | |
145 | /* Pid of our debugged inferior, or 0 if no inferior now. | |
146 | Since various parts of infrun.c test this to see whether there is a program | |
147 | being debugged it should be nonzero (currently 3 is used) for remote | |
148 | debugging. */ | |
149 | ||
39f77062 | 150 | ptid_t inferior_ptid; |
c906108c | 151 | |
c906108c SS |
152 | /* Address at which inferior stopped. */ |
153 | ||
154 | CORE_ADDR stop_pc; | |
155 | ||
c906108c SS |
156 | /* Flag indicating that a command has proceeded the inferior past the |
157 | current breakpoint. */ | |
158 | ||
159 | int breakpoint_proceeded; | |
160 | ||
c906108c SS |
161 | /* Nonzero if stopped due to completion of a stack dummy routine. */ |
162 | ||
aa7d318d | 163 | enum stop_stack_kind stop_stack_dummy; |
c906108c SS |
164 | |
165 | /* Nonzero if stopped due to a random (unexpected) signal in inferior | |
166 | process. */ | |
167 | ||
168 | int stopped_by_random_signal; | |
169 | ||
c906108c | 170 | \f |
1777feb0 | 171 | /* Accessor routines. */ |
07091751 | 172 | |
3f81c18a VP |
173 | /* Set the io terminal for the current inferior. Ownership of |
174 | TERMINAL_NAME is not transferred. */ | |
175 | ||
3cb3b8df BR |
176 | void |
177 | set_inferior_io_terminal (const char *terminal_name) | |
178 | { | |
3f81c18a VP |
179 | xfree (current_inferior ()->terminal); |
180 | current_inferior ()->terminal = terminal_name ? xstrdup (terminal_name) : 0; | |
3cb3b8df BR |
181 | } |
182 | ||
183 | const char * | |
184 | get_inferior_io_terminal (void) | |
185 | { | |
3f81c18a VP |
186 | return current_inferior ()->terminal; |
187 | } | |
188 | ||
189 | static void | |
190 | set_inferior_tty_command (char *args, int from_tty, | |
191 | struct cmd_list_element *c) | |
192 | { | |
193 | /* CLI has assigned the user-provided value to inferior_io_terminal_scratch. | |
194 | Now route it to current inferior. */ | |
195 | set_inferior_io_terminal (inferior_io_terminal_scratch); | |
196 | } | |
197 | ||
198 | static void | |
199 | show_inferior_tty_command (struct ui_file *file, int from_tty, | |
200 | struct cmd_list_element *c, const char *value) | |
201 | { | |
202 | /* Note that we ignore the passed-in value in favor of computing it | |
203 | directly. */ | |
275f2e57 | 204 | const char *inferior_io_terminal = get_inferior_io_terminal (); |
abbb1732 | 205 | |
275f2e57 DJ |
206 | if (inferior_io_terminal == NULL) |
207 | inferior_io_terminal = ""; | |
3f81c18a | 208 | fprintf_filtered (gdb_stdout, |
275f2e57 DJ |
209 | _("Terminal for future runs of program being debugged " |
210 | "is \"%s\".\n"), inferior_io_terminal); | |
3cb3b8df BR |
211 | } |
212 | ||
07091751 FN |
213 | char * |
214 | get_inferior_args (void) | |
215 | { | |
3f81c18a | 216 | if (current_inferior ()->argc != 0) |
552c04a7 | 217 | { |
3f81c18a | 218 | char *n; |
552c04a7 | 219 | |
3f81c18a VP |
220 | n = construct_inferior_arguments (current_inferior ()->argc, |
221 | current_inferior ()->argv); | |
222 | set_inferior_args (n); | |
223 | xfree (n); | |
552c04a7 TT |
224 | } |
225 | ||
3f81c18a VP |
226 | if (current_inferior ()->args == NULL) |
227 | current_inferior ()->args = xstrdup (""); | |
552c04a7 | 228 | |
3f81c18a | 229 | return current_inferior ()->args; |
07091751 FN |
230 | } |
231 | ||
3f81c18a VP |
232 | /* Set the arguments for the current inferior. Ownership of |
233 | NEWARGS is not transferred. */ | |
234 | ||
235 | void | |
07091751 FN |
236 | set_inferior_args (char *newargs) |
237 | { | |
3f81c18a VP |
238 | xfree (current_inferior ()->args); |
239 | current_inferior ()->args = newargs ? xstrdup (newargs) : NULL; | |
240 | current_inferior ()->argc = 0; | |
241 | current_inferior ()->argv = 0; | |
07091751 | 242 | } |
c5aa993b | 243 | |
552c04a7 TT |
244 | void |
245 | set_inferior_args_vector (int argc, char **argv) | |
246 | { | |
3f81c18a VP |
247 | current_inferior ()->argc = argc; |
248 | current_inferior ()->argv = argv; | |
552c04a7 TT |
249 | } |
250 | ||
251 | /* Notice when `set args' is run. */ | |
252 | static void | |
3f81c18a | 253 | set_args_command (char *args, int from_tty, struct cmd_list_element *c) |
552c04a7 | 254 | { |
3f81c18a VP |
255 | /* CLI has assigned the user-provided value to inferior_args_scratch. |
256 | Now route it to current inferior. */ | |
257 | set_inferior_args (inferior_args_scratch); | |
552c04a7 TT |
258 | } |
259 | ||
260 | /* Notice when `show args' is run. */ | |
261 | static void | |
3f81c18a VP |
262 | show_args_command (struct ui_file *file, int from_tty, |
263 | struct cmd_list_element *c, const char *value) | |
552c04a7 | 264 | { |
258c00cc TT |
265 | /* Note that we ignore the passed-in value in favor of computing it |
266 | directly. */ | |
267 | deprecated_show_value_hack (file, from_tty, c, get_inferior_args ()); | |
552c04a7 TT |
268 | } |
269 | ||
c2a727fa TT |
270 | \f |
271 | /* Compute command-line string given argument vector. This does the | |
272 | same shell processing as fork_inferior. */ | |
c2a727fa | 273 | char * |
bd57a748 | 274 | construct_inferior_arguments (int argc, char **argv) |
c2a727fa TT |
275 | { |
276 | char *result; | |
277 | ||
278 | if (STARTUP_WITH_SHELL) | |
279 | { | |
280 | /* This holds all the characters considered special to the | |
281 | typical Unix shells. We include `^' because the SunOS | |
282 | /bin/sh treats it as a synonym for `|'. */ | |
283 | char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n"; | |
284 | int i; | |
285 | int length = 0; | |
286 | char *out, *cp; | |
287 | ||
288 | /* We over-compute the size. It shouldn't matter. */ | |
289 | for (i = 0; i < argc; ++i) | |
c2226152 | 290 | length += 3 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0'); |
c2a727fa TT |
291 | |
292 | result = (char *) xmalloc (length); | |
293 | out = result; | |
294 | ||
295 | for (i = 0; i < argc; ++i) | |
296 | { | |
297 | if (i > 0) | |
298 | *out++ = ' '; | |
299 | ||
03c6228e AS |
300 | /* Need to handle empty arguments specially. */ |
301 | if (argv[i][0] == '\0') | |
c2a727fa | 302 | { |
03c6228e AS |
303 | *out++ = '\''; |
304 | *out++ = '\''; | |
305 | } | |
306 | else | |
307 | { | |
308 | for (cp = argv[i]; *cp; ++cp) | |
309 | { | |
c2226152 AS |
310 | if (*cp == '\n') |
311 | { | |
312 | /* A newline cannot be quoted with a backslash (it | |
313 | just disappears), only by putting it inside | |
314 | quotes. */ | |
315 | *out++ = '\''; | |
316 | *out++ = '\n'; | |
317 | *out++ = '\''; | |
318 | } | |
319 | else | |
320 | { | |
321 | if (strchr (special, *cp) != NULL) | |
322 | *out++ = '\\'; | |
323 | *out++ = *cp; | |
324 | } | |
03c6228e | 325 | } |
c2a727fa TT |
326 | } |
327 | } | |
328 | *out = '\0'; | |
329 | } | |
330 | else | |
331 | { | |
332 | /* In this case we can't handle arguments that contain spaces, | |
333 | tabs, or newlines -- see breakup_args(). */ | |
334 | int i; | |
335 | int length = 0; | |
336 | ||
337 | for (i = 0; i < argc; ++i) | |
338 | { | |
339 | char *cp = strchr (argv[i], ' '); | |
340 | if (cp == NULL) | |
341 | cp = strchr (argv[i], '\t'); | |
342 | if (cp == NULL) | |
343 | cp = strchr (argv[i], '\n'); | |
344 | if (cp != NULL) | |
3e43a32a MS |
345 | error (_("can't handle command-line " |
346 | "argument containing whitespace")); | |
c2a727fa TT |
347 | length += strlen (argv[i]) + 1; |
348 | } | |
349 | ||
350 | result = (char *) xmalloc (length); | |
351 | result[0] = '\0'; | |
352 | for (i = 0; i < argc; ++i) | |
353 | { | |
354 | if (i > 0) | |
355 | strcat (result, " "); | |
356 | strcat (result, argv[i]); | |
357 | } | |
358 | } | |
359 | ||
360 | return result; | |
361 | } | |
552c04a7 TT |
362 | \f |
363 | ||
43ff13b4 JM |
364 | /* This function detects whether or not a '&' character (indicating |
365 | background execution) has been added as *the last* of the arguments ARGS | |
1777feb0 MS |
366 | of a command. If it has, it removes it and returns 1. Otherwise it |
367 | does nothing and returns 0. */ | |
c5aa993b | 368 | static int |
fba45db2 | 369 | strip_bg_char (char **args) |
43ff13b4 JM |
370 | { |
371 | char *p = NULL; | |
c5aa993b | 372 | |
9846de1b | 373 | p = strchr (*args, '&'); |
c5aa993b | 374 | |
9846de1b | 375 | if (p) |
43ff13b4 JM |
376 | { |
377 | if (p == (*args + strlen (*args) - 1)) | |
378 | { | |
c5aa993b | 379 | if (strlen (*args) > 1) |
43ff13b4 JM |
380 | { |
381 | do | |
382 | p--; | |
383 | while (*p == ' ' || *p == '\t'); | |
384 | *(p + 1) = '\0'; | |
385 | } | |
386 | else | |
387 | *args = 0; | |
388 | return 1; | |
389 | } | |
390 | } | |
391 | return 0; | |
392 | } | |
393 | ||
281b533b DJ |
394 | /* Common actions to take after creating any sort of inferior, by any |
395 | means (running, attaching, connecting, et cetera). The target | |
396 | should be stopped. */ | |
397 | ||
398 | void | |
399 | post_create_inferior (struct target_ops *target, int from_tty) | |
400 | { | |
ce406537 PA |
401 | volatile struct gdb_exception ex; |
402 | ||
b79599ff DP |
403 | /* Be sure we own the terminal in case write operations are performed. */ |
404 | target_terminal_ours (); | |
405 | ||
424163ea DJ |
406 | /* If the target hasn't taken care of this already, do it now. |
407 | Targets which need to access registers during to_open, | |
408 | to_create_inferior, or to_attach should do it earlier; but many | |
409 | don't need to. */ | |
410 | target_find_description (); | |
411 | ||
ce406537 PA |
412 | /* Now that we know the register layout, retrieve current PC. But |
413 | if the PC is unavailable (e.g., we're opening a core file with | |
414 | missing registers info), ignore it. */ | |
415 | stop_pc = 0; | |
416 | TRY_CATCH (ex, RETURN_MASK_ERROR) | |
417 | { | |
418 | stop_pc = regcache_read_pc (get_current_regcache ()); | |
419 | } | |
420 | if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) | |
421 | throw_exception (ex); | |
f698437e | 422 | |
50c71eaf PA |
423 | if (exec_bfd) |
424 | { | |
2eff07b3 PP |
425 | const unsigned solib_add_generation |
426 | = current_program_space->solib_add_generation; | |
427 | ||
9353355f DJ |
428 | /* Create the hooks to handle shared library load and unload |
429 | events. */ | |
430 | #ifdef SOLIB_CREATE_INFERIOR_HOOK | |
37706b70 | 431 | SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); |
9353355f | 432 | #else |
268a4a75 JK |
433 | solib_create_inferior_hook (from_tty); |
434 | #endif | |
268a4a75 | 435 | |
2eff07b3 PP |
436 | if (current_program_space->solib_add_generation == solib_add_generation) |
437 | { | |
438 | /* The platform-specific hook should load initial shared libraries, | |
439 | but didn't. FROM_TTY will be incorrectly 0 but such solib | |
440 | targets should be fixed anyway. Call it only after the solib | |
441 | target has been initialized by solib_create_inferior_hook. */ | |
442 | ||
443 | if (info_verbose) | |
444 | warning (_("platform-specific solib_create_inferior_hook did " | |
445 | "not load initial shared libraries.")); | |
446 | ||
447 | /* If the solist is global across processes, there's no need to | |
448 | refetch it here. */ | |
449 | if (!gdbarch_has_global_solist (target_gdbarch)) | |
450 | { | |
268a4a75 | 451 | #ifdef SOLIB_ADD |
2eff07b3 | 452 | SOLIB_ADD (NULL, 0, target, auto_solib_add); |
268a4a75 | 453 | #else |
2eff07b3 | 454 | solib_add (NULL, 0, target, auto_solib_add); |
9353355f | 455 | #endif |
2eff07b3 PP |
456 | } |
457 | } | |
9353355f DJ |
458 | } |
459 | ||
ea5d7a99 PM |
460 | /* If the user sets watchpoints before execution having started, |
461 | then she gets software watchpoints, because GDB can't know which | |
462 | target will end up being pushed, or if it supports hardware | |
463 | watchpoints or not. breakpoint_re_set takes care of promoting | |
464 | watchpoints to hardware watchpoints if possible, however, if this | |
465 | new inferior doesn't load shared libraries or we don't pull in | |
466 | symbols from any other source on this target/arch, | |
467 | breakpoint_re_set is never called. Call it now so that software | |
468 | watchpoints get a chance to be promoted to hardware watchpoints | |
469 | if the now pushed target supports hardware watchpoints. */ | |
470 | breakpoint_re_set (); | |
471 | ||
281b533b DJ |
472 | observer_notify_inferior_created (target, from_tty); |
473 | } | |
474 | ||
a4d5f2e0 JB |
475 | /* Kill the inferior if already running. This function is designed |
476 | to be called when we are about to start the execution of the program | |
477 | from the beginning. Ask the user to confirm that he wants to restart | |
478 | the program being debugged when FROM_TTY is non-null. */ | |
c906108c | 479 | |
8edfe269 | 480 | static void |
a4d5f2e0 JB |
481 | kill_if_already_running (int from_tty) |
482 | { | |
39f77062 | 483 | if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) |
c906108c | 484 | { |
8edfe269 DJ |
485 | /* Bail out before killing the program if we will not be able to |
486 | restart it. */ | |
487 | target_require_runnable (); | |
488 | ||
adf40b2e | 489 | if (from_tty |
9e2f0ad4 HZ |
490 | && !query (_("The program being debugged has been started already.\n\ |
491 | Start it from the beginning? "))) | |
8a3fe4f8 | 492 | error (_("Program not restarted.")); |
c906108c | 493 | target_kill (); |
c906108c | 494 | } |
a4d5f2e0 JB |
495 | } |
496 | ||
1777feb0 | 497 | /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert |
f67a969f JB |
498 | a temporary breakpoint at the begining of the main program before |
499 | running the program. */ | |
500 | ||
a4d5f2e0 | 501 | static void |
f67a969f | 502 | run_command_1 (char *args, int from_tty, int tbreak_at_main) |
a4d5f2e0 JB |
503 | { |
504 | char *exec_file; | |
29f49a6a PA |
505 | struct cleanup *old_chain; |
506 | ptid_t ptid; | |
79a45e25 | 507 | struct ui_out *uiout = current_uiout; |
c906108c | 508 | |
a4d5f2e0 JB |
509 | dont_repeat (); |
510 | ||
511 | kill_if_already_running (from_tty); | |
3c35e65b UW |
512 | |
513 | init_wait_for_inferior (); | |
c906108c SS |
514 | clear_breakpoint_hit_counts (); |
515 | ||
fd79ecee DJ |
516 | /* Clean up any leftovers from other runs. Some other things from |
517 | this function should probably be moved into target_pre_inferior. */ | |
518 | target_pre_inferior (from_tty); | |
519 | ||
39ad761d JB |
520 | /* The comment here used to read, "The exec file is re-read every |
521 | time we do a generic_mourn_inferior, so we just have to worry | |
522 | about the symbol file." The `generic_mourn_inferior' function | |
523 | gets called whenever the program exits. However, suppose the | |
524 | program exits, and *then* the executable file changes? We need | |
525 | to check again here. Since reopen_exec_file doesn't do anything | |
526 | if the timestamp hasn't changed, I don't see the harm. */ | |
527 | reopen_exec_file (); | |
c906108c SS |
528 | reread_symbols (); |
529 | ||
f67a969f JB |
530 | /* Insert the temporary breakpoint if a location was specified. */ |
531 | if (tbreak_at_main) | |
532 | tbreak_command (main_name (), 0); | |
533 | ||
39ad761d JB |
534 | exec_file = (char *) get_exec_file (0); |
535 | ||
9908b566 VP |
536 | if (non_stop && !target_supports_non_stop ()) |
537 | error (_("The target does not support running in non-stop mode.")); | |
538 | ||
c906108c SS |
539 | /* We keep symbols from add-symbol-file, on the grounds that the |
540 | user might want to add some symbols before running the program | |
541 | (right?). But sometimes (dynamic loading where the user manually | |
542 | introduces the new symbols with add-symbol-file), the code which | |
543 | the symbols describe does not persist between runs. Currently | |
544 | the user has to manually nuke all symbols between runs if they | |
545 | want them to go away (PR 2207). This is probably reasonable. */ | |
546 | ||
43ff13b4 | 547 | if (!args) |
6426a772 | 548 | { |
362646f5 | 549 | if (target_can_async_p ()) |
6426a772 JM |
550 | async_disable_stdin (); |
551 | } | |
43ff13b4 | 552 | else |
c906108c | 553 | { |
43ff13b4 JM |
554 | int async_exec = strip_bg_char (&args); |
555 | ||
556 | /* If we get a request for running in the bg but the target | |
1777feb0 | 557 | doesn't support it, error out. */ |
362646f5 | 558 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 559 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 JM |
560 | |
561 | /* If we don't get a request of running in the bg, then we need | |
1777feb0 | 562 | to simulate synchronous (fg) execution. */ |
362646f5 | 563 | if (!async_exec && target_can_async_p ()) |
43ff13b4 | 564 | { |
1777feb0 | 565 | /* Simulate synchronous execution. */ |
6426a772 | 566 | async_disable_stdin (); |
43ff13b4 JM |
567 | } |
568 | ||
1777feb0 | 569 | /* If there were other args, beside '&', process them. */ |
43ff13b4 | 570 | if (args) |
3f81c18a | 571 | set_inferior_args (args); |
c906108c SS |
572 | } |
573 | ||
574 | if (from_tty) | |
575 | { | |
8b93c638 JM |
576 | ui_out_field_string (uiout, NULL, "Starting program"); |
577 | ui_out_text (uiout, ": "); | |
578 | if (exec_file) | |
579 | ui_out_field_string (uiout, "execfile", exec_file); | |
580 | ui_out_spaces (uiout, 1); | |
552c04a7 TT |
581 | /* We call get_inferior_args() because we might need to compute |
582 | the value now. */ | |
583 | ui_out_field_string (uiout, "infargs", get_inferior_args ()); | |
8b93c638 JM |
584 | ui_out_text (uiout, "\n"); |
585 | ui_out_flush (uiout); | |
c906108c SS |
586 | } |
587 | ||
552c04a7 TT |
588 | /* We call get_inferior_args() because we might need to compute |
589 | the value now. */ | |
590 | target_create_inferior (exec_file, get_inferior_args (), | |
3e43a32a MS |
591 | environ_vector (current_inferior ()->environment), |
592 | from_tty); | |
281b533b | 593 | |
29f49a6a PA |
594 | /* We're starting off a new process. When we get out of here, in |
595 | non-stop mode, finish the state of all threads of that process, | |
596 | but leave other threads alone, as they may be stopped in internal | |
597 | events --- the frontend shouldn't see them as stopped. In | |
598 | all-stop, always finish the state of all threads, as we may be | |
599 | resuming more than just the new process. */ | |
600 | if (non_stop) | |
601 | ptid = pid_to_ptid (ptid_get_pid (inferior_ptid)); | |
602 | else | |
603 | ptid = minus_one_ptid; | |
604 | old_chain = make_cleanup (finish_thread_state_cleanup, &ptid); | |
605 | ||
de1b3c3d PA |
606 | /* Pass zero for FROM_TTY, because at this point the "run" command |
607 | has done its thing; now we are setting up the running program. */ | |
608 | post_create_inferior (¤t_target, 0); | |
281b533b | 609 | |
74d1f91e JK |
610 | /* Start the target running. Do not use -1 continuation as it would skip |
611 | breakpoint right at the entry point. */ | |
612 | proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0); | |
c906108c | 613 | |
29f49a6a PA |
614 | /* Since there was no error, there's no need to finish the thread |
615 | states here. */ | |
616 | discard_cleanups (old_chain); | |
617 | } | |
c906108c | 618 | |
f67a969f JB |
619 | static void |
620 | run_command (char *args, int from_tty) | |
621 | { | |
622 | run_command_1 (args, from_tty, 0); | |
623 | } | |
624 | ||
c906108c | 625 | static void |
fba45db2 | 626 | run_no_args_command (char *args, int from_tty) |
c906108c | 627 | { |
3f81c18a | 628 | set_inferior_args (""); |
c906108c | 629 | } |
c906108c | 630 | \f |
c5aa993b | 631 | |
a4d5f2e0 JB |
632 | /* Start the execution of the program up until the beginning of the main |
633 | program. */ | |
634 | ||
635 | static void | |
636 | start_command (char *args, int from_tty) | |
637 | { | |
638 | /* Some languages such as Ada need to search inside the program | |
639 | minimal symbols for the location where to put the temporary | |
640 | breakpoint before starting. */ | |
641 | if (!have_minimal_symbols ()) | |
8a3fe4f8 | 642 | error (_("No symbol table loaded. Use the \"file\" command.")); |
a4d5f2e0 | 643 | |
f67a969f JB |
644 | /* Run the program until reaching the main procedure... */ |
645 | run_command_1 (args, from_tty, 1); | |
a4d5f2e0 JB |
646 | } |
647 | ||
8cae4b3f PA |
648 | static int |
649 | proceed_thread_callback (struct thread_info *thread, void *arg) | |
650 | { | |
74531fed PA |
651 | /* We go through all threads individually instead of compressing |
652 | into a single target `resume_all' request, because some threads | |
653 | may be stopped in internal breakpoints/events, or stopped waiting | |
654 | for its turn in the displaced stepping queue (that is, they are | |
655 | running && !executing). The target side has no idea about why | |
656 | the thread is stopped, so a `resume_all' command would resume too | |
657 | much. If/when GDB gains a way to tell the target `hold this | |
658 | thread stopped until I say otherwise', then we can optimize | |
659 | this. */ | |
4f8d22e3 | 660 | if (!is_stopped (thread->ptid)) |
8cae4b3f PA |
661 | return 0; |
662 | ||
dcf4fbde | 663 | switch_to_thread (thread->ptid); |
8cae4b3f PA |
664 | clear_proceed_status (); |
665 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); | |
666 | return 0; | |
667 | } | |
668 | ||
d729566a PA |
669 | void |
670 | ensure_valid_thread (void) | |
671 | { | |
672 | if (ptid_equal (inferior_ptid, null_ptid) | |
673 | || is_exited (inferior_ptid)) | |
3e43a32a | 674 | error (_("Cannot execute this command without a live selected thread.")); |
d729566a PA |
675 | } |
676 | ||
573cda03 | 677 | /* If the user is looking at trace frames, any resumption of execution |
1777feb0 | 678 | is likely to mix up recorded and live target data. So simply |
573cda03 SS |
679 | disallow those commands. */ |
680 | ||
681 | void | |
682 | ensure_not_tfind_mode (void) | |
683 | { | |
684 | if (get_traceframe_number () >= 0) | |
3e43a32a | 685 | error (_("Cannot execute this command while looking at trace frames.")); |
573cda03 SS |
686 | } |
687 | ||
77ebaa5a VP |
688 | void |
689 | continue_1 (int all_threads) | |
690 | { | |
3d488bfc | 691 | ERROR_NO_INFERIOR; |
573cda03 | 692 | ensure_not_tfind_mode (); |
3d488bfc | 693 | |
77ebaa5a VP |
694 | if (non_stop && all_threads) |
695 | { | |
696 | /* Don't error out if the current thread is running, because | |
abbb1732 | 697 | there may be other stopped threads. */ |
77ebaa5a VP |
698 | struct cleanup *old_chain; |
699 | ||
700 | /* Backup current thread and selected frame. */ | |
701 | old_chain = make_cleanup_restore_current_thread (); | |
702 | ||
703 | iterate_over_threads (proceed_thread_callback, NULL); | |
704 | ||
705 | /* Restore selected ptid. */ | |
706 | do_cleanups (old_chain); | |
707 | } | |
708 | else | |
709 | { | |
d729566a | 710 | ensure_valid_thread (); |
77ebaa5a VP |
711 | ensure_not_running (); |
712 | clear_proceed_status (); | |
713 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); | |
714 | } | |
715 | } | |
716 | ||
8cae4b3f | 717 | /* continue [-a] [proceed-count] [&] */ |
c906108c | 718 | void |
8cae4b3f | 719 | continue_command (char *args, int from_tty) |
c906108c | 720 | { |
c5aa993b | 721 | int async_exec = 0; |
8cae4b3f | 722 | int all_threads = 0; |
c906108c SS |
723 | ERROR_NO_INFERIOR; |
724 | ||
1777feb0 | 725 | /* Find out whether we must run in the background. */ |
8cae4b3f PA |
726 | if (args != NULL) |
727 | async_exec = strip_bg_char (&args); | |
43ff13b4 JM |
728 | |
729 | /* If we must run in the background, but the target can't do it, | |
1777feb0 | 730 | error out. */ |
362646f5 | 731 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 732 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 JM |
733 | |
734 | /* If we are not asked to run in the bg, then prepare to run in the | |
1777feb0 | 735 | foreground, synchronously. */ |
362646f5 | 736 | if (!async_exec && target_can_async_p ()) |
c5aa993b | 737 | { |
1777feb0 | 738 | /* Simulate synchronous execution. */ |
6426a772 | 739 | async_disable_stdin (); |
43ff13b4 | 740 | } |
c906108c | 741 | |
8cae4b3f PA |
742 | if (args != NULL) |
743 | { | |
744 | if (strncmp (args, "-a", sizeof ("-a") - 1) == 0) | |
745 | { | |
746 | all_threads = 1; | |
747 | args += sizeof ("-a") - 1; | |
748 | if (*args == '\0') | |
749 | args = NULL; | |
750 | } | |
751 | } | |
752 | ||
753 | if (!non_stop && all_threads) | |
754 | error (_("`-a' is meaningless in all-stop mode.")); | |
755 | ||
756 | if (args != NULL && all_threads) | |
3e43a32a MS |
757 | error (_("Can't resume all threads and specify " |
758 | "proceed count simultaneously.")); | |
8cae4b3f PA |
759 | |
760 | /* If we have an argument left, set proceed count of breakpoint we | |
761 | stopped at. */ | |
762 | if (args != NULL) | |
c906108c | 763 | { |
347bddb7 | 764 | bpstat bs = NULL; |
8671a17b PA |
765 | int num, stat; |
766 | int stopped = 0; | |
347bddb7 PA |
767 | struct thread_info *tp; |
768 | ||
769 | if (non_stop) | |
e09875d4 | 770 | tp = find_thread_ptid (inferior_ptid); |
347bddb7 PA |
771 | else |
772 | { | |
773 | ptid_t last_ptid; | |
774 | struct target_waitstatus ws; | |
775 | ||
776 | get_last_target_status (&last_ptid, &ws); | |
e09875d4 | 777 | tp = find_thread_ptid (last_ptid); |
347bddb7 PA |
778 | } |
779 | if (tp != NULL) | |
16c381f0 | 780 | bs = tp->control.stop_bpstat; |
8671a17b PA |
781 | |
782 | while ((stat = bpstat_num (&bs, &num)) != 0) | |
783 | if (stat > 0) | |
784 | { | |
785 | set_ignore_count (num, | |
8cae4b3f | 786 | parse_and_eval_long (args) - 1, |
8671a17b PA |
787 | from_tty); |
788 | /* set_ignore_count prints a message ending with a period. | |
789 | So print two spaces before "Continuing.". */ | |
790 | if (from_tty) | |
791 | printf_filtered (" "); | |
792 | stopped = 1; | |
793 | } | |
794 | ||
795 | if (!stopped && from_tty) | |
c906108c SS |
796 | { |
797 | printf_filtered | |
798 | ("Not stopped at any breakpoint; argument ignored.\n"); | |
799 | } | |
c906108c SS |
800 | } |
801 | ||
802 | if (from_tty) | |
a3f17187 | 803 | printf_filtered (_("Continuing.\n")); |
c906108c | 804 | |
77ebaa5a | 805 | continue_1 (all_threads); |
c906108c SS |
806 | } |
807 | \f | |
edb3359d DJ |
808 | /* Record the starting point of a "step" or "next" command. */ |
809 | ||
810 | static void | |
811 | set_step_frame (void) | |
812 | { | |
813 | struct symtab_and_line sal; | |
814 | ||
815 | find_frame_sal (get_current_frame (), &sal); | |
816 | set_step_info (get_current_frame (), sal); | |
817 | } | |
818 | ||
c906108c SS |
819 | /* Step until outside of current statement. */ |
820 | ||
c906108c | 821 | static void |
fba45db2 | 822 | step_command (char *count_string, int from_tty) |
c906108c SS |
823 | { |
824 | step_1 (0, 0, count_string); | |
825 | } | |
826 | ||
827 | /* Likewise, but skip over subroutine calls as if single instructions. */ | |
828 | ||
c906108c | 829 | static void |
fba45db2 | 830 | next_command (char *count_string, int from_tty) |
c906108c SS |
831 | { |
832 | step_1 (1, 0, count_string); | |
833 | } | |
834 | ||
835 | /* Likewise, but step only one instruction. */ | |
836 | ||
c906108c | 837 | void |
fba45db2 | 838 | stepi_command (char *count_string, int from_tty) |
c906108c SS |
839 | { |
840 | step_1 (0, 1, count_string); | |
841 | } | |
842 | ||
c906108c | 843 | void |
fba45db2 | 844 | nexti_command (char *count_string, int from_tty) |
c906108c SS |
845 | { |
846 | step_1 (1, 1, count_string); | |
847 | } | |
848 | ||
186c406b | 849 | void |
611c83ae | 850 | delete_longjmp_breakpoint_cleanup (void *arg) |
74b7792f | 851 | { |
611c83ae PA |
852 | int thread = * (int *) arg; |
853 | delete_longjmp_breakpoint (thread); | |
74b7792f AC |
854 | } |
855 | ||
c906108c | 856 | static void |
fba45db2 | 857 | step_1 (int skip_subroutines, int single_inst, char *count_string) |
c906108c | 858 | { |
52f0bd74 | 859 | int count = 1; |
f107f563 | 860 | struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); |
43ff13b4 | 861 | int async_exec = 0; |
b3dc826b | 862 | int thread = -1; |
c5aa993b | 863 | |
c906108c | 864 | ERROR_NO_INFERIOR; |
573cda03 | 865 | ensure_not_tfind_mode (); |
d729566a | 866 | ensure_valid_thread (); |
94cc34af | 867 | ensure_not_running (); |
43ff13b4 JM |
868 | |
869 | if (count_string) | |
870 | async_exec = strip_bg_char (&count_string); | |
c5aa993b | 871 | |
43ff13b4 | 872 | /* If we get a request for running in the bg but the target |
1777feb0 | 873 | doesn't support it, error out. */ |
362646f5 | 874 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 875 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 JM |
876 | |
877 | /* If we don't get a request of running in the bg, then we need | |
1777feb0 | 878 | to simulate synchronous (fg) execution. */ |
362646f5 | 879 | if (!async_exec && target_can_async_p ()) |
43ff13b4 | 880 | { |
1777feb0 | 881 | /* Simulate synchronous execution. */ |
6426a772 | 882 | async_disable_stdin (); |
43ff13b4 JM |
883 | } |
884 | ||
bb518678 | 885 | count = count_string ? parse_and_eval_long (count_string) : 1; |
c906108c | 886 | |
1777feb0 | 887 | if (!single_inst || skip_subroutines) /* Leave si command alone. */ |
c906108c | 888 | { |
186c406b TT |
889 | struct thread_info *tp = inferior_thread (); |
890 | ||
611c83ae | 891 | if (in_thread_list (inferior_ptid)) |
b3dc826b | 892 | thread = pid_to_thread_id (inferior_ptid); |
611c83ae | 893 | |
186c406b | 894 | set_longjmp_breakpoint (tp, get_frame_id (get_current_frame ())); |
611c83ae | 895 | |
b3dc826b | 896 | make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); |
c2d11a7d JM |
897 | } |
898 | ||
37d94800 | 899 | /* In synchronous case, all is well; each step_once call will step once. */ |
362646f5 | 900 | if (!target_can_async_p ()) |
c2d11a7d JM |
901 | { |
902 | for (; count > 0; count--) | |
903 | { | |
37d94800 | 904 | step_once (skip_subroutines, single_inst, count, thread); |
c2d11a7d | 905 | |
751b8ce1 PA |
906 | if (!target_has_execution) |
907 | break; | |
c2d11a7d JM |
908 | else |
909 | { | |
751b8ce1 PA |
910 | struct thread_info *tp = inferior_thread (); |
911 | ||
912 | if (!tp->control.stop_step || !tp->step_multi) | |
913 | { | |
914 | /* If we stopped for some reason that is not stepping | |
915 | there are no further steps to make. */ | |
916 | tp->step_multi = 0; | |
917 | break; | |
918 | } | |
c2d11a7d | 919 | } |
c2d11a7d JM |
920 | } |
921 | ||
f107f563 | 922 | do_cleanups (cleanups); |
c2d11a7d | 923 | } |
c2d11a7d JM |
924 | else |
925 | { | |
37d94800 PA |
926 | /* In the case of an asynchronous target things get complicated; |
927 | do only one step for now, before returning control to the | |
928 | event loop. Let the continuation figure out how many other | |
929 | steps we need to do, and handle them one at the time, through | |
930 | step_once. */ | |
b3dc826b | 931 | step_once (skip_subroutines, single_inst, count, thread); |
37d94800 | 932 | |
611c83ae | 933 | /* We are running, and the continuation is installed. It will |
f107f563 VP |
934 | disable the longjmp breakpoint as appropriate. */ |
935 | discard_cleanups (cleanups); | |
c906108c | 936 | } |
c2d11a7d | 937 | } |
c906108c | 938 | |
bfec99b2 PA |
939 | struct step_1_continuation_args |
940 | { | |
941 | int count; | |
942 | int skip_subroutines; | |
943 | int single_inst; | |
944 | int thread; | |
945 | }; | |
946 | ||
c2d11a7d JM |
947 | /* Called after we are done with one step operation, to check whether |
948 | we need to step again, before we print the prompt and return control | |
1777feb0 MS |
949 | to the user. If count is > 1, we will need to do one more call to |
950 | proceed(), via step_once(). Basically it is like step_once and | |
951 | step_1_continuation are co-recursive. */ | |
c2d11a7d | 952 | static void |
fa4cd53f | 953 | step_1_continuation (void *args, int err) |
c2d11a7d | 954 | { |
bfec99b2 | 955 | struct step_1_continuation_args *a = args; |
f13468d9 | 956 | |
af679fd0 | 957 | if (target_has_execution) |
f13468d9 | 958 | { |
af679fd0 PA |
959 | struct thread_info *tp; |
960 | ||
961 | tp = inferior_thread (); | |
fa4cd53f PA |
962 | if (!err |
963 | && tp->step_multi && tp->control.stop_step) | |
af679fd0 PA |
964 | { |
965 | /* There are more steps to make, and we did stop due to | |
966 | ending a stepping range. Do another step. */ | |
37d94800 PA |
967 | step_once (a->skip_subroutines, a->single_inst, |
968 | a->count - 1, a->thread); | |
af679fd0 PA |
969 | return; |
970 | } | |
971 | tp->step_multi = 0; | |
f107f563 | 972 | } |
af679fd0 | 973 | |
fa4cd53f PA |
974 | /* We either hit an error, or stopped for some reason that is |
975 | not stepping, or there are no further steps to make. | |
976 | Cleanup. */ | |
af679fd0 PA |
977 | if (!a->single_inst || a->skip_subroutines) |
978 | delete_longjmp_breakpoint (a->thread); | |
c2d11a7d JM |
979 | } |
980 | ||
37d94800 PA |
981 | /* Do just one step operation. This is useful to implement the 'step |
982 | n' kind of commands. In case of asynchronous targets, we will have | |
983 | to set up a continuation to be done after the target stops (after | |
984 | this one step). For synch targets, the caller handles further | |
985 | stepping. */ | |
986 | ||
987 | static void | |
611c83ae | 988 | step_once (int skip_subroutines, int single_inst, int count, int thread) |
bfec99b2 | 989 | { |
edb3359d | 990 | struct frame_info *frame = get_current_frame (); |
c2d11a7d JM |
991 | |
992 | if (count > 0) | |
c906108c | 993 | { |
4e1c45ea PA |
994 | /* Don't assume THREAD is a valid thread id. It is set to -1 if |
995 | the longjmp breakpoint was not required. Use the | |
996 | INFERIOR_PTID thread instead, which is the same thread when | |
997 | THREAD is set. */ | |
998 | struct thread_info *tp = inferior_thread (); | |
abbb1732 | 999 | |
c906108c | 1000 | clear_proceed_status (); |
edb3359d | 1001 | set_step_frame (); |
c906108c | 1002 | |
c5aa993b | 1003 | if (!single_inst) |
c906108c | 1004 | { |
1641cfcc PA |
1005 | CORE_ADDR pc; |
1006 | ||
edb3359d DJ |
1007 | /* Step at an inlined function behaves like "down". */ |
1008 | if (!skip_subroutines && !single_inst | |
1009 | && inline_skipped_frames (inferior_ptid)) | |
1010 | { | |
09cee04b PA |
1011 | ptid_t resume_ptid; |
1012 | ||
1013 | /* Pretend that we've ran. */ | |
1014 | resume_ptid = user_visible_resume_ptid (1); | |
1015 | set_running (resume_ptid, 1); | |
1016 | ||
edb3359d DJ |
1017 | step_into_inline_frame (inferior_ptid); |
1018 | if (count > 1) | |
1019 | step_once (skip_subroutines, single_inst, count - 1, thread); | |
1020 | else | |
09cee04b PA |
1021 | { |
1022 | /* Pretend that we've stopped. */ | |
1023 | normal_stop (); | |
1024 | ||
1025 | if (target_can_async_p ()) | |
1026 | inferior_event_handler (INF_EXEC_COMPLETE, NULL); | |
1027 | } | |
edb3359d DJ |
1028 | return; |
1029 | } | |
1030 | ||
1641cfcc PA |
1031 | pc = get_frame_pc (frame); |
1032 | find_pc_line_pc_range (pc, | |
16c381f0 JK |
1033 | &tp->control.step_range_start, |
1034 | &tp->control.step_range_end); | |
5fbbeb29 CF |
1035 | |
1036 | /* If we have no line info, switch to stepi mode. */ | |
16c381f0 JK |
1037 | if (tp->control.step_range_end == 0 && step_stop_if_no_debug) |
1038 | tp->control.step_range_start = tp->control.step_range_end = 1; | |
1039 | else if (tp->control.step_range_end == 0) | |
c906108c SS |
1040 | { |
1041 | char *name; | |
abbb1732 | 1042 | |
1641cfcc | 1043 | if (find_pc_partial_function (pc, &name, |
16c381f0 JK |
1044 | &tp->control.step_range_start, |
1045 | &tp->control.step_range_end) == 0) | |
8a3fe4f8 | 1046 | error (_("Cannot find bounds of current function")); |
c906108c SS |
1047 | |
1048 | target_terminal_ours (); | |
3e43a32a MS |
1049 | printf_filtered (_("Single stepping until exit from function %s," |
1050 | "\nwhich has no line number information.\n"), | |
1051 | name); | |
c906108c SS |
1052 | } |
1053 | } | |
1054 | else | |
1055 | { | |
1056 | /* Say we are stepping, but stop after one insn whatever it does. */ | |
16c381f0 | 1057 | tp->control.step_range_start = tp->control.step_range_end = 1; |
c906108c SS |
1058 | if (!skip_subroutines) |
1059 | /* It is stepi. | |
1060 | Don't step over function calls, not even to functions lacking | |
1061 | line numbers. */ | |
16c381f0 | 1062 | tp->control.step_over_calls = STEP_OVER_NONE; |
c906108c SS |
1063 | } |
1064 | ||
1065 | if (skip_subroutines) | |
16c381f0 | 1066 | tp->control.step_over_calls = STEP_OVER_ALL; |
c906108c | 1067 | |
95e54da7 | 1068 | tp->step_multi = (count > 1); |
f107f563 | 1069 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
bfec99b2 | 1070 | |
37d94800 PA |
1071 | /* For async targets, register a continuation to do any |
1072 | additional steps. For sync targets, the caller will handle | |
1073 | further stepping. */ | |
1074 | if (target_can_async_p ()) | |
1075 | { | |
1076 | struct step_1_continuation_args *args; | |
1077 | ||
1078 | args = xmalloc (sizeof (*args)); | |
1079 | args->skip_subroutines = skip_subroutines; | |
1080 | args->single_inst = single_inst; | |
1081 | args->count = count; | |
1082 | args->thread = thread; | |
1083 | ||
1084 | add_intermediate_continuation (tp, step_1_continuation, args, xfree); | |
1085 | } | |
c906108c | 1086 | } |
c906108c | 1087 | } |
c2d11a7d | 1088 | |
c906108c SS |
1089 | \f |
1090 | /* Continue program at specified address. */ | |
1091 | ||
1092 | static void | |
fba45db2 | 1093 | jump_command (char *arg, int from_tty) |
c906108c | 1094 | { |
5af949e3 | 1095 | struct gdbarch *gdbarch = get_current_arch (); |
52f0bd74 | 1096 | CORE_ADDR addr; |
c906108c SS |
1097 | struct symtabs_and_lines sals; |
1098 | struct symtab_and_line sal; | |
1099 | struct symbol *fn; | |
1100 | struct symbol *sfn; | |
43ff13b4 | 1101 | int async_exec = 0; |
c5aa993b | 1102 | |
c906108c | 1103 | ERROR_NO_INFERIOR; |
573cda03 | 1104 | ensure_not_tfind_mode (); |
d729566a | 1105 | ensure_valid_thread (); |
94cc34af | 1106 | ensure_not_running (); |
c906108c | 1107 | |
1777feb0 | 1108 | /* Find out whether we must run in the background. */ |
43ff13b4 JM |
1109 | if (arg != NULL) |
1110 | async_exec = strip_bg_char (&arg); | |
1111 | ||
1112 | /* If we must run in the background, but the target can't do it, | |
1777feb0 | 1113 | error out. */ |
362646f5 | 1114 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 1115 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 | 1116 | |
c906108c | 1117 | if (!arg) |
e2e0b3e5 | 1118 | error_no_arg (_("starting address")); |
c906108c | 1119 | |
f8eba3c6 | 1120 | sals = decode_line_spec_1 (arg, DECODE_LINE_FUNFIRSTLINE); |
c906108c SS |
1121 | if (sals.nelts != 1) |
1122 | { | |
8a3fe4f8 | 1123 | error (_("Unreasonable jump request")); |
c906108c SS |
1124 | } |
1125 | ||
1126 | sal = sals.sals[0]; | |
b8c9b27d | 1127 | xfree (sals.sals); |
c906108c SS |
1128 | |
1129 | if (sal.symtab == 0 && sal.pc == 0) | |
8a3fe4f8 | 1130 | error (_("No source file has been specified.")); |
c906108c | 1131 | |
1777feb0 | 1132 | resolve_sal_pc (&sal); /* May error out. */ |
c906108c | 1133 | |
1777feb0 | 1134 | /* See if we are trying to jump to another function. */ |
c906108c SS |
1135 | fn = get_frame_function (get_current_frame ()); |
1136 | sfn = find_pc_function (sal.pc); | |
1137 | if (fn != NULL && sfn != fn) | |
1138 | { | |
9e2f0ad4 | 1139 | if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line, |
de5ad195 | 1140 | SYMBOL_PRINT_NAME (fn))) |
c906108c | 1141 | { |
8a3fe4f8 | 1142 | error (_("Not confirmed.")); |
c906108c SS |
1143 | /* NOTREACHED */ |
1144 | } | |
1145 | } | |
1146 | ||
c5aa993b | 1147 | if (sfn != NULL) |
c906108c SS |
1148 | { |
1149 | fixup_symbol_section (sfn, 0); | |
714835d5 UW |
1150 | if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn)) && |
1151 | !section_is_mapped (SYMBOL_OBJ_SECTION (sfn))) | |
c906108c | 1152 | { |
3e43a32a MS |
1153 | if (!query (_("WARNING!!! Destination is in " |
1154 | "unmapped overlay! Jump anyway? "))) | |
c906108c | 1155 | { |
8a3fe4f8 | 1156 | error (_("Not confirmed.")); |
c906108c SS |
1157 | /* NOTREACHED */ |
1158 | } | |
1159 | } | |
1160 | } | |
1161 | ||
c906108c SS |
1162 | addr = sal.pc; |
1163 | ||
1164 | if (from_tty) | |
1165 | { | |
a3f17187 | 1166 | printf_filtered (_("Continuing at ")); |
5af949e3 | 1167 | fputs_filtered (paddress (gdbarch, addr), gdb_stdout); |
c906108c SS |
1168 | printf_filtered (".\n"); |
1169 | } | |
1170 | ||
89113898 | 1171 | /* If we are not asked to run in the bg, then prepare to run in the |
1777feb0 | 1172 | foreground, synchronously. */ |
89113898 PA |
1173 | if (!async_exec && target_can_async_p ()) |
1174 | { | |
1777feb0 | 1175 | /* Simulate synchronous execution. */ |
89113898 PA |
1176 | async_disable_stdin (); |
1177 | } | |
1178 | ||
c906108c SS |
1179 | clear_proceed_status (); |
1180 | proceed (addr, TARGET_SIGNAL_0, 0); | |
1181 | } | |
c906108c | 1182 | \f |
c5aa993b | 1183 | |
1777feb0 | 1184 | /* Go to line or address in current procedure. */ |
c906108c | 1185 | static void |
fba45db2 | 1186 | go_command (char *line_no, int from_tty) |
c906108c | 1187 | { |
c5aa993b | 1188 | if (line_no == (char *) NULL || !*line_no) |
f42429a6 | 1189 | printf_filtered (_("Usage: go <location>\n")); |
c906108c SS |
1190 | else |
1191 | { | |
b83266a0 SS |
1192 | tbreak_command (line_no, from_tty); |
1193 | jump_command (line_no, from_tty); | |
c906108c SS |
1194 | } |
1195 | } | |
c906108c | 1196 | \f |
c5aa993b | 1197 | |
c906108c SS |
1198 | /* Continue program giving it specified signal. */ |
1199 | ||
1200 | static void | |
fba45db2 | 1201 | signal_command (char *signum_exp, int from_tty) |
c906108c SS |
1202 | { |
1203 | enum target_signal oursig; | |
32c1e744 | 1204 | int async_exec = 0; |
c906108c SS |
1205 | |
1206 | dont_repeat (); /* Too dangerous. */ | |
1207 | ERROR_NO_INFERIOR; | |
573cda03 | 1208 | ensure_not_tfind_mode (); |
d729566a | 1209 | ensure_valid_thread (); |
94cc34af | 1210 | ensure_not_running (); |
c906108c | 1211 | |
32c1e744 VP |
1212 | /* Find out whether we must run in the background. */ |
1213 | if (signum_exp != NULL) | |
1214 | async_exec = strip_bg_char (&signum_exp); | |
1215 | ||
1216 | /* If we must run in the background, but the target can't do it, | |
1217 | error out. */ | |
1218 | if (async_exec && !target_can_async_p ()) | |
1219 | error (_("Asynchronous execution not supported on this target.")); | |
1220 | ||
1221 | /* If we are not asked to run in the bg, then prepare to run in the | |
1222 | foreground, synchronously. */ | |
1223 | if (!async_exec && target_can_async_p ()) | |
1224 | { | |
1225 | /* Simulate synchronous execution. */ | |
1226 | async_disable_stdin (); | |
1227 | } | |
1228 | ||
c906108c | 1229 | if (!signum_exp) |
e2e0b3e5 | 1230 | error_no_arg (_("signal number")); |
c906108c SS |
1231 | |
1232 | /* It would be even slicker to make signal names be valid expressions, | |
1233 | (the type could be "enum $signal" or some such), then the user could | |
1234 | assign them to convenience variables. */ | |
1235 | oursig = target_signal_from_name (signum_exp); | |
1236 | ||
1237 | if (oursig == TARGET_SIGNAL_UNKNOWN) | |
1238 | { | |
1239 | /* No, try numeric. */ | |
bb518678 | 1240 | int num = parse_and_eval_long (signum_exp); |
c906108c SS |
1241 | |
1242 | if (num == 0) | |
1243 | oursig = TARGET_SIGNAL_0; | |
1244 | else | |
1245 | oursig = target_signal_from_command (num); | |
1246 | } | |
1247 | ||
1248 | if (from_tty) | |
1249 | { | |
1250 | if (oursig == TARGET_SIGNAL_0) | |
a3f17187 | 1251 | printf_filtered (_("Continuing with no signal.\n")); |
c906108c | 1252 | else |
a3f17187 | 1253 | printf_filtered (_("Continuing with signal %s.\n"), |
c906108c SS |
1254 | target_signal_to_name (oursig)); |
1255 | } | |
1256 | ||
1257 | clear_proceed_status (); | |
a12cc160 | 1258 | proceed ((CORE_ADDR) -1, oursig, 0); |
c906108c SS |
1259 | } |
1260 | ||
fa4cd53f PA |
1261 | /* Continuation args to be passed to the "until" command |
1262 | continuation. */ | |
1263 | struct until_next_continuation_args | |
1264 | { | |
1265 | /* The thread that was current when the command was executed. */ | |
1266 | int thread; | |
1267 | }; | |
1268 | ||
186c406b TT |
1269 | /* A continuation callback for until_next_command. */ |
1270 | ||
1271 | static void | |
fa4cd53f | 1272 | until_next_continuation (void *arg, int err) |
186c406b | 1273 | { |
fa4cd53f | 1274 | struct until_next_continuation_args *a = arg; |
186c406b | 1275 | |
fa4cd53f | 1276 | delete_longjmp_breakpoint (a->thread); |
186c406b TT |
1277 | } |
1278 | ||
c906108c SS |
1279 | /* Proceed until we reach a different source line with pc greater than |
1280 | our current one or exit the function. We skip calls in both cases. | |
1281 | ||
1282 | Note that eventually this command should probably be changed so | |
1283 | that only source lines are printed out when we hit the breakpoint | |
1284 | we set. This may involve changes to wait_for_inferior and the | |
1285 | proceed status code. */ | |
1286 | ||
c906108c | 1287 | static void |
fba45db2 | 1288 | until_next_command (int from_tty) |
c906108c SS |
1289 | { |
1290 | struct frame_info *frame; | |
1291 | CORE_ADDR pc; | |
1292 | struct symbol *func; | |
1293 | struct symtab_and_line sal; | |
4e1c45ea | 1294 | struct thread_info *tp = inferior_thread (); |
186c406b TT |
1295 | int thread = tp->num; |
1296 | struct cleanup *old_chain; | |
c5aa993b | 1297 | |
c906108c | 1298 | clear_proceed_status (); |
edb3359d | 1299 | set_step_frame (); |
c906108c SS |
1300 | |
1301 | frame = get_current_frame (); | |
1302 | ||
1303 | /* Step until either exited from this function or greater | |
1304 | than the current line (if in symbolic section) or pc (if | |
1777feb0 | 1305 | not). */ |
c906108c | 1306 | |
1c7819ef | 1307 | pc = get_frame_pc (frame); |
c906108c | 1308 | func = find_pc_function (pc); |
c5aa993b | 1309 | |
c906108c SS |
1310 | if (!func) |
1311 | { | |
1312 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); | |
c5aa993b | 1313 | |
c906108c | 1314 | if (msymbol == NULL) |
8a3fe4f8 | 1315 | error (_("Execution is not within a known function.")); |
c5aa993b | 1316 | |
16c381f0 JK |
1317 | tp->control.step_range_start = SYMBOL_VALUE_ADDRESS (msymbol); |
1318 | tp->control.step_range_end = pc; | |
c906108c SS |
1319 | } |
1320 | else | |
1321 | { | |
1322 | sal = find_pc_line (pc, 0); | |
c5aa993b | 1323 | |
16c381f0 JK |
1324 | tp->control.step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); |
1325 | tp->control.step_range_end = sal.end; | |
c906108c | 1326 | } |
c5aa993b | 1327 | |
16c381f0 | 1328 | tp->control.step_over_calls = STEP_OVER_ALL; |
c906108c | 1329 | |
af679fd0 | 1330 | tp->step_multi = 0; /* Only one call to proceed */ |
c5aa993b | 1331 | |
186c406b TT |
1332 | set_longjmp_breakpoint (tp, get_frame_id (frame)); |
1333 | old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); | |
1334 | ||
2acceee2 | 1335 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
186c406b TT |
1336 | |
1337 | if (target_can_async_p () && is_running (inferior_ptid)) | |
1338 | { | |
fa4cd53f PA |
1339 | struct until_next_continuation_args *cont_args; |
1340 | ||
186c406b | 1341 | discard_cleanups (old_chain); |
fa4cd53f PA |
1342 | cont_args = XNEW (struct until_next_continuation_args); |
1343 | cont_args->thread = inferior_thread ()->num; | |
1344 | ||
1345 | add_continuation (tp, until_next_continuation, cont_args, xfree); | |
186c406b TT |
1346 | } |
1347 | else | |
1348 | do_cleanups (old_chain); | |
c906108c SS |
1349 | } |
1350 | ||
c5aa993b | 1351 | static void |
fba45db2 | 1352 | until_command (char *arg, int from_tty) |
c906108c | 1353 | { |
43ff13b4 JM |
1354 | int async_exec = 0; |
1355 | ||
4247603b | 1356 | ERROR_NO_INFERIOR; |
573cda03 | 1357 | ensure_not_tfind_mode (); |
4247603b PA |
1358 | ensure_valid_thread (); |
1359 | ensure_not_running (); | |
573cda03 | 1360 | |
1777feb0 | 1361 | /* Find out whether we must run in the background. */ |
43ff13b4 JM |
1362 | if (arg != NULL) |
1363 | async_exec = strip_bg_char (&arg); | |
1364 | ||
1365 | /* If we must run in the background, but the target can't do it, | |
1777feb0 | 1366 | error out. */ |
362646f5 | 1367 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 1368 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 JM |
1369 | |
1370 | /* If we are not asked to run in the bg, then prepare to run in the | |
1777feb0 | 1371 | foreground, synchronously. */ |
362646f5 | 1372 | if (!async_exec && target_can_async_p ()) |
c5aa993b | 1373 | { |
1777feb0 | 1374 | /* Simulate synchronous execution. */ |
6426a772 | 1375 | async_disable_stdin (); |
43ff13b4 JM |
1376 | } |
1377 | ||
c906108c | 1378 | if (arg) |
ae66c1fc | 1379 | until_break_command (arg, from_tty, 0); |
c906108c SS |
1380 | else |
1381 | until_next_command (from_tty); | |
1382 | } | |
ae66c1fc EZ |
1383 | |
1384 | static void | |
1385 | advance_command (char *arg, int from_tty) | |
1386 | { | |
1387 | int async_exec = 0; | |
1388 | ||
4247603b | 1389 | ERROR_NO_INFERIOR; |
573cda03 | 1390 | ensure_not_tfind_mode (); |
4247603b PA |
1391 | ensure_valid_thread (); |
1392 | ensure_not_running (); | |
573cda03 | 1393 | |
ae66c1fc | 1394 | if (arg == NULL) |
e2e0b3e5 | 1395 | error_no_arg (_("a location")); |
ae66c1fc EZ |
1396 | |
1397 | /* Find out whether we must run in the background. */ | |
1398 | if (arg != NULL) | |
1399 | async_exec = strip_bg_char (&arg); | |
1400 | ||
1401 | /* If we must run in the background, but the target can't do it, | |
1402 | error out. */ | |
362646f5 | 1403 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 1404 | error (_("Asynchronous execution not supported on this target.")); |
ae66c1fc EZ |
1405 | |
1406 | /* If we are not asked to run in the bg, then prepare to run in the | |
1407 | foreground, synchronously. */ | |
362646f5 | 1408 | if (!async_exec && target_can_async_p ()) |
ae66c1fc EZ |
1409 | { |
1410 | /* Simulate synchronous execution. */ | |
1411 | async_disable_stdin (); | |
1412 | } | |
1413 | ||
1414 | until_break_command (arg, from_tty, 1); | |
1415 | } | |
c906108c | 1416 | \f |
f941662f MK |
1417 | /* Print the result of a function at the end of a 'finish' command. */ |
1418 | ||
11cf8741 | 1419 | static void |
c055b101 | 1420 | print_return_value (struct type *func_type, struct type *value_type) |
11cf8741 | 1421 | { |
d80b854b | 1422 | struct gdbarch *gdbarch = get_regcache_arch (stop_registers); |
bb472c1e MK |
1423 | struct cleanup *old_chain; |
1424 | struct ui_stream *stb; | |
44e5158b | 1425 | struct value *value; |
79a45e25 | 1426 | struct ui_out *uiout = current_uiout; |
44e5158b | 1427 | |
181fc57c | 1428 | CHECK_TYPEDEF (value_type); |
44e5158b | 1429 | gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID); |
11cf8741 | 1430 | |
92ad9cd9 AC |
1431 | /* FIXME: 2003-09-27: When returning from a nested inferior function |
1432 | call, it's possible (with no help from the architecture vector) | |
1433 | to locate and return/print a "struct return" value. This is just | |
7a9dd1b2 | 1434 | a more complicated case of what is already being done in the |
92ad9cd9 AC |
1435 | inferior function call code. In fact, when inferior function |
1436 | calls are made async, this will likely be made the norm. */ | |
31db7b6c | 1437 | |
c055b101 CV |
1438 | switch (gdbarch_return_value (gdbarch, func_type, value_type, |
1439 | NULL, NULL, NULL)) | |
44e5158b | 1440 | { |
750eb019 AC |
1441 | case RETURN_VALUE_REGISTER_CONVENTION: |
1442 | case RETURN_VALUE_ABI_RETURNS_ADDRESS: | |
181fc57c | 1443 | case RETURN_VALUE_ABI_PRESERVES_ADDRESS: |
44e5158b | 1444 | value = allocate_value (value_type); |
c055b101 | 1445 | gdbarch_return_value (gdbarch, func_type, value_type, stop_registers, |
990a07ab | 1446 | value_contents_raw (value), NULL); |
750eb019 AC |
1447 | break; |
1448 | case RETURN_VALUE_STRUCT_CONVENTION: | |
1449 | value = NULL; | |
1450 | break; | |
1451 | default: | |
e2e0b3e5 | 1452 | internal_error (__FILE__, __LINE__, _("bad switch")); |
44e5158b | 1453 | } |
bb472c1e | 1454 | |
31db7b6c MK |
1455 | if (value) |
1456 | { | |
79a45b7d TT |
1457 | struct value_print_options opts; |
1458 | ||
31db7b6c | 1459 | /* Print it. */ |
1d751abe PA |
1460 | stb = ui_out_stream_new (uiout); |
1461 | old_chain = make_cleanup_ui_out_stream_delete (stb); | |
31db7b6c MK |
1462 | ui_out_text (uiout, "Value returned is "); |
1463 | ui_out_field_fmt (uiout, "gdb-result-var", "$%d", | |
1464 | record_latest_value (value)); | |
1465 | ui_out_text (uiout, " = "); | |
79a45b7d TT |
1466 | get_raw_print_options (&opts); |
1467 | value_print (value, stb->stream, &opts); | |
31db7b6c MK |
1468 | ui_out_field_stream (uiout, "return-value", stb); |
1469 | ui_out_text (uiout, "\n"); | |
1d751abe | 1470 | do_cleanups (old_chain); |
31db7b6c MK |
1471 | } |
1472 | else | |
1473 | { | |
1474 | ui_out_text (uiout, "Value returned has type: "); | |
1d751abe PA |
1475 | ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type)); |
1476 | ui_out_text (uiout, "."); | |
1477 | ui_out_text (uiout, " Cannot determine contents\n"); | |
31db7b6c | 1478 | } |
11cf8741 JM |
1479 | } |
1480 | ||
43ff13b4 | 1481 | /* Stuff that needs to be done by the finish command after the target |
f941662f MK |
1482 | has stopped. In asynchronous mode, we wait for the target to stop |
1483 | in the call to poll or select in the event loop, so it is | |
1484 | impossible to do all the stuff as part of the finish_command | |
1485 | function itself. The only chance we have to complete this command | |
1486 | is in fetch_inferior_event, which is called by the event loop as | |
fa4cd53f | 1487 | soon as it detects that the target has stopped. */ |
f941662f | 1488 | |
bfec99b2 | 1489 | struct finish_command_continuation_args |
43ff13b4 | 1490 | { |
fa4cd53f PA |
1491 | /* The thread that as current when the command was executed. */ |
1492 | int thread; | |
43ff13b4 | 1493 | struct breakpoint *breakpoint; |
bfec99b2 PA |
1494 | struct symbol *function; |
1495 | }; | |
c5aa993b | 1496 | |
bfec99b2 | 1497 | static void |
fa4cd53f | 1498 | finish_command_continuation (void *arg, int err) |
bfec99b2 PA |
1499 | { |
1500 | struct finish_command_continuation_args *a = arg; | |
347bddb7 | 1501 | |
fa4cd53f | 1502 | if (!err) |
43ff13b4 | 1503 | { |
fa4cd53f PA |
1504 | struct thread_info *tp = NULL; |
1505 | bpstat bs = NULL; | |
bfec99b2 | 1506 | |
fa4cd53f PA |
1507 | if (!ptid_equal (inferior_ptid, null_ptid) |
1508 | && target_has_execution | |
1509 | && is_stopped (inferior_ptid)) | |
1510 | { | |
1511 | tp = inferior_thread (); | |
1512 | bs = tp->control.stop_bpstat; | |
1513 | } | |
f5871ec0 | 1514 | |
fa4cd53f PA |
1515 | if (bpstat_find_breakpoint (bs, a->breakpoint) != NULL |
1516 | && a->function != NULL) | |
40c549d6 | 1517 | { |
fa4cd53f PA |
1518 | struct type *value_type; |
1519 | ||
1520 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function)); | |
1521 | if (!value_type) | |
1522 | internal_error (__FILE__, __LINE__, | |
1523 | _("finish_command: function has no target type")); | |
40c549d6 | 1524 | |
fa4cd53f | 1525 | if (TYPE_CODE (value_type) != TYPE_CODE_VOID) |
40c549d6 | 1526 | { |
fa4cd53f PA |
1527 | volatile struct gdb_exception ex; |
1528 | ||
1529 | TRY_CATCH (ex, RETURN_MASK_ALL) | |
1530 | { | |
1531 | /* print_return_value can throw an exception in some | |
1532 | circumstances. We need to catch this so that we still | |
1533 | delete the breakpoint. */ | |
1534 | print_return_value (SYMBOL_TYPE (a->function), value_type); | |
1535 | } | |
1536 | if (ex.reason < 0) | |
1537 | exception_print (gdb_stdout, ex); | |
40c549d6 | 1538 | } |
40c549d6 | 1539 | } |
fa4cd53f PA |
1540 | |
1541 | /* We suppress normal call of normal_stop observer and do it | |
1542 | here so that the *stopped notification includes the return | |
1543 | value. */ | |
1544 | if (bs != NULL && tp->control.proceed_to_finish) | |
1545 | observer_notify_normal_stop (bs, 1 /* print frame */); | |
43ff13b4 | 1546 | } |
f941662f | 1547 | |
bfec99b2 | 1548 | delete_breakpoint (a->breakpoint); |
fa4cd53f | 1549 | delete_longjmp_breakpoint (a->thread); |
43ff13b4 JM |
1550 | } |
1551 | ||
604ead4a PA |
1552 | static void |
1553 | finish_command_continuation_free_arg (void *arg) | |
1554 | { | |
604ead4a PA |
1555 | xfree (arg); |
1556 | } | |
1557 | ||
b2175913 MS |
1558 | /* finish_backward -- helper function for finish_command. */ |
1559 | ||
1560 | static void | |
1561 | finish_backward (struct symbol *function) | |
1562 | { | |
1563 | struct symtab_and_line sal; | |
1564 | struct thread_info *tp = inferior_thread (); | |
1c7819ef | 1565 | CORE_ADDR pc; |
b2175913 | 1566 | CORE_ADDR func_addr; |
b2175913 | 1567 | |
1c7819ef PA |
1568 | pc = get_frame_pc (get_current_frame ()); |
1569 | ||
1570 | if (find_pc_partial_function (pc, NULL, &func_addr, NULL) == 0) | |
b2175913 MS |
1571 | internal_error (__FILE__, __LINE__, |
1572 | _("Finish: couldn't find function.")); | |
1573 | ||
1574 | sal = find_pc_line (func_addr, 0); | |
1575 | ||
9da8c2a0 | 1576 | tp->control.proceed_to_finish = 1; |
b2175913 MS |
1577 | /* Special case: if we're sitting at the function entry point, |
1578 | then all we need to do is take a reverse singlestep. We | |
1579 | don't need to set a breakpoint, and indeed it would do us | |
1580 | no good to do so. | |
1581 | ||
1582 | Note that this can only happen at frame #0, since there's | |
1583 | no way that a function up the stack can have a return address | |
1584 | that's equal to its entry point. */ | |
1585 | ||
1c7819ef | 1586 | if (sal.pc != pc) |
b2175913 | 1587 | { |
a6d9a66e UW |
1588 | struct frame_info *frame = get_selected_frame (NULL); |
1589 | struct gdbarch *gdbarch = get_frame_arch (frame); | |
9da8c2a0 PA |
1590 | struct symtab_and_line sr_sal; |
1591 | ||
1592 | /* Set a step-resume at the function's entry point. Once that's | |
1593 | hit, we'll do one more step backwards. */ | |
1594 | init_sal (&sr_sal); | |
1595 | sr_sal.pc = sal.pc; | |
1596 | sr_sal.pspace = get_frame_program_space (frame); | |
1597 | insert_step_resume_breakpoint_at_sal (gdbarch, | |
1598 | sr_sal, null_frame_id); | |
a6d9a66e | 1599 | |
b2175913 | 1600 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
b2175913 MS |
1601 | } |
1602 | else | |
b2175913 | 1603 | { |
9da8c2a0 PA |
1604 | /* We're almost there -- we just need to back up by one more |
1605 | single-step. */ | |
16c381f0 | 1606 | tp->control.step_range_start = tp->control.step_range_end = 1; |
b2175913 MS |
1607 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
1608 | } | |
b2175913 MS |
1609 | } |
1610 | ||
1611 | /* finish_forward -- helper function for finish_command. */ | |
1612 | ||
1613 | static void | |
1614 | finish_forward (struct symbol *function, struct frame_info *frame) | |
1615 | { | |
a6d9a66e | 1616 | struct gdbarch *gdbarch = get_frame_arch (frame); |
b2175913 MS |
1617 | struct symtab_and_line sal; |
1618 | struct thread_info *tp = inferior_thread (); | |
1619 | struct breakpoint *breakpoint; | |
1620 | struct cleanup *old_chain; | |
1621 | struct finish_command_continuation_args *cargs; | |
186c406b | 1622 | int thread = tp->num; |
b2175913 MS |
1623 | |
1624 | sal = find_pc_line (get_frame_pc (frame), 0); | |
1625 | sal.pc = get_frame_pc (frame); | |
1626 | ||
a6d9a66e UW |
1627 | breakpoint = set_momentary_breakpoint (gdbarch, sal, |
1628 | get_stack_frame_id (frame), | |
b2175913 MS |
1629 | bp_finish); |
1630 | ||
1631 | old_chain = make_cleanup_delete_breakpoint (breakpoint); | |
1632 | ||
186c406b TT |
1633 | set_longjmp_breakpoint (tp, get_frame_id (frame)); |
1634 | make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); | |
1635 | ||
16c381f0 JK |
1636 | /* We want stop_registers, please... */ |
1637 | tp->control.proceed_to_finish = 1; | |
b2175913 MS |
1638 | cargs = xmalloc (sizeof (*cargs)); |
1639 | ||
fa4cd53f | 1640 | cargs->thread = thread; |
b2175913 MS |
1641 | cargs->breakpoint = breakpoint; |
1642 | cargs->function = function; | |
1643 | add_continuation (tp, finish_command_continuation, cargs, | |
1644 | finish_command_continuation_free_arg); | |
6c95b8df | 1645 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
b2175913 MS |
1646 | |
1647 | discard_cleanups (old_chain); | |
1648 | if (!target_can_async_p ()) | |
fa4cd53f | 1649 | do_all_continuations (0); |
b2175913 MS |
1650 | } |
1651 | ||
f941662f MK |
1652 | /* "finish": Set a temporary breakpoint at the place the selected |
1653 | frame will return to, then continue. */ | |
c906108c SS |
1654 | |
1655 | static void | |
fba45db2 | 1656 | finish_command (char *arg, int from_tty) |
c906108c | 1657 | { |
52f0bd74 AC |
1658 | struct frame_info *frame; |
1659 | struct symbol *function; | |
43ff13b4 JM |
1660 | |
1661 | int async_exec = 0; | |
1662 | ||
4247603b | 1663 | ERROR_NO_INFERIOR; |
573cda03 | 1664 | ensure_not_tfind_mode (); |
4247603b PA |
1665 | ensure_valid_thread (); |
1666 | ensure_not_running (); | |
573cda03 | 1667 | |
f941662f | 1668 | /* Find out whether we must run in the background. */ |
43ff13b4 JM |
1669 | if (arg != NULL) |
1670 | async_exec = strip_bg_char (&arg); | |
1671 | ||
1672 | /* If we must run in the background, but the target can't do it, | |
f941662f | 1673 | error out. */ |
362646f5 | 1674 | if (async_exec && !target_can_async_p ()) |
8a3fe4f8 | 1675 | error (_("Asynchronous execution not supported on this target.")); |
43ff13b4 JM |
1676 | |
1677 | /* If we are not asked to run in the bg, then prepare to run in the | |
f941662f | 1678 | foreground, synchronously. */ |
362646f5 | 1679 | if (!async_exec && target_can_async_p ()) |
c5aa993b | 1680 | { |
f941662f | 1681 | /* Simulate synchronous execution. */ |
6426a772 | 1682 | async_disable_stdin (); |
43ff13b4 | 1683 | } |
c906108c SS |
1684 | |
1685 | if (arg) | |
8a3fe4f8 | 1686 | error (_("The \"finish\" command does not take any arguments.")); |
c906108c | 1687 | |
206415a3 | 1688 | frame = get_prev_frame (get_selected_frame (_("No selected frame."))); |
c906108c | 1689 | if (frame == 0) |
8a3fe4f8 | 1690 | error (_("\"finish\" not meaningful in the outermost frame.")); |
c906108c SS |
1691 | |
1692 | clear_proceed_status (); | |
1693 | ||
edb3359d DJ |
1694 | /* Finishing from an inline frame is completely different. We don't |
1695 | try to show the "return value" - no way to locate it. So we do | |
1696 | not need a completion. */ | |
1697 | if (get_frame_type (get_selected_frame (_("No selected frame."))) | |
1698 | == INLINE_FRAME) | |
1699 | { | |
1700 | /* Claim we are stepping in the calling frame. An empty step | |
1701 | range means that we will stop once we aren't in a function | |
1702 | called by that frame. We don't use the magic "1" value for | |
1703 | step_range_end, because then infrun will think this is nexti, | |
1704 | and not step over the rest of this inlined function call. */ | |
1705 | struct thread_info *tp = inferior_thread (); | |
1706 | struct symtab_and_line empty_sal; | |
abbb1732 | 1707 | |
edb3359d DJ |
1708 | init_sal (&empty_sal); |
1709 | set_step_info (frame, empty_sal); | |
16c381f0 JK |
1710 | tp->control.step_range_start = get_frame_pc (frame); |
1711 | tp->control.step_range_end = tp->control.step_range_start; | |
1712 | tp->control.step_over_calls = STEP_OVER_ALL; | |
edb3359d DJ |
1713 | |
1714 | /* Print info on the selected frame, including level number but not | |
1715 | source. */ | |
1716 | if (from_tty) | |
1717 | { | |
1718 | printf_filtered (_("Run till exit from ")); | |
1719 | print_stack_frame (get_selected_frame (NULL), 1, LOCATION); | |
1720 | } | |
1721 | ||
1722 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); | |
1723 | return; | |
1724 | } | |
1725 | ||
c906108c SS |
1726 | /* Find the function we will return from. */ |
1727 | ||
206415a3 | 1728 | function = find_pc_function (get_frame_pc (get_selected_frame (NULL))); |
c906108c | 1729 | |
f941662f MK |
1730 | /* Print info on the selected frame, including level number but not |
1731 | source. */ | |
c906108c SS |
1732 | if (from_tty) |
1733 | { | |
b2175913 MS |
1734 | if (execution_direction == EXEC_REVERSE) |
1735 | printf_filtered (_("Run back to call of ")); | |
1736 | else | |
1737 | printf_filtered (_("Run till exit from ")); | |
1738 | ||
b04f3ab4 | 1739 | print_stack_frame (get_selected_frame (NULL), 1, LOCATION); |
c906108c SS |
1740 | } |
1741 | ||
b2175913 MS |
1742 | if (execution_direction == EXEC_REVERSE) |
1743 | finish_backward (function); | |
1744 | else | |
1745 | finish_forward (function, frame); | |
c906108c SS |
1746 | } |
1747 | \f | |
f941662f | 1748 | |
c906108c | 1749 | static void |
fba45db2 | 1750 | program_info (char *args, int from_tty) |
c906108c | 1751 | { |
347bddb7 PA |
1752 | bpstat bs; |
1753 | int num, stat; | |
1754 | struct thread_info *tp; | |
1755 | ptid_t ptid; | |
c5aa993b | 1756 | |
c906108c SS |
1757 | if (!target_has_execution) |
1758 | { | |
a3f17187 | 1759 | printf_filtered (_("The program being debugged is not being run.\n")); |
c906108c SS |
1760 | return; |
1761 | } | |
1762 | ||
347bddb7 PA |
1763 | if (non_stop) |
1764 | ptid = inferior_ptid; | |
1765 | else | |
1766 | { | |
1767 | struct target_waitstatus ws; | |
abbb1732 | 1768 | |
347bddb7 PA |
1769 | get_last_target_status (&ptid, &ws); |
1770 | } | |
1771 | ||
1772 | if (ptid_equal (ptid, null_ptid) || is_exited (ptid)) | |
1773 | error (_("Invalid selected thread.")); | |
1774 | else if (is_running (ptid)) | |
1775 | error (_("Selected thread is running.")); | |
1776 | ||
e09875d4 | 1777 | tp = find_thread_ptid (ptid); |
16c381f0 | 1778 | bs = tp->control.stop_bpstat; |
347bddb7 PA |
1779 | stat = bpstat_num (&bs, &num); |
1780 | ||
c906108c | 1781 | target_files_info (); |
5af949e3 UW |
1782 | printf_filtered (_("Program stopped at %s.\n"), |
1783 | paddress (target_gdbarch, stop_pc)); | |
16c381f0 | 1784 | if (tp->control.stop_step) |
a3f17187 | 1785 | printf_filtered (_("It stopped after being stepped.\n")); |
8671a17b | 1786 | else if (stat != 0) |
c906108c SS |
1787 | { |
1788 | /* There may be several breakpoints in the same place, so this | |
c5aa993b | 1789 | isn't as strange as it seems. */ |
8671a17b | 1790 | while (stat != 0) |
c906108c | 1791 | { |
8671a17b | 1792 | if (stat < 0) |
c906108c | 1793 | { |
3e43a32a MS |
1794 | printf_filtered (_("It stopped at a breakpoint " |
1795 | "that has since been deleted.\n")); | |
c906108c SS |
1796 | } |
1797 | else | |
a3f17187 | 1798 | printf_filtered (_("It stopped at breakpoint %d.\n"), num); |
8671a17b | 1799 | stat = bpstat_num (&bs, &num); |
c906108c SS |
1800 | } |
1801 | } | |
16c381f0 | 1802 | else if (tp->suspend.stop_signal != TARGET_SIGNAL_0) |
c906108c | 1803 | { |
a3f17187 | 1804 | printf_filtered (_("It stopped with signal %s, %s.\n"), |
16c381f0 JK |
1805 | target_signal_to_name (tp->suspend.stop_signal), |
1806 | target_signal_to_string (tp->suspend.stop_signal)); | |
c906108c SS |
1807 | } |
1808 | ||
1809 | if (!from_tty) | |
1810 | { | |
3e43a32a MS |
1811 | printf_filtered (_("Type \"info stack\" or \"info " |
1812 | "registers\" for more information.\n")); | |
c906108c SS |
1813 | } |
1814 | } | |
1815 | \f | |
1816 | static void | |
fba45db2 | 1817 | environment_info (char *var, int from_tty) |
c906108c SS |
1818 | { |
1819 | if (var) | |
1820 | { | |
3f81c18a | 1821 | char *val = get_in_environ (current_inferior ()->environment, var); |
abbb1732 | 1822 | |
c906108c SS |
1823 | if (val) |
1824 | { | |
1825 | puts_filtered (var); | |
1826 | puts_filtered (" = "); | |
1827 | puts_filtered (val); | |
1828 | puts_filtered ("\n"); | |
1829 | } | |
1830 | else | |
1831 | { | |
1832 | puts_filtered ("Environment variable \""); | |
1833 | puts_filtered (var); | |
1834 | puts_filtered ("\" not defined.\n"); | |
1835 | } | |
1836 | } | |
1837 | else | |
1838 | { | |
3f81c18a | 1839 | char **vector = environ_vector (current_inferior ()->environment); |
abbb1732 | 1840 | |
c906108c SS |
1841 | while (*vector) |
1842 | { | |
1843 | puts_filtered (*vector++); | |
1844 | puts_filtered ("\n"); | |
1845 | } | |
1846 | } | |
1847 | } | |
1848 | ||
1849 | static void | |
fba45db2 | 1850 | set_environment_command (char *arg, int from_tty) |
c906108c | 1851 | { |
52f0bd74 | 1852 | char *p, *val, *var; |
c906108c SS |
1853 | int nullset = 0; |
1854 | ||
1855 | if (arg == 0) | |
e2e0b3e5 | 1856 | error_no_arg (_("environment variable and value")); |
c906108c | 1857 | |
1777feb0 | 1858 | /* Find seperation between variable name and value. */ |
c906108c SS |
1859 | p = (char *) strchr (arg, '='); |
1860 | val = (char *) strchr (arg, ' '); | |
1861 | ||
1862 | if (p != 0 && val != 0) | |
1863 | { | |
1864 | /* We have both a space and an equals. If the space is before the | |
c5aa993b | 1865 | equals, walk forward over the spaces til we see a nonspace |
1777feb0 | 1866 | (possibly the equals). */ |
c906108c SS |
1867 | if (p > val) |
1868 | while (*val == ' ') | |
1869 | val++; | |
1870 | ||
1871 | /* Now if the = is after the char following the spaces, | |
c5aa993b | 1872 | take the char following the spaces. */ |
c906108c SS |
1873 | if (p > val) |
1874 | p = val - 1; | |
1875 | } | |
1876 | else if (val != 0 && p == 0) | |
1877 | p = val; | |
1878 | ||
1879 | if (p == arg) | |
e2e0b3e5 | 1880 | error_no_arg (_("environment variable to set")); |
c906108c SS |
1881 | |
1882 | if (p == 0 || p[1] == 0) | |
1883 | { | |
1884 | nullset = 1; | |
1885 | if (p == 0) | |
1777feb0 | 1886 | p = arg + strlen (arg); /* So that savestring below will work. */ |
c906108c SS |
1887 | } |
1888 | else | |
1889 | { | |
1777feb0 | 1890 | /* Not setting variable value to null. */ |
c906108c SS |
1891 | val = p + 1; |
1892 | while (*val == ' ' || *val == '\t') | |
1893 | val++; | |
1894 | } | |
1895 | ||
c5aa993b JM |
1896 | while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) |
1897 | p--; | |
c906108c SS |
1898 | |
1899 | var = savestring (arg, p - arg); | |
1900 | if (nullset) | |
1901 | { | |
3e43a32a MS |
1902 | printf_filtered (_("Setting environment variable " |
1903 | "\"%s\" to null value.\n"), | |
a3f17187 | 1904 | var); |
3f81c18a | 1905 | set_in_environ (current_inferior ()->environment, var, ""); |
c906108c SS |
1906 | } |
1907 | else | |
3f81c18a | 1908 | set_in_environ (current_inferior ()->environment, var, val); |
b8c9b27d | 1909 | xfree (var); |
c906108c SS |
1910 | } |
1911 | ||
1912 | static void | |
fba45db2 | 1913 | unset_environment_command (char *var, int from_tty) |
c906108c SS |
1914 | { |
1915 | if (var == 0) | |
1916 | { | |
1917 | /* If there is no argument, delete all environment variables. | |
c5aa993b | 1918 | Ask for confirmation if reading from the terminal. */ |
e2e0b3e5 | 1919 | if (!from_tty || query (_("Delete all environment variables? "))) |
c906108c | 1920 | { |
3f81c18a VP |
1921 | free_environ (current_inferior ()->environment); |
1922 | current_inferior ()->environment = make_environ (); | |
c906108c SS |
1923 | } |
1924 | } | |
1925 | else | |
3f81c18a | 1926 | unset_in_environ (current_inferior ()->environment, var); |
c906108c SS |
1927 | } |
1928 | ||
1777feb0 | 1929 | /* Handle the execution path (PATH variable). */ |
c906108c SS |
1930 | |
1931 | static const char path_var_name[] = "PATH"; | |
1932 | ||
c906108c | 1933 | static void |
fba45db2 | 1934 | path_info (char *args, int from_tty) |
c906108c SS |
1935 | { |
1936 | puts_filtered ("Executable and object file path: "); | |
3e43a32a MS |
1937 | puts_filtered (get_in_environ (current_inferior ()->environment, |
1938 | path_var_name)); | |
c906108c SS |
1939 | puts_filtered ("\n"); |
1940 | } | |
1941 | ||
1942 | /* Add zero or more directories to the front of the execution path. */ | |
1943 | ||
1944 | static void | |
fba45db2 | 1945 | path_command (char *dirname, int from_tty) |
c906108c SS |
1946 | { |
1947 | char *exec_path; | |
1948 | char *env; | |
abbb1732 | 1949 | |
c906108c | 1950 | dont_repeat (); |
3f81c18a | 1951 | env = get_in_environ (current_inferior ()->environment, path_var_name); |
1777feb0 | 1952 | /* Can be null if path is not set. */ |
c906108c SS |
1953 | if (!env) |
1954 | env = ""; | |
4fcf66da | 1955 | exec_path = xstrdup (env); |
c906108c | 1956 | mod_path (dirname, &exec_path); |
3f81c18a | 1957 | set_in_environ (current_inferior ()->environment, path_var_name, exec_path); |
b8c9b27d | 1958 | xfree (exec_path); |
c906108c | 1959 | if (from_tty) |
c5aa993b | 1960 | path_info ((char *) NULL, from_tty); |
c906108c | 1961 | } |
c906108c | 1962 | \f |
c5aa993b | 1963 | |
1777feb0 | 1964 | /* Print out the machine register regnum. If regnum is -1, print all |
0ab7a791 AC |
1965 | registers (print_all == 1) or all non-float and non-vector |
1966 | registers (print_all == 0). | |
c906108c SS |
1967 | |
1968 | For most machines, having all_registers_info() print the | |
0ab7a791 AC |
1969 | register(s) one per line is good enough. If a different format is |
1970 | required, (eg, for MIPS or Pyramid 90x, which both have lots of | |
1971 | regs), or there is an existing convention for showing all the | |
1972 | registers, define the architecture method PRINT_REGISTERS_INFO to | |
1973 | provide that format. */ | |
c906108c | 1974 | |
666e11c5 | 1975 | void |
0ab7a791 AC |
1976 | default_print_registers_info (struct gdbarch *gdbarch, |
1977 | struct ui_file *file, | |
1978 | struct frame_info *frame, | |
1979 | int regnum, int print_all) | |
c906108c | 1980 | { |
0ab7a791 | 1981 | int i; |
a4bd449d UW |
1982 | const int numregs = gdbarch_num_regs (gdbarch) |
1983 | + gdbarch_num_pseudo_regs (gdbarch); | |
0ab7a791 | 1984 | |
c906108c SS |
1985 | for (i = 0; i < numregs; i++) |
1986 | { | |
29ec5263 PA |
1987 | struct type *regtype; |
1988 | struct value *val; | |
1989 | ||
4782dc19 AC |
1990 | /* Decide between printing all regs, non-float / vector regs, or |
1991 | specific reg. */ | |
c5aa993b JM |
1992 | if (regnum == -1) |
1993 | { | |
f9418c0f | 1994 | if (print_all) |
4782dc19 | 1995 | { |
f9418c0f | 1996 | if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup)) |
4782dc19 | 1997 | continue; |
f9418c0f AC |
1998 | } |
1999 | else | |
2000 | { | |
2001 | if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup)) | |
4782dc19 AC |
2002 | continue; |
2003 | } | |
c5aa993b JM |
2004 | } |
2005 | else | |
2006 | { | |
2007 | if (i != regnum) | |
2008 | continue; | |
2009 | } | |
c906108c SS |
2010 | |
2011 | /* If the register name is empty, it is undefined for this | |
c5aa993b | 2012 | processor, so don't display anything. */ |
a4bd449d UW |
2013 | if (gdbarch_register_name (gdbarch, i) == NULL |
2014 | || *(gdbarch_register_name (gdbarch, i)) == '\0') | |
c906108c SS |
2015 | continue; |
2016 | ||
a4bd449d | 2017 | fputs_filtered (gdbarch_register_name (gdbarch, i), file); |
c9f4d572 | 2018 | print_spaces_filtered (15 - strlen (gdbarch_register_name |
a4bd449d | 2019 | (gdbarch, i)), file); |
c906108c | 2020 | |
29ec5263 PA |
2021 | regtype = register_type (gdbarch, i); |
2022 | val = allocate_value (regtype); | |
2023 | ||
c906108c | 2024 | /* Get the data in raw format. */ |
29ec5263 | 2025 | if (! frame_register_read (frame, i, value_contents_raw (val))) |
c906108c | 2026 | { |
0ab7a791 | 2027 | fprintf_filtered (file, "*value not available*\n"); |
c906108c SS |
2028 | continue; |
2029 | } | |
2030 | ||
0ab7a791 AC |
2031 | /* If virtual format is floating, print it that way, and in raw |
2032 | hex. */ | |
29ec5263 PA |
2033 | if (TYPE_CODE (regtype) == TYPE_CODE_FLT |
2034 | || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT) | |
c906108c | 2035 | { |
0ab7a791 | 2036 | int j; |
79a45b7d | 2037 | struct value_print_options opts; |
29ec5263 | 2038 | const gdb_byte *valaddr = value_contents_for_printing (val); |
c906108c | 2039 | |
79a45b7d TT |
2040 | get_user_print_options (&opts); |
2041 | opts.deref_ref = 1; | |
29ec5263 PA |
2042 | |
2043 | val_print (regtype, | |
2044 | value_contents_for_printing (val), | |
2045 | value_embedded_offset (val), 0, | |
2046 | file, 0, val, &opts, current_language); | |
c906108c | 2047 | |
0ab7a791 | 2048 | fprintf_filtered (file, "\t(raw 0x"); |
a4bd449d | 2049 | for (j = 0; j < register_size (gdbarch, i); j++) |
c906108c | 2050 | { |
0ab7a791 | 2051 | int idx; |
abbb1732 | 2052 | |
a4bd449d | 2053 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) |
0ab7a791 AC |
2054 | idx = j; |
2055 | else | |
a4bd449d | 2056 | idx = register_size (gdbarch, i) - 1 - j; |
29ec5263 | 2057 | fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]); |
c906108c | 2058 | } |
0ab7a791 | 2059 | fprintf_filtered (file, ")"); |
c906108c | 2060 | } |
c906108c SS |
2061 | else |
2062 | { | |
79a45b7d TT |
2063 | struct value_print_options opts; |
2064 | ||
ab4327e0 | 2065 | /* Print the register in hex. */ |
79a45b7d TT |
2066 | get_formatted_print_options (&opts, 'x'); |
2067 | opts.deref_ref = 1; | |
29ec5263 PA |
2068 | val_print (regtype, |
2069 | value_contents_for_printing (val), | |
2070 | value_embedded_offset (val), 0, | |
2071 | file, 0, val, &opts, current_language); | |
ab4327e0 EZ |
2072 | /* If not a vector register, print it also according to its |
2073 | natural format. */ | |
29ec5263 | 2074 | if (TYPE_VECTOR (regtype) == 0) |
ab4327e0 | 2075 | { |
79a45b7d TT |
2076 | get_user_print_options (&opts); |
2077 | opts.deref_ref = 1; | |
9d84ac84 | 2078 | fprintf_filtered (file, "\t"); |
29ec5263 PA |
2079 | val_print (regtype, |
2080 | value_contents_for_printing (val), | |
2081 | value_embedded_offset (val), 0, | |
2082 | file, 0, val, &opts, current_language); | |
ab4327e0 | 2083 | } |
c906108c SS |
2084 | } |
2085 | ||
0ab7a791 | 2086 | fprintf_filtered (file, "\n"); |
c906108c SS |
2087 | } |
2088 | } | |
c906108c | 2089 | |
c906108c | 2090 | void |
fba45db2 | 2091 | registers_info (char *addr_exp, int fpregs) |
c906108c | 2092 | { |
206415a3 | 2093 | struct frame_info *frame; |
a4bd449d | 2094 | struct gdbarch *gdbarch; |
c906108c SS |
2095 | |
2096 | if (!target_has_registers) | |
8a3fe4f8 | 2097 | error (_("The program has no registers now.")); |
206415a3 | 2098 | frame = get_selected_frame (NULL); |
a4bd449d | 2099 | gdbarch = get_frame_arch (frame); |
c906108c SS |
2100 | |
2101 | if (!addr_exp) | |
2102 | { | |
a4bd449d | 2103 | gdbarch_print_registers_info (gdbarch, gdb_stdout, |
206415a3 | 2104 | frame, -1, fpregs); |
c906108c SS |
2105 | return; |
2106 | } | |
2107 | ||
f9418c0f | 2108 | while (*addr_exp != '\0') |
c5aa993b | 2109 | { |
f9418c0f AC |
2110 | char *start; |
2111 | const char *end; | |
c906108c | 2112 | |
f9418c0f AC |
2113 | /* Keep skipping leading white space. */ |
2114 | if (isspace ((*addr_exp))) | |
2115 | { | |
2116 | addr_exp++; | |
2117 | continue; | |
2118 | } | |
c906108c | 2119 | |
f9418c0f AC |
2120 | /* Discard any leading ``$''. Check that there is something |
2121 | resembling a register following it. */ | |
2122 | if (addr_exp[0] == '$') | |
2123 | addr_exp++; | |
2124 | if (isspace ((*addr_exp)) || (*addr_exp) == '\0') | |
8a3fe4f8 | 2125 | error (_("Missing register name")); |
c906108c | 2126 | |
f9418c0f AC |
2127 | /* Find the start/end of this register name/num/group. */ |
2128 | start = addr_exp; | |
2129 | while ((*addr_exp) != '\0' && !isspace ((*addr_exp))) | |
2130 | addr_exp++; | |
2131 | end = addr_exp; | |
ad842144 | 2132 | |
f9418c0f AC |
2133 | /* Figure out what we've found and display it. */ |
2134 | ||
2135 | /* A register name? */ | |
2136 | { | |
029a67e4 | 2137 | int regnum = user_reg_map_name_to_regnum (gdbarch, start, end - start); |
abbb1732 | 2138 | |
f9418c0f AC |
2139 | if (regnum >= 0) |
2140 | { | |
ad842144 MR |
2141 | /* User registers lie completely outside of the range of |
2142 | normal registers. Catch them early so that the target | |
2143 | never sees them. */ | |
2144 | if (regnum >= gdbarch_num_regs (gdbarch) | |
2145 | + gdbarch_num_pseudo_regs (gdbarch)) | |
2146 | { | |
79a45b7d | 2147 | struct value_print_options opts; |
ad842144 MR |
2148 | struct value *val = value_of_user_reg (regnum, frame); |
2149 | ||
2150 | printf_filtered ("%s: ", start); | |
79a45b7d | 2151 | get_formatted_print_options (&opts, 'x'); |
ab2188aa PA |
2152 | val_print_scalar_formatted (check_typedef (value_type (val)), |
2153 | value_contents_for_printing (val), | |
2154 | value_embedded_offset (val), | |
2155 | val, | |
2156 | &opts, 0, gdb_stdout); | |
ad842144 MR |
2157 | printf_filtered ("\n"); |
2158 | } | |
2159 | else | |
2160 | gdbarch_print_registers_info (gdbarch, gdb_stdout, | |
2161 | frame, regnum, fpregs); | |
f9418c0f AC |
2162 | continue; |
2163 | } | |
2164 | } | |
ad842144 | 2165 | |
f9418c0f AC |
2166 | /* A register group? */ |
2167 | { | |
6c7d17ba | 2168 | struct reggroup *group; |
abbb1732 | 2169 | |
a4bd449d | 2170 | for (group = reggroup_next (gdbarch, NULL); |
6c7d17ba | 2171 | group != NULL; |
a4bd449d | 2172 | group = reggroup_next (gdbarch, group)) |
f9418c0f AC |
2173 | { |
2174 | /* Don't bother with a length check. Should the user | |
2175 | enter a short register group name, go with the first | |
2176 | group that matches. */ | |
6c7d17ba | 2177 | if (strncmp (start, reggroup_name (group), end - start) == 0) |
f9418c0f AC |
2178 | break; |
2179 | } | |
6c7d17ba | 2180 | if (group != NULL) |
f9418c0f AC |
2181 | { |
2182 | int regnum; | |
abbb1732 | 2183 | |
f57d151a | 2184 | for (regnum = 0; |
a4bd449d UW |
2185 | regnum < gdbarch_num_regs (gdbarch) |
2186 | + gdbarch_num_pseudo_regs (gdbarch); | |
f57d151a | 2187 | regnum++) |
f9418c0f | 2188 | { |
a4bd449d UW |
2189 | if (gdbarch_register_reggroup_p (gdbarch, regnum, group)) |
2190 | gdbarch_print_registers_info (gdbarch, | |
206415a3 | 2191 | gdb_stdout, frame, |
f9418c0f AC |
2192 | regnum, fpregs); |
2193 | } | |
2194 | continue; | |
2195 | } | |
2196 | } | |
c906108c | 2197 | |
f9418c0f | 2198 | /* Nothing matched. */ |
8a3fe4f8 | 2199 | error (_("Invalid register `%.*s'"), (int) (end - start), start); |
c5aa993b | 2200 | } |
c906108c SS |
2201 | } |
2202 | ||
2203 | void | |
fba45db2 | 2204 | all_registers_info (char *addr_exp, int from_tty) |
c906108c SS |
2205 | { |
2206 | registers_info (addr_exp, 1); | |
2207 | } | |
2208 | ||
a58dd373 | 2209 | static void |
fba45db2 | 2210 | nofp_registers_info (char *addr_exp, int from_tty) |
c906108c SS |
2211 | { |
2212 | registers_info (addr_exp, 0); | |
2213 | } | |
e76f1f2e AC |
2214 | |
2215 | static void | |
d80b854b | 2216 | print_vector_info (struct ui_file *file, |
e76f1f2e AC |
2217 | struct frame_info *frame, const char *args) |
2218 | { | |
d80b854b UW |
2219 | struct gdbarch *gdbarch = get_frame_arch (frame); |
2220 | ||
e76f1f2e AC |
2221 | if (gdbarch_print_vector_info_p (gdbarch)) |
2222 | gdbarch_print_vector_info (gdbarch, file, frame, args); | |
2223 | else | |
2224 | { | |
2225 | int regnum; | |
2226 | int printed_something = 0; | |
ab4327e0 | 2227 | |
f57d151a | 2228 | for (regnum = 0; |
a4bd449d UW |
2229 | regnum < gdbarch_num_regs (gdbarch) |
2230 | + gdbarch_num_pseudo_regs (gdbarch); | |
f57d151a | 2231 | regnum++) |
e76f1f2e | 2232 | { |
f9418c0f | 2233 | if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup)) |
e76f1f2e AC |
2234 | { |
2235 | printed_something = 1; | |
e76f1f2e | 2236 | gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); |
e76f1f2e AC |
2237 | } |
2238 | } | |
2239 | if (!printed_something) | |
2240 | fprintf_filtered (file, "No vector information\n"); | |
2241 | } | |
2242 | } | |
2243 | ||
2244 | static void | |
2245 | vector_info (char *args, int from_tty) | |
2246 | { | |
206415a3 DJ |
2247 | if (!target_has_registers) |
2248 | error (_("The program has no registers now.")); | |
2249 | ||
d80b854b | 2250 | print_vector_info (gdb_stdout, get_selected_frame (NULL), args); |
e76f1f2e | 2251 | } |
c906108c | 2252 | \f |
5fd62852 PA |
2253 | /* Kill the inferior process. Make us have no inferior. */ |
2254 | ||
2255 | static void | |
2256 | kill_command (char *arg, int from_tty) | |
2257 | { | |
2258 | /* FIXME: This should not really be inferior_ptid (or target_has_execution). | |
2259 | It should be a distinct flag that indicates that a target is active, cuz | |
1777feb0 | 2260 | some targets don't have processes! */ |
5fd62852 PA |
2261 | |
2262 | if (ptid_equal (inferior_ptid, null_ptid)) | |
2263 | error (_("The program is not being run.")); | |
2264 | if (!query (_("Kill the program being debugged? "))) | |
2265 | error (_("Not confirmed.")); | |
2266 | target_kill (); | |
2267 | ||
c35b1492 PA |
2268 | /* If we still have other inferiors to debug, then don't mess with |
2269 | with their threads. */ | |
2270 | if (!have_inferiors ()) | |
5fd62852 | 2271 | { |
1777feb0 | 2272 | init_thread_list (); /* Destroy thread info. */ |
5fd62852 PA |
2273 | |
2274 | /* Killing off the inferior can leave us with a core file. If | |
2275 | so, print the state we are left in. */ | |
2276 | if (target_has_stack) | |
2277 | { | |
2278 | printf_filtered (_("In %s,\n"), target_longname); | |
2279 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); | |
2280 | } | |
2281 | } | |
2282 | bfd_cache_close_all (); | |
2283 | } | |
c5aa993b | 2284 | |
74531fed PA |
2285 | /* Used in `attach&' command. ARG is a point to an integer |
2286 | representing a process id. Proceed threads of this process iff | |
2287 | they stopped due to debugger request, and when they did, they | |
2288 | reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads | |
2289 | that have been explicitly been told to stop. */ | |
2290 | ||
2291 | static int | |
2292 | proceed_after_attach_callback (struct thread_info *thread, | |
2293 | void *arg) | |
2294 | { | |
2295 | int pid = * (int *) arg; | |
2296 | ||
2297 | if (ptid_get_pid (thread->ptid) == pid | |
2298 | && !is_exited (thread->ptid) | |
2299 | && !is_executing (thread->ptid) | |
2300 | && !thread->stop_requested | |
16c381f0 | 2301 | && thread->suspend.stop_signal == TARGET_SIGNAL_0) |
74531fed PA |
2302 | { |
2303 | switch_to_thread (thread->ptid); | |
2304 | clear_proceed_status (); | |
2305 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); | |
2306 | } | |
2307 | ||
2308 | return 0; | |
2309 | } | |
2310 | ||
2311 | static void | |
2312 | proceed_after_attach (int pid) | |
2313 | { | |
2314 | /* Don't error out if the current thread is running, because | |
2315 | there may be other stopped threads. */ | |
2316 | struct cleanup *old_chain; | |
2317 | ||
2318 | /* Backup current thread and selected frame. */ | |
2319 | old_chain = make_cleanup_restore_current_thread (); | |
2320 | ||
2321 | iterate_over_threads (proceed_after_attach_callback, &pid); | |
2322 | ||
2323 | /* Restore selected ptid. */ | |
2324 | do_cleanups (old_chain); | |
2325 | } | |
2326 | ||
c906108c SS |
2327 | /* |
2328 | * TODO: | |
2329 | * Should save/restore the tty state since it might be that the | |
2330 | * program to be debugged was started on this tty and it wants | |
2331 | * the tty in some state other than what we want. If it's running | |
2332 | * on another terminal or without a terminal, then saving and | |
2333 | * restoring the tty state is a harmless no-op. | |
2334 | * This only needs to be done if we are attaching to a process. | |
2335 | */ | |
2336 | ||
1777feb0 | 2337 | /* attach_command -- |
c906108c SS |
2338 | takes a program started up outside of gdb and ``attaches'' to it. |
2339 | This stops it cold in its tracks and allows us to start debugging it. | |
2340 | and wait for the trace-trap that results from attaching. */ | |
2341 | ||
9356cf8d PA |
2342 | static void |
2343 | attach_command_post_wait (char *args, int from_tty, int async_exec) | |
2344 | { | |
2345 | char *exec_file; | |
2346 | char *full_exec_path = NULL; | |
d6b48e9c | 2347 | struct inferior *inferior; |
9356cf8d | 2348 | |
d6b48e9c | 2349 | inferior = current_inferior (); |
16c381f0 | 2350 | inferior->control.stop_soon = NO_STOP_QUIETLY; |
9356cf8d PA |
2351 | |
2352 | /* If no exec file is yet known, try to determine it from the | |
2353 | process itself. */ | |
2354 | exec_file = (char *) get_exec_file (0); | |
2355 | if (!exec_file) | |
2356 | { | |
2357 | exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid)); | |
2358 | if (exec_file) | |
2359 | { | |
2360 | /* It's possible we don't have a full path, but rather just a | |
2361 | filename. Some targets, such as HP-UX, don't provide the | |
2362 | full path, sigh. | |
2363 | ||
2364 | Attempt to qualify the filename against the source path. | |
2365 | (If that fails, we'll just fall back on the original | |
1777feb0 MS |
2366 | filename. Not much more we can do...) */ |
2367 | ||
9356cf8d | 2368 | if (!source_full_path_of (exec_file, &full_exec_path)) |
1b36a34b | 2369 | full_exec_path = xstrdup (exec_file); |
9356cf8d PA |
2370 | |
2371 | exec_file_attach (full_exec_path, from_tty); | |
2372 | symbol_file_add_main (full_exec_path, from_tty); | |
2373 | } | |
2374 | } | |
2375 | else | |
2376 | { | |
2377 | reopen_exec_file (); | |
2378 | reread_symbols (); | |
2379 | } | |
2380 | ||
2381 | /* Take any necessary post-attaching actions for this platform. */ | |
2382 | target_post_attach (PIDGET (inferior_ptid)); | |
2383 | ||
2384 | post_create_inferior (¤t_target, from_tty); | |
2385 | ||
2386 | /* Install inferior's terminal modes. */ | |
2387 | target_terminal_inferior (); | |
2388 | ||
2389 | if (async_exec) | |
74531fed PA |
2390 | { |
2391 | /* The user requested an `attach&', so be sure to leave threads | |
2392 | that didn't get a signal running. */ | |
2393 | ||
2394 | /* Immediatelly resume all suspended threads of this inferior, | |
2395 | and this inferior only. This should have no effect on | |
2396 | already running threads. If a thread has been stopped with a | |
2397 | signal, leave it be. */ | |
2398 | if (non_stop) | |
2399 | proceed_after_attach (inferior->pid); | |
2400 | else | |
2401 | { | |
16c381f0 | 2402 | if (inferior_thread ()->suspend.stop_signal == TARGET_SIGNAL_0) |
74531fed PA |
2403 | { |
2404 | clear_proceed_status (); | |
2405 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); | |
2406 | } | |
2407 | } | |
2408 | } | |
9356cf8d PA |
2409 | else |
2410 | { | |
74531fed PA |
2411 | /* The user requested a plain `attach', so be sure to leave |
2412 | the inferior stopped. */ | |
2413 | ||
9356cf8d PA |
2414 | if (target_can_async_p ()) |
2415 | async_enable_stdin (); | |
74531fed PA |
2416 | |
2417 | /* At least the current thread is already stopped. */ | |
2418 | ||
2419 | /* In all-stop, by definition, all threads have to be already | |
2420 | stopped at this point. In non-stop, however, although the | |
2421 | selected thread is stopped, others may still be executing. | |
2422 | Be sure to explicitly stop all threads of the process. This | |
2423 | should have no effect on already stopped threads. */ | |
2424 | if (non_stop) | |
2425 | target_stop (pid_to_ptid (inferior->pid)); | |
2426 | ||
2427 | /* Tell the user/frontend where we're stopped. */ | |
9356cf8d PA |
2428 | normal_stop (); |
2429 | if (deprecated_attach_hook) | |
2430 | deprecated_attach_hook (); | |
2431 | } | |
2432 | } | |
2433 | ||
bfec99b2 | 2434 | struct attach_command_continuation_args |
9356cf8d PA |
2435 | { |
2436 | char *args; | |
2437 | int from_tty; | |
2438 | int async_exec; | |
bfec99b2 | 2439 | }; |
9356cf8d | 2440 | |
bfec99b2 | 2441 | static void |
fa4cd53f | 2442 | attach_command_continuation (void *args, int err) |
bfec99b2 PA |
2443 | { |
2444 | struct attach_command_continuation_args *a = args; | |
abbb1732 | 2445 | |
fa4cd53f PA |
2446 | if (err) |
2447 | return; | |
2448 | ||
bfec99b2 | 2449 | attach_command_post_wait (a->args, a->from_tty, a->async_exec); |
9356cf8d PA |
2450 | } |
2451 | ||
604ead4a PA |
2452 | static void |
2453 | attach_command_continuation_free_args (void *args) | |
2454 | { | |
2455 | struct attach_command_continuation_args *a = args; | |
abbb1732 | 2456 | |
604ead4a PA |
2457 | xfree (a->args); |
2458 | xfree (a); | |
2459 | } | |
2460 | ||
c906108c | 2461 | void |
fba45db2 | 2462 | attach_command (char *args, int from_tty) |
c906108c | 2463 | { |
9356cf8d | 2464 | int async_exec = 0; |
cb0362bb | 2465 | struct cleanup *back_to = make_cleanup (null_cleanup, NULL); |
c906108c | 2466 | |
c5aa993b | 2467 | dont_repeat (); /* Not for the faint of heart */ |
c906108c | 2468 | |
2567c7d9 PA |
2469 | if (gdbarch_has_global_solist (target_gdbarch)) |
2470 | /* Don't complain if all processes share the same symbol | |
2471 | space. */ | |
8a305172 PA |
2472 | ; |
2473 | else if (target_has_execution) | |
c906108c | 2474 | { |
9e2f0ad4 | 2475 | if (query (_("A program is being debugged already. Kill it? "))) |
c906108c SS |
2476 | target_kill (); |
2477 | else | |
8a3fe4f8 | 2478 | error (_("Not killed.")); |
c906108c SS |
2479 | } |
2480 | ||
fd79ecee DJ |
2481 | /* Clean up any leftovers from other runs. Some other things from |
2482 | this function should probably be moved into target_pre_inferior. */ | |
2483 | target_pre_inferior (from_tty); | |
2484 | ||
9908b566 VP |
2485 | if (non_stop && !target_supports_non_stop ()) |
2486 | error (_("Cannot attach to this target in non-stop mode")); | |
2487 | ||
9356cf8d PA |
2488 | if (args) |
2489 | { | |
2490 | async_exec = strip_bg_char (&args); | |
2491 | ||
2492 | /* If we get a request for running in the bg but the target | |
1777feb0 | 2493 | doesn't support it, error out. */ |
9356cf8d PA |
2494 | if (async_exec && !target_can_async_p ()) |
2495 | error (_("Asynchronous execution not supported on this target.")); | |
2496 | } | |
2497 | ||
2498 | /* If we don't get a request of running in the bg, then we need | |
2499 | to simulate synchronous (fg) execution. */ | |
2500 | if (!async_exec && target_can_async_p ()) | |
2501 | { | |
1777feb0 | 2502 | /* Simulate synchronous execution. */ |
9356cf8d | 2503 | async_disable_stdin (); |
cb0362bb | 2504 | make_cleanup ((make_cleanup_ftype *)async_enable_stdin, NULL); |
9356cf8d PA |
2505 | } |
2506 | ||
c906108c SS |
2507 | target_attach (args, from_tty); |
2508 | ||
2509 | /* Set up the "saved terminal modes" of the inferior | |
2510 | based on what modes we are starting it with. */ | |
2511 | target_terminal_init (); | |
2512 | ||
c906108c SS |
2513 | /* Set up execution context to know that we should return from |
2514 | wait_for_inferior as soon as the target reports a stop. */ | |
2515 | init_wait_for_inferior (); | |
2516 | clear_proceed_status (); | |
c906108c | 2517 | |
74531fed PA |
2518 | if (non_stop) |
2519 | { | |
2520 | /* If we find that the current thread isn't stopped, explicitly | |
2521 | do so now, because we're going to install breakpoints and | |
2522 | poke at memory. */ | |
2523 | ||
2524 | if (async_exec) | |
2525 | /* The user requested an `attach&'; stop just one thread. */ | |
2526 | target_stop (inferior_ptid); | |
2527 | else | |
2528 | /* The user requested an `attach', so stop all threads of this | |
2529 | inferior. */ | |
2530 | target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid))); | |
2531 | } | |
2532 | ||
dc177b7a PA |
2533 | /* Some system don't generate traps when attaching to inferior. |
2534 | E.g. Mach 3 or GNU hurd. */ | |
2535 | if (!target_attach_no_wait) | |
c5aa993b | 2536 | { |
d6b48e9c PA |
2537 | struct inferior *inferior = current_inferior (); |
2538 | ||
1777feb0 | 2539 | /* Careful here. See comments in inferior.h. Basically some |
dc177b7a PA |
2540 | OSes don't ignore SIGSTOPs on continue requests anymore. We |
2541 | need a way for handle_inferior_event to reset the stop_signal | |
2542 | variable after an attach, and this is what | |
2543 | STOP_QUIETLY_NO_SIGSTOP is for. */ | |
16c381f0 | 2544 | inferior->control.stop_soon = STOP_QUIETLY_NO_SIGSTOP; |
c5aa993b | 2545 | |
dc177b7a PA |
2546 | if (target_can_async_p ()) |
2547 | { | |
2548 | /* sync_execution mode. Wait for stop. */ | |
bfec99b2 PA |
2549 | struct attach_command_continuation_args *a; |
2550 | ||
2551 | a = xmalloc (sizeof (*a)); | |
2552 | a->args = xstrdup (args); | |
2553 | a->from_tty = from_tty; | |
2554 | a->async_exec = async_exec; | |
e0ba6746 PA |
2555 | add_inferior_continuation (attach_command_continuation, a, |
2556 | attach_command_continuation_free_args); | |
cb0362bb | 2557 | discard_cleanups (back_to); |
dc177b7a PA |
2558 | return; |
2559 | } | |
c906108c | 2560 | |
e4c8541f | 2561 | wait_for_inferior (); |
dc177b7a | 2562 | } |
6426a772 | 2563 | |
9356cf8d | 2564 | attach_command_post_wait (args, from_tty, async_exec); |
cb0362bb | 2565 | discard_cleanups (back_to); |
c906108c SS |
2566 | } |
2567 | ||
1941c569 PA |
2568 | /* We had just found out that the target was already attached to an |
2569 | inferior. PTID points at a thread of this new inferior, that is | |
2570 | the most likely to be stopped right now, but not necessarily so. | |
2571 | The new inferior is assumed to be already added to the inferior | |
2572 | list at this point. If LEAVE_RUNNING, then leave the threads of | |
2573 | this inferior running, except those we've explicitly seen reported | |
2574 | as stopped. */ | |
2575 | ||
2576 | void | |
2577 | notice_new_inferior (ptid_t ptid, int leave_running, int from_tty) | |
2578 | { | |
2579 | struct cleanup* old_chain; | |
2580 | int async_exec; | |
2581 | ||
2582 | old_chain = make_cleanup (null_cleanup, NULL); | |
2583 | ||
2584 | /* If in non-stop, leave threads as running as they were. If | |
2585 | they're stopped for some reason other than us telling it to, the | |
2586 | target reports a signal != TARGET_SIGNAL_0. We don't try to | |
2587 | resume threads with such a stop signal. */ | |
2588 | async_exec = non_stop; | |
2589 | ||
2590 | if (!ptid_equal (inferior_ptid, null_ptid)) | |
2591 | make_cleanup_restore_current_thread (); | |
2592 | ||
2593 | switch_to_thread (ptid); | |
2594 | ||
2595 | /* When we "notice" a new inferior we need to do all the things we | |
2596 | would normally do if we had just attached to it. */ | |
2597 | ||
2598 | if (is_executing (inferior_ptid)) | |
2599 | { | |
2600 | struct inferior *inferior = current_inferior (); | |
2601 | ||
2602 | /* We're going to install breakpoints, and poke at memory, | |
2603 | ensure that the inferior is stopped for a moment while we do | |
2604 | that. */ | |
2605 | target_stop (inferior_ptid); | |
2606 | ||
16c381f0 | 2607 | inferior->control.stop_soon = STOP_QUIETLY_REMOTE; |
1941c569 PA |
2608 | |
2609 | /* Wait for stop before proceeding. */ | |
2610 | if (target_can_async_p ()) | |
2611 | { | |
2612 | struct attach_command_continuation_args *a; | |
2613 | ||
2614 | a = xmalloc (sizeof (*a)); | |
2615 | a->args = xstrdup (""); | |
2616 | a->from_tty = from_tty; | |
2617 | a->async_exec = async_exec; | |
2618 | add_inferior_continuation (attach_command_continuation, a, | |
2619 | attach_command_continuation_free_args); | |
2620 | ||
2621 | do_cleanups (old_chain); | |
2622 | return; | |
2623 | } | |
2624 | else | |
e4c8541f | 2625 | wait_for_inferior (); |
1941c569 PA |
2626 | } |
2627 | ||
2628 | async_exec = leave_running; | |
2629 | attach_command_post_wait ("" /* args */, from_tty, async_exec); | |
2630 | ||
2631 | do_cleanups (old_chain); | |
2632 | } | |
2633 | ||
c906108c SS |
2634 | /* |
2635 | * detach_command -- | |
2636 | * takes a program previously attached to and detaches it. | |
2637 | * The program resumes execution and will no longer stop | |
2638 | * on signals, etc. We better not have left any breakpoints | |
2639 | * in the program or it'll die when it hits one. For this | |
2640 | * to work, it may be necessary for the process to have been | |
2641 | * previously attached. It *might* work if the program was | |
2642 | * started via the normal ptrace (PTRACE_TRACEME). | |
2643 | */ | |
2644 | ||
6418d433 | 2645 | void |
fba45db2 | 2646 | detach_command (char *args, int from_tty) |
c906108c | 2647 | { |
1f5d0fc9 | 2648 | dont_repeat (); /* Not for the faint of heart. */ |
d729566a PA |
2649 | |
2650 | if (ptid_equal (inferior_ptid, null_ptid)) | |
2651 | error (_("The program is not being run.")); | |
2652 | ||
33da3f1c | 2653 | disconnect_tracing (from_tty); |
d5551862 | 2654 | |
c906108c | 2655 | target_detach (args, from_tty); |
50c71eaf PA |
2656 | |
2657 | /* If the solist is global across inferiors, don't clear it when we | |
2658 | detach from a single inferior. */ | |
2659 | if (!gdbarch_has_global_solist (target_gdbarch)) | |
2660 | no_shared_libraries (NULL, from_tty); | |
8a305172 | 2661 | |
c35b1492 PA |
2662 | /* If we still have inferiors to debug, then don't mess with their |
2663 | threads. */ | |
2664 | if (!have_inferiors ()) | |
8a305172 PA |
2665 | init_thread_list (); |
2666 | ||
9a4105ab AC |
2667 | if (deprecated_detach_hook) |
2668 | deprecated_detach_hook (); | |
c906108c SS |
2669 | } |
2670 | ||
6ad8ae5c DJ |
2671 | /* Disconnect from the current target without resuming it (leaving it |
2672 | waiting for a debugger). | |
2673 | ||
2674 | We'd better not have left any breakpoints in the program or the | |
2675 | next debugger will get confused. Currently only supported for some | |
2676 | remote targets, since the normal attach mechanisms don't work on | |
2677 | stopped processes on some native platforms (e.g. GNU/Linux). */ | |
2678 | ||
2679 | static void | |
2680 | disconnect_command (char *args, int from_tty) | |
2681 | { | |
1777feb0 | 2682 | dont_repeat (); /* Not for the faint of heart. */ |
d31647d2 | 2683 | disconnect_tracing (from_tty); |
6ad8ae5c | 2684 | target_disconnect (args, from_tty); |
e85a822c | 2685 | no_shared_libraries (NULL, from_tty); |
a0ef4274 | 2686 | init_thread_list (); |
9a4105ab AC |
2687 | if (deprecated_detach_hook) |
2688 | deprecated_detach_hook (); | |
6ad8ae5c DJ |
2689 | } |
2690 | ||
77ebaa5a VP |
2691 | void |
2692 | interrupt_target_1 (int all_threads) | |
2693 | { | |
2694 | ptid_t ptid; | |
abbb1732 | 2695 | |
77ebaa5a VP |
2696 | if (all_threads) |
2697 | ptid = minus_one_ptid; | |
2698 | else | |
2699 | ptid = inferior_ptid; | |
2700 | target_stop (ptid); | |
252fbfc8 PA |
2701 | |
2702 | /* Tag the thread as having been explicitly requested to stop, so | |
2703 | other parts of gdb know not to resume this thread automatically, | |
2704 | if it was stopped due to an internal event. Limit this to | |
2705 | non-stop mode, as when debugging a multi-threaded application in | |
2706 | all-stop mode, we will only get one stop event --- it's undefined | |
2707 | which thread will report the event. */ | |
2708 | if (non_stop) | |
2709 | set_stop_requested (ptid, 1); | |
77ebaa5a VP |
2710 | } |
2711 | ||
43ff13b4 | 2712 | /* Stop the execution of the target while running in async mode, in |
8cae4b3f PA |
2713 | the backgound. In all-stop, stop the whole process. In non-stop |
2714 | mode, stop the current thread only by default, or stop all threads | |
2715 | if the `-a' switch is used. */ | |
2716 | ||
2717 | /* interrupt [-a] */ | |
8b93c638 | 2718 | void |
fba45db2 | 2719 | interrupt_target_command (char *args, int from_tty) |
43ff13b4 | 2720 | { |
362646f5 | 2721 | if (target_can_async_p ()) |
43ff13b4 | 2722 | { |
8cae4b3f PA |
2723 | int all_threads = 0; |
2724 | ||
1777feb0 | 2725 | dont_repeat (); /* Not for the faint of heart. */ |
94cc34af | 2726 | |
8cae4b3f PA |
2727 | if (args != NULL |
2728 | && strncmp (args, "-a", sizeof ("-a") - 1) == 0) | |
2729 | all_threads = 1; | |
2730 | ||
2731 | if (!non_stop && all_threads) | |
2732 | error (_("-a is meaningless in all-stop mode.")); | |
2733 | ||
77ebaa5a | 2734 | interrupt_target_1 (all_threads); |
43ff13b4 JM |
2735 | } |
2736 | } | |
2737 | ||
c906108c | 2738 | static void |
d80b854b | 2739 | print_float_info (struct ui_file *file, |
23e3a7ac | 2740 | struct frame_info *frame, const char *args) |
c906108c | 2741 | { |
d80b854b UW |
2742 | struct gdbarch *gdbarch = get_frame_arch (frame); |
2743 | ||
23e3a7ac AC |
2744 | if (gdbarch_print_float_info_p (gdbarch)) |
2745 | gdbarch_print_float_info (gdbarch, file, frame, args); | |
2746 | else | |
2747 | { | |
23e3a7ac AC |
2748 | int regnum; |
2749 | int printed_something = 0; | |
ab4327e0 | 2750 | |
f57d151a | 2751 | for (regnum = 0; |
a4bd449d UW |
2752 | regnum < gdbarch_num_regs (gdbarch) |
2753 | + gdbarch_num_pseudo_regs (gdbarch); | |
f57d151a | 2754 | regnum++) |
23e3a7ac | 2755 | { |
f9418c0f | 2756 | if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup)) |
23e3a7ac AC |
2757 | { |
2758 | printed_something = 1; | |
23e3a7ac | 2759 | gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); |
23e3a7ac AC |
2760 | } |
2761 | } | |
2762 | if (!printed_something) | |
3e43a32a MS |
2763 | fprintf_filtered (file, "No floating-point info " |
2764 | "available for this processor.\n"); | |
23e3a7ac AC |
2765 | } |
2766 | } | |
2767 | ||
2768 | static void | |
2769 | float_info (char *args, int from_tty) | |
2770 | { | |
206415a3 DJ |
2771 | if (!target_has_registers) |
2772 | error (_("The program has no registers now.")); | |
2773 | ||
d80b854b | 2774 | print_float_info (gdb_stdout, get_selected_frame (NULL), args); |
c906108c SS |
2775 | } |
2776 | \f | |
c906108c | 2777 | static void |
fba45db2 | 2778 | unset_command (char *args, int from_tty) |
c906108c | 2779 | { |
3e43a32a MS |
2780 | printf_filtered (_("\"unset\" must be followed by the " |
2781 | "name of an unset subcommand.\n")); | |
c906108c SS |
2782 | help_list (unsetlist, "unset ", -1, gdb_stdout); |
2783 | } | |
2784 | ||
2785 | void | |
fba45db2 | 2786 | _initialize_infcmd (void) |
c906108c | 2787 | { |
3cb3b8df BR |
2788 | struct cmd_list_element *c = NULL; |
2789 | ||
1777feb0 | 2790 | /* Add the filename of the terminal connected to inferior I/O. */ |
3cb3b8df | 2791 | add_setshow_filename_cmd ("inferior-tty", class_run, |
3f81c18a | 2792 | &inferior_io_terminal_scratch, _("\ |
3cb3b8df BR |
2793 | Set terminal for future runs of program being debugged."), _("\ |
2794 | Show terminal for future runs of program being debugged."), _("\ | |
3f81c18a VP |
2795 | Usage: set inferior-tty /dev/pts/1"), |
2796 | set_inferior_tty_command, | |
2797 | show_inferior_tty_command, | |
2798 | &setlist, &showlist); | |
3cb3b8df | 2799 | add_com_alias ("tty", "set inferior-tty", class_alias, 0); |
c906108c | 2800 | |
b4b4ac0b | 2801 | add_setshow_optional_filename_cmd ("args", class_run, |
3f81c18a | 2802 | &inferior_args_scratch, _("\ |
b4b4ac0b AC |
2803 | Set argument list to give program being debugged when it is started."), _("\ |
2804 | Show argument list to give program being debugged when it is started."), _("\ | |
2805 | Follow this command with any number of args, to be passed to the program."), | |
3f81c18a VP |
2806 | set_args_command, |
2807 | show_args_command, | |
b4b4ac0b | 2808 | &setlist, &showlist); |
c906108c | 2809 | |
1a966eab AC |
2810 | c = add_cmd ("environment", no_class, environment_info, _("\ |
2811 | The environment to give the program, or one variable's value.\n\ | |
c906108c SS |
2812 | With an argument VAR, prints the value of environment variable VAR to\n\ |
2813 | give the program being debugged. With no arguments, prints the entire\n\ | |
1a966eab | 2814 | environment to be given to the program."), &showlist); |
5ba2abeb | 2815 | set_cmd_completer (c, noop_completer); |
c906108c SS |
2816 | |
2817 | add_prefix_cmd ("unset", no_class, unset_command, | |
1bedd215 | 2818 | _("Complement to certain \"set\" commands."), |
c906108c | 2819 | &unsetlist, "unset ", 0, &cmdlist); |
c5aa993b | 2820 | |
1a966eab AC |
2821 | c = add_cmd ("environment", class_run, unset_environment_command, _("\ |
2822 | Cancel environment variable VAR for the program.\n\ | |
2823 | This does not affect the program until the next \"run\" command."), | |
c5aa993b | 2824 | &unsetlist); |
5ba2abeb | 2825 | set_cmd_completer (c, noop_completer); |
c906108c | 2826 | |
1a966eab AC |
2827 | c = add_cmd ("environment", class_run, set_environment_command, _("\ |
2828 | Set environment variable value to give the program.\n\ | |
c906108c SS |
2829 | Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ |
2830 | VALUES of environment variables are uninterpreted strings.\n\ | |
1a966eab | 2831 | This does not affect the program until the next \"run\" command."), |
c5aa993b | 2832 | &setlist); |
5ba2abeb | 2833 | set_cmd_completer (c, noop_completer); |
c5aa993b | 2834 | |
1bedd215 AC |
2835 | c = add_com ("path", class_files, path_command, _("\ |
2836 | Add directory DIR(s) to beginning of search path for object files.\n\ | |
c906108c SS |
2837 | $cwd in the path means the current working directory.\n\ |
2838 | This path is equivalent to the $PATH shell variable. It is a list of\n\ | |
2839 | directories, separated by colons. These directories are searched to find\n\ | |
3e43a32a MS |
2840 | fully linked executable files and separately compiled object files as \ |
2841 | needed.")); | |
5ba2abeb | 2842 | set_cmd_completer (c, filename_completer); |
c906108c | 2843 | |
1a966eab AC |
2844 | c = add_cmd ("paths", no_class, path_info, _("\ |
2845 | Current search path for finding object files.\n\ | |
c906108c SS |
2846 | $cwd in the path means the current working directory.\n\ |
2847 | This path is equivalent to the $PATH shell variable. It is a list of\n\ | |
2848 | directories, separated by colons. These directories are searched to find\n\ | |
3e43a32a MS |
2849 | fully linked executable files and separately compiled object files as \ |
2850 | needed."), | |
c906108c | 2851 | &showlist); |
5ba2abeb | 2852 | set_cmd_completer (c, noop_completer); |
c906108c | 2853 | |
2277426b PA |
2854 | add_prefix_cmd ("kill", class_run, kill_command, |
2855 | _("Kill execution of program being debugged."), | |
2856 | &killlist, "kill ", 0, &cmdlist); | |
5fd62852 | 2857 | |
1bedd215 AC |
2858 | add_com ("attach", class_run, attach_command, _("\ |
2859 | Attach to a process or file outside of GDB.\n\ | |
c906108c SS |
2860 | This command attaches to another target, of the same type as your last\n\ |
2861 | \"target\" command (\"info files\" will show your target stack).\n\ | |
2862 | The command may take as argument a process id or a device file.\n\ | |
2863 | For a process id, you must have permission to send the process a signal,\n\ | |
2864 | and it must have the same effective uid as the debugger.\n\ | |
2865 | When using \"attach\" with a process id, the debugger finds the\n\ | |
2866 | program running in the process, looking first in the current working\n\ | |
2867 | directory, or (if not found there) using the source file search path\n\ | |
2868 | (see the \"directory\" command). You can also use the \"file\" command\n\ | |
1bedd215 | 2869 | to specify the program, and to load its symbol table.")); |
c906108c | 2870 | |
f73adfeb | 2871 | add_prefix_cmd ("detach", class_run, detach_command, _("\ |
1bedd215 | 2872 | Detach a process or file previously attached.\n\ |
c906108c | 2873 | If a process, it is no longer traced, and it continues its execution. If\n\ |
f73adfeb AS |
2874 | you were debugging a file, the file is closed and gdb no longer accesses it."), |
2875 | &detachlist, "detach ", 0, &cmdlist); | |
c906108c | 2876 | |
1bedd215 AC |
2877 | add_com ("disconnect", class_run, disconnect_command, _("\ |
2878 | Disconnect from a target.\n\ | |
6ad8ae5c | 2879 | The target will wait for another debugger to connect. Not available for\n\ |
1bedd215 | 2880 | all targets.")); |
6ad8ae5c | 2881 | |
1bedd215 AC |
2882 | add_com ("signal", class_run, signal_command, _("\ |
2883 | Continue program giving it signal specified by the argument.\n\ | |
2884 | An argument of \"0\" means continue program without giving it a signal.")); | |
c906108c | 2885 | |
1bedd215 AC |
2886 | add_com ("stepi", class_run, stepi_command, _("\ |
2887 | Step one instruction exactly.\n\ | |
3e43a32a MS |
2888 | Argument N means do this N times (or till program stops for another \ |
2889 | reason).")); | |
c906108c SS |
2890 | add_com_alias ("si", "stepi", class_alias, 0); |
2891 | ||
1bedd215 AC |
2892 | add_com ("nexti", class_run, nexti_command, _("\ |
2893 | Step one instruction, but proceed through subroutine calls.\n\ | |
3e43a32a MS |
2894 | Argument N means do this N times (or till program stops for another \ |
2895 | reason).")); | |
c906108c SS |
2896 | add_com_alias ("ni", "nexti", class_alias, 0); |
2897 | ||
1bedd215 AC |
2898 | add_com ("finish", class_run, finish_command, _("\ |
2899 | Execute until selected stack frame returns.\n\ | |
2900 | Upon return, the value returned is printed and put in the value history.")); | |
0e479716 | 2901 | add_com_alias ("fin", "finish", class_run, 1); |
c906108c | 2902 | |
1bedd215 AC |
2903 | add_com ("next", class_run, next_command, _("\ |
2904 | Step program, proceeding through subroutine calls.\n\ | |
c906108c SS |
2905 | Like the \"step\" command as long as subroutine calls do not happen;\n\ |
2906 | when they do, the call is treated as one instruction.\n\ | |
3e43a32a MS |
2907 | Argument N means do this N times (or till program stops for another \ |
2908 | reason).")); | |
c906108c SS |
2909 | add_com_alias ("n", "next", class_run, 1); |
2910 | if (xdb_commands) | |
c5aa993b | 2911 | add_com_alias ("S", "next", class_run, 1); |
c906108c | 2912 | |
1bedd215 AC |
2913 | add_com ("step", class_run, step_command, _("\ |
2914 | Step program until it reaches a different source line.\n\ | |
3e43a32a MS |
2915 | Argument N means do this N times (or till program stops for another \ |
2916 | reason).")); | |
c906108c SS |
2917 | add_com_alias ("s", "step", class_run, 1); |
2918 | ||
1bedd215 AC |
2919 | c = add_com ("until", class_run, until_command, _("\ |
2920 | Execute until the program reaches a source line greater than the current\n\ | |
3e43a32a MS |
2921 | or a specified location (same args as break command) within the current \ |
2922 | frame.")); | |
5ba2abeb | 2923 | set_cmd_completer (c, location_completer); |
c906108c | 2924 | add_com_alias ("u", "until", class_run, 1); |
c5aa993b | 2925 | |
1bedd215 | 2926 | c = add_com ("advance", class_run, advance_command, _("\ |
3e43a32a MS |
2927 | Continue the program up to the given location (same form as args for break \ |
2928 | command).\n\ | |
1bedd215 | 2929 | Execution will also stop upon exit from the current stack frame.")); |
ae66c1fc EZ |
2930 | set_cmd_completer (c, location_completer); |
2931 | ||
1bedd215 AC |
2932 | c = add_com ("jump", class_run, jump_command, _("\ |
2933 | Continue program being debugged at specified line or address.\n\ | |
c906108c | 2934 | Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ |
1bedd215 | 2935 | for an address to start at.")); |
5ba2abeb | 2936 | set_cmd_completer (c, location_completer); |
c906108c | 2937 | |
b83266a0 | 2938 | if (xdb_commands) |
c94fdfd0 | 2939 | { |
1bedd215 AC |
2940 | c = add_com ("go", class_run, go_command, _("\ |
2941 | Usage: go <location>\n\ | |
c906108c SS |
2942 | Continue program being debugged, stopping at specified line or \n\ |
2943 | address.\n\ | |
2944 | Give as argument either LINENUM or *ADDR, where ADDR is an \n\ | |
2945 | expression for an address to start at.\n\ | |
1bedd215 | 2946 | This command is a combination of tbreak and jump.")); |
5ba2abeb | 2947 | set_cmd_completer (c, location_completer); |
c94fdfd0 | 2948 | } |
b83266a0 | 2949 | |
c906108c | 2950 | if (xdb_commands) |
c5aa993b | 2951 | add_com_alias ("g", "go", class_run, 1); |
c906108c | 2952 | |
df983543 | 2953 | add_com ("continue", class_run, continue_command, _("\ |
1bedd215 | 2954 | Continue program being debugged, after signal or breakpoint.\n\ |
c906108c SS |
2955 | If proceeding from breakpoint, a number N may be used as an argument,\n\ |
2956 | which means to set the ignore count of that breakpoint to N - 1 (so that\n\ | |
8cae4b3f PA |
2957 | the breakpoint won't break until the Nth time it is reached).\n\ |
2958 | \n\ | |
2959 | If non-stop mode is enabled, continue only the current thread,\n\ | |
2960 | otherwise all the threads in the program are continued. To \n\ | |
2961 | continue all stopped threads in non-stop mode, use the -a option.\n\ | |
2962 | Specifying -a and an ignore count simultaneously is an error.")); | |
c906108c SS |
2963 | add_com_alias ("c", "cont", class_run, 1); |
2964 | add_com_alias ("fg", "cont", class_run, 1); | |
2965 | ||
1bedd215 AC |
2966 | c = add_com ("run", class_run, run_command, _("\ |
2967 | Start debugged program. You may specify arguments to give it.\n\ | |
c906108c | 2968 | Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ |
3e43a32a MS |
2969 | Input and output redirection with \">\", \"<\", or \">>\" are also \ |
2970 | allowed.\n\n\ | |
2971 | With no arguments, uses arguments last specified (with \"run\" \ | |
2972 | or \"set args\").\n\ | |
c906108c | 2973 | To cancel previous arguments and run with no arguments,\n\ |
1bedd215 | 2974 | use \"set args\" without arguments.")); |
5ba2abeb | 2975 | set_cmd_completer (c, filename_completer); |
c906108c SS |
2976 | add_com_alias ("r", "run", class_run, 1); |
2977 | if (xdb_commands) | |
2978 | add_com ("R", class_run, run_no_args_command, | |
1bedd215 | 2979 | _("Start debugged program with no arguments.")); |
c906108c | 2980 | |
1bedd215 | 2981 | c = add_com ("start", class_run, start_command, _("\ |
a4d5f2e0 JB |
2982 | Run the debugged program until the beginning of the main procedure.\n\ |
2983 | You may specify arguments to give to your program, just as with the\n\ | |
1bedd215 | 2984 | \"run\" command.")); |
a4d5f2e0 JB |
2985 | set_cmd_completer (c, filename_completer); |
2986 | ||
df983543 MS |
2987 | add_com ("interrupt", class_run, interrupt_target_command, |
2988 | _("Interrupt the execution of the debugged program.\n\ | |
8cae4b3f PA |
2989 | If non-stop mode is enabled, interrupt only the current thread,\n\ |
2990 | otherwise all the threads in the program are stopped. To \n\ | |
2991 | interrupt all running threads in non-stop mode, use the -a option.")); | |
43ff13b4 | 2992 | |
1bedd215 AC |
2993 | add_info ("registers", nofp_registers_info, _("\ |
2994 | List of integer registers and their contents, for selected stack frame.\n\ | |
2995 | Register name as argument means describe only that register.")); | |
7194c49b | 2996 | add_info_alias ("r", "registers", 1); |
c906108c SS |
2997 | |
2998 | if (xdb_commands) | |
1bedd215 AC |
2999 | add_com ("lr", class_info, nofp_registers_info, _("\ |
3000 | List of integer registers and their contents, for selected stack frame.\n\ | |
3001 | Register name as argument means describe only that register.")); | |
3002 | add_info ("all-registers", all_registers_info, _("\ | |
3003 | List of all registers and their contents, for selected stack frame.\n\ | |
3004 | Register name as argument means describe only that register.")); | |
c906108c SS |
3005 | |
3006 | add_info ("program", program_info, | |
1bedd215 | 3007 | _("Execution status of the program.")); |
c906108c SS |
3008 | |
3009 | add_info ("float", float_info, | |
1bedd215 | 3010 | _("Print the status of the floating point unit\n")); |
c906108c | 3011 | |
e76f1f2e | 3012 | add_info ("vector", vector_info, |
1bedd215 | 3013 | _("Print the status of the vector unit\n")); |
c906108c | 3014 | } |