| 1 | /* Memory-access and commands for "inferior" process, for GDB. |
| 2 | |
| 3 | Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, |
| 4 | 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
| 5 | 2008 Free Software Foundation, Inc. |
| 6 | |
| 7 | This file is part of GDB. |
| 8 | |
| 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 |
| 11 | the Free Software Foundation; either version 3 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 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. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 21 | |
| 22 | #include "defs.h" |
| 23 | #include <signal.h> |
| 24 | #include "gdb_string.h" |
| 25 | #include "symtab.h" |
| 26 | #include "gdbtypes.h" |
| 27 | #include "frame.h" |
| 28 | #include "inferior.h" |
| 29 | #include "environ.h" |
| 30 | #include "value.h" |
| 31 | #include "gdbcmd.h" |
| 32 | #include "symfile.h" |
| 33 | #include "gdbcore.h" |
| 34 | #include "target.h" |
| 35 | #include "language.h" |
| 36 | #include "symfile.h" |
| 37 | #include "objfiles.h" |
| 38 | #include "completer.h" |
| 39 | #include "ui-out.h" |
| 40 | #include "event-top.h" |
| 41 | #include "parser-defs.h" |
| 42 | #include "regcache.h" |
| 43 | #include "reggroups.h" |
| 44 | #include "block.h" |
| 45 | #include "solib.h" |
| 46 | #include <ctype.h> |
| 47 | #include "gdb_assert.h" |
| 48 | #include "observer.h" |
| 49 | #include "target-descriptions.h" |
| 50 | #include "user-regs.h" |
| 51 | #include "exceptions.h" |
| 52 | #include "cli/cli-decode.h" |
| 53 | |
| 54 | /* Functions exported for general use, in inferior.h: */ |
| 55 | |
| 56 | void all_registers_info (char *, int); |
| 57 | |
| 58 | void registers_info (char *, int); |
| 59 | |
| 60 | void nexti_command (char *, int); |
| 61 | |
| 62 | void stepi_command (char *, int); |
| 63 | |
| 64 | void continue_command (char *, int); |
| 65 | |
| 66 | void interrupt_target_command (char *args, int from_tty); |
| 67 | |
| 68 | /* Local functions: */ |
| 69 | |
| 70 | static void nofp_registers_info (char *, int); |
| 71 | |
| 72 | static void print_return_value (struct type *func_type, |
| 73 | struct type *value_type); |
| 74 | |
| 75 | static void finish_command_continuation (struct continuation_arg *, |
| 76 | int error_p); |
| 77 | |
| 78 | static void until_next_command (int); |
| 79 | |
| 80 | static void until_command (char *, int); |
| 81 | |
| 82 | static void path_info (char *, int); |
| 83 | |
| 84 | static void path_command (char *, int); |
| 85 | |
| 86 | static void unset_command (char *, int); |
| 87 | |
| 88 | static void float_info (char *, int); |
| 89 | |
| 90 | static void detach_command (char *, int); |
| 91 | |
| 92 | static void disconnect_command (char *, int); |
| 93 | |
| 94 | static void unset_environment_command (char *, int); |
| 95 | |
| 96 | static void set_environment_command (char *, int); |
| 97 | |
| 98 | static void environment_info (char *, int); |
| 99 | |
| 100 | static void program_info (char *, int); |
| 101 | |
| 102 | static void finish_command (char *, int); |
| 103 | |
| 104 | static void signal_command (char *, int); |
| 105 | |
| 106 | static void jump_command (char *, int); |
| 107 | |
| 108 | static void step_1 (int, int, char *); |
| 109 | static void step_once (int skip_subroutines, int single_inst, int count); |
| 110 | static void step_1_continuation (struct continuation_arg *arg, int error_p); |
| 111 | |
| 112 | static void next_command (char *, int); |
| 113 | |
| 114 | static void step_command (char *, int); |
| 115 | |
| 116 | static void run_command (char *, int); |
| 117 | |
| 118 | static void run_no_args_command (char *args, int from_tty); |
| 119 | |
| 120 | static void go_command (char *line_no, int from_tty); |
| 121 | |
| 122 | static int strip_bg_char (char **); |
| 123 | |
| 124 | void _initialize_infcmd (void); |
| 125 | |
| 126 | #define GO_USAGE "Usage: go <location>\n" |
| 127 | |
| 128 | #define ERROR_NO_INFERIOR \ |
| 129 | if (!target_has_execution) error (_("The program is not being run.")); |
| 130 | |
| 131 | /* String containing arguments to give to the program, separated by spaces. |
| 132 | Empty string (pointer to '\0') means no args. */ |
| 133 | |
| 134 | static char *inferior_args; |
| 135 | |
| 136 | /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero, |
| 137 | then we must compute INFERIOR_ARGS from this (via the target). */ |
| 138 | |
| 139 | static int inferior_argc; |
| 140 | static char **inferior_argv; |
| 141 | |
| 142 | /* File name for default use for standard in/out in the inferior. */ |
| 143 | |
| 144 | static char *inferior_io_terminal; |
| 145 | |
| 146 | /* Pid of our debugged inferior, or 0 if no inferior now. |
| 147 | Since various parts of infrun.c test this to see whether there is a program |
| 148 | being debugged it should be nonzero (currently 3 is used) for remote |
| 149 | debugging. */ |
| 150 | |
| 151 | ptid_t inferior_ptid; |
| 152 | |
| 153 | /* Last signal that the inferior received (why it stopped). */ |
| 154 | |
| 155 | enum target_signal stop_signal; |
| 156 | |
| 157 | /* Address at which inferior stopped. */ |
| 158 | |
| 159 | CORE_ADDR stop_pc; |
| 160 | |
| 161 | /* Chain containing status of breakpoint(s) that we have stopped at. */ |
| 162 | |
| 163 | bpstat stop_bpstat; |
| 164 | |
| 165 | /* Flag indicating that a command has proceeded the inferior past the |
| 166 | current breakpoint. */ |
| 167 | |
| 168 | int breakpoint_proceeded; |
| 169 | |
| 170 | /* Nonzero if stopped due to a step command. */ |
| 171 | |
| 172 | int stop_step; |
| 173 | |
| 174 | /* Nonzero if stopped due to completion of a stack dummy routine. */ |
| 175 | |
| 176 | int stop_stack_dummy; |
| 177 | |
| 178 | /* Nonzero if stopped due to a random (unexpected) signal in inferior |
| 179 | process. */ |
| 180 | |
| 181 | int stopped_by_random_signal; |
| 182 | |
| 183 | /* Range to single step within. |
| 184 | If this is nonzero, respond to a single-step signal |
| 185 | by continuing to step if the pc is in this range. */ |
| 186 | |
| 187 | CORE_ADDR step_range_start; /* Inclusive */ |
| 188 | CORE_ADDR step_range_end; /* Exclusive */ |
| 189 | |
| 190 | /* Stack frame address as of when stepping command was issued. |
| 191 | This is how we know when we step into a subroutine call, |
| 192 | and how to set the frame for the breakpoint used to step out. */ |
| 193 | |
| 194 | struct frame_id step_frame_id; |
| 195 | |
| 196 | enum step_over_calls_kind step_over_calls; |
| 197 | |
| 198 | /* If stepping, nonzero means step count is > 1 |
| 199 | so don't print frame next time inferior stops |
| 200 | if it stops due to stepping. */ |
| 201 | |
| 202 | int step_multi; |
| 203 | |
| 204 | /* Environment to use for running inferior, |
| 205 | in format described in environ.h. */ |
| 206 | |
| 207 | struct gdb_environ *inferior_environ; |
| 208 | \f |
| 209 | /* Accessor routines. */ |
| 210 | |
| 211 | void |
| 212 | set_inferior_io_terminal (const char *terminal_name) |
| 213 | { |
| 214 | if (inferior_io_terminal) |
| 215 | xfree (inferior_io_terminal); |
| 216 | |
| 217 | if (!terminal_name) |
| 218 | inferior_io_terminal = NULL; |
| 219 | else |
| 220 | inferior_io_terminal = savestring (terminal_name, strlen (terminal_name)); |
| 221 | } |
| 222 | |
| 223 | const char * |
| 224 | get_inferior_io_terminal (void) |
| 225 | { |
| 226 | return inferior_io_terminal; |
| 227 | } |
| 228 | |
| 229 | char * |
| 230 | get_inferior_args (void) |
| 231 | { |
| 232 | if (inferior_argc != 0) |
| 233 | { |
| 234 | char *n, *old; |
| 235 | |
| 236 | n = gdbarch_construct_inferior_arguments (current_gdbarch, |
| 237 | inferior_argc, inferior_argv); |
| 238 | old = set_inferior_args (n); |
| 239 | xfree (old); |
| 240 | } |
| 241 | |
| 242 | if (inferior_args == NULL) |
| 243 | inferior_args = xstrdup (""); |
| 244 | |
| 245 | return inferior_args; |
| 246 | } |
| 247 | |
| 248 | char * |
| 249 | set_inferior_args (char *newargs) |
| 250 | { |
| 251 | char *saved_args = inferior_args; |
| 252 | |
| 253 | inferior_args = newargs; |
| 254 | inferior_argc = 0; |
| 255 | inferior_argv = 0; |
| 256 | |
| 257 | return saved_args; |
| 258 | } |
| 259 | |
| 260 | void |
| 261 | set_inferior_args_vector (int argc, char **argv) |
| 262 | { |
| 263 | inferior_argc = argc; |
| 264 | inferior_argv = argv; |
| 265 | } |
| 266 | |
| 267 | /* Notice when `set args' is run. */ |
| 268 | static void |
| 269 | notice_args_set (char *args, int from_tty, struct cmd_list_element *c) |
| 270 | { |
| 271 | inferior_argc = 0; |
| 272 | inferior_argv = 0; |
| 273 | } |
| 274 | |
| 275 | /* Notice when `show args' is run. */ |
| 276 | static void |
| 277 | notice_args_read (struct ui_file *file, int from_tty, |
| 278 | struct cmd_list_element *c, const char *value) |
| 279 | { |
| 280 | /* Note that we ignore the passed-in value in favor of computing it |
| 281 | directly. */ |
| 282 | deprecated_show_value_hack (file, from_tty, c, get_inferior_args ()); |
| 283 | } |
| 284 | |
| 285 | \f |
| 286 | /* Compute command-line string given argument vector. This does the |
| 287 | same shell processing as fork_inferior. */ |
| 288 | char * |
| 289 | construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv) |
| 290 | { |
| 291 | char *result; |
| 292 | |
| 293 | if (STARTUP_WITH_SHELL) |
| 294 | { |
| 295 | /* This holds all the characters considered special to the |
| 296 | typical Unix shells. We include `^' because the SunOS |
| 297 | /bin/sh treats it as a synonym for `|'. */ |
| 298 | char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n"; |
| 299 | int i; |
| 300 | int length = 0; |
| 301 | char *out, *cp; |
| 302 | |
| 303 | /* We over-compute the size. It shouldn't matter. */ |
| 304 | for (i = 0; i < argc; ++i) |
| 305 | length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0'); |
| 306 | |
| 307 | result = (char *) xmalloc (length); |
| 308 | out = result; |
| 309 | |
| 310 | for (i = 0; i < argc; ++i) |
| 311 | { |
| 312 | if (i > 0) |
| 313 | *out++ = ' '; |
| 314 | |
| 315 | /* Need to handle empty arguments specially. */ |
| 316 | if (argv[i][0] == '\0') |
| 317 | { |
| 318 | *out++ = '\''; |
| 319 | *out++ = '\''; |
| 320 | } |
| 321 | else |
| 322 | { |
| 323 | for (cp = argv[i]; *cp; ++cp) |
| 324 | { |
| 325 | if (strchr (special, *cp) != NULL) |
| 326 | *out++ = '\\'; |
| 327 | *out++ = *cp; |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | *out = '\0'; |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | /* In this case we can't handle arguments that contain spaces, |
| 336 | tabs, or newlines -- see breakup_args(). */ |
| 337 | int i; |
| 338 | int length = 0; |
| 339 | |
| 340 | for (i = 0; i < argc; ++i) |
| 341 | { |
| 342 | char *cp = strchr (argv[i], ' '); |
| 343 | if (cp == NULL) |
| 344 | cp = strchr (argv[i], '\t'); |
| 345 | if (cp == NULL) |
| 346 | cp = strchr (argv[i], '\n'); |
| 347 | if (cp != NULL) |
| 348 | error (_("can't handle command-line argument containing whitespace")); |
| 349 | length += strlen (argv[i]) + 1; |
| 350 | } |
| 351 | |
| 352 | result = (char *) xmalloc (length); |
| 353 | result[0] = '\0'; |
| 354 | for (i = 0; i < argc; ++i) |
| 355 | { |
| 356 | if (i > 0) |
| 357 | strcat (result, " "); |
| 358 | strcat (result, argv[i]); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | return result; |
| 363 | } |
| 364 | \f |
| 365 | |
| 366 | /* This function detects whether or not a '&' character (indicating |
| 367 | background execution) has been added as *the last* of the arguments ARGS |
| 368 | of a command. If it has, it removes it and returns 1. Otherwise it |
| 369 | does nothing and returns 0. */ |
| 370 | static int |
| 371 | strip_bg_char (char **args) |
| 372 | { |
| 373 | char *p = NULL; |
| 374 | |
| 375 | p = strchr (*args, '&'); |
| 376 | |
| 377 | if (p) |
| 378 | { |
| 379 | if (p == (*args + strlen (*args) - 1)) |
| 380 | { |
| 381 | if (strlen (*args) > 1) |
| 382 | { |
| 383 | do |
| 384 | p--; |
| 385 | while (*p == ' ' || *p == '\t'); |
| 386 | *(p + 1) = '\0'; |
| 387 | } |
| 388 | else |
| 389 | *args = 0; |
| 390 | return 1; |
| 391 | } |
| 392 | } |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | void |
| 397 | tty_command (char *file, int from_tty) |
| 398 | { |
| 399 | if (file == 0) |
| 400 | error_no_arg (_("terminal name for running target process")); |
| 401 | |
| 402 | set_inferior_io_terminal (file); |
| 403 | } |
| 404 | |
| 405 | /* Common actions to take after creating any sort of inferior, by any |
| 406 | means (running, attaching, connecting, et cetera). The target |
| 407 | should be stopped. */ |
| 408 | |
| 409 | void |
| 410 | post_create_inferior (struct target_ops *target, int from_tty) |
| 411 | { |
| 412 | /* Be sure we own the terminal in case write operations are performed. */ |
| 413 | target_terminal_ours (); |
| 414 | |
| 415 | /* If the target hasn't taken care of this already, do it now. |
| 416 | Targets which need to access registers during to_open, |
| 417 | to_create_inferior, or to_attach should do it earlier; but many |
| 418 | don't need to. */ |
| 419 | target_find_description (); |
| 420 | |
| 421 | if (exec_bfd) |
| 422 | { |
| 423 | /* Sometimes the platform-specific hook loads initial shared |
| 424 | libraries, and sometimes it doesn't. Try to do so first, so |
| 425 | that we can add them with the correct value for FROM_TTY. |
| 426 | If we made all the inferior hook methods consistent, |
| 427 | this call could be removed. */ |
| 428 | #ifdef SOLIB_ADD |
| 429 | SOLIB_ADD (NULL, from_tty, target, auto_solib_add); |
| 430 | #else |
| 431 | solib_add (NULL, from_tty, target, auto_solib_add); |
| 432 | #endif |
| 433 | |
| 434 | /* Create the hooks to handle shared library load and unload |
| 435 | events. */ |
| 436 | #ifdef SOLIB_CREATE_INFERIOR_HOOK |
| 437 | SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); |
| 438 | #else |
| 439 | solib_create_inferior_hook (); |
| 440 | #endif |
| 441 | } |
| 442 | |
| 443 | observer_notify_inferior_created (target, from_tty); |
| 444 | } |
| 445 | |
| 446 | /* Kill the inferior if already running. This function is designed |
| 447 | to be called when we are about to start the execution of the program |
| 448 | from the beginning. Ask the user to confirm that he wants to restart |
| 449 | the program being debugged when FROM_TTY is non-null. */ |
| 450 | |
| 451 | static void |
| 452 | kill_if_already_running (int from_tty) |
| 453 | { |
| 454 | if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) |
| 455 | { |
| 456 | /* Bail out before killing the program if we will not be able to |
| 457 | restart it. */ |
| 458 | target_require_runnable (); |
| 459 | |
| 460 | if (from_tty |
| 461 | && !query ("The program being debugged has been started already.\n\ |
| 462 | Start it from the beginning? ")) |
| 463 | error (_("Program not restarted.")); |
| 464 | target_kill (); |
| 465 | no_shared_libraries (NULL, from_tty); |
| 466 | init_wait_for_inferior (); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert |
| 471 | a temporary breakpoint at the begining of the main program before |
| 472 | running the program. */ |
| 473 | |
| 474 | static void |
| 475 | run_command_1 (char *args, int from_tty, int tbreak_at_main) |
| 476 | { |
| 477 | char *exec_file; |
| 478 | |
| 479 | dont_repeat (); |
| 480 | |
| 481 | kill_if_already_running (from_tty); |
| 482 | clear_breakpoint_hit_counts (); |
| 483 | |
| 484 | /* Clean up any leftovers from other runs. Some other things from |
| 485 | this function should probably be moved into target_pre_inferior. */ |
| 486 | target_pre_inferior (from_tty); |
| 487 | |
| 488 | /* Purge old solib objfiles. */ |
| 489 | objfile_purge_solibs (); |
| 490 | |
| 491 | clear_solib (); |
| 492 | |
| 493 | /* The comment here used to read, "The exec file is re-read every |
| 494 | time we do a generic_mourn_inferior, so we just have to worry |
| 495 | about the symbol file." The `generic_mourn_inferior' function |
| 496 | gets called whenever the program exits. However, suppose the |
| 497 | program exits, and *then* the executable file changes? We need |
| 498 | to check again here. Since reopen_exec_file doesn't do anything |
| 499 | if the timestamp hasn't changed, I don't see the harm. */ |
| 500 | reopen_exec_file (); |
| 501 | reread_symbols (); |
| 502 | |
| 503 | /* Insert the temporary breakpoint if a location was specified. */ |
| 504 | if (tbreak_at_main) |
| 505 | tbreak_command (main_name (), 0); |
| 506 | |
| 507 | exec_file = (char *) get_exec_file (0); |
| 508 | |
| 509 | /* We keep symbols from add-symbol-file, on the grounds that the |
| 510 | user might want to add some symbols before running the program |
| 511 | (right?). But sometimes (dynamic loading where the user manually |
| 512 | introduces the new symbols with add-symbol-file), the code which |
| 513 | the symbols describe does not persist between runs. Currently |
| 514 | the user has to manually nuke all symbols between runs if they |
| 515 | want them to go away (PR 2207). This is probably reasonable. */ |
| 516 | |
| 517 | if (!args) |
| 518 | { |
| 519 | if (target_can_async_p ()) |
| 520 | async_disable_stdin (); |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | int async_exec = strip_bg_char (&args); |
| 525 | |
| 526 | /* If we get a request for running in the bg but the target |
| 527 | doesn't support it, error out. */ |
| 528 | if (async_exec && !target_can_async_p ()) |
| 529 | error (_("Asynchronous execution not supported on this target.")); |
| 530 | |
| 531 | /* If we don't get a request of running in the bg, then we need |
| 532 | to simulate synchronous (fg) execution. */ |
| 533 | if (!async_exec && target_can_async_p ()) |
| 534 | { |
| 535 | /* Simulate synchronous execution */ |
| 536 | async_disable_stdin (); |
| 537 | } |
| 538 | |
| 539 | /* If there were other args, beside '&', process them. */ |
| 540 | if (args) |
| 541 | { |
| 542 | char *old_args = set_inferior_args (xstrdup (args)); |
| 543 | xfree (old_args); |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | if (from_tty) |
| 548 | { |
| 549 | ui_out_field_string (uiout, NULL, "Starting program"); |
| 550 | ui_out_text (uiout, ": "); |
| 551 | if (exec_file) |
| 552 | ui_out_field_string (uiout, "execfile", exec_file); |
| 553 | ui_out_spaces (uiout, 1); |
| 554 | /* We call get_inferior_args() because we might need to compute |
| 555 | the value now. */ |
| 556 | ui_out_field_string (uiout, "infargs", get_inferior_args ()); |
| 557 | ui_out_text (uiout, "\n"); |
| 558 | ui_out_flush (uiout); |
| 559 | } |
| 560 | |
| 561 | /* We call get_inferior_args() because we might need to compute |
| 562 | the value now. */ |
| 563 | target_create_inferior (exec_file, get_inferior_args (), |
| 564 | environ_vector (inferior_environ), from_tty); |
| 565 | |
| 566 | /* Pass zero for FROM_TTY, because at this point the "run" command |
| 567 | has done its thing; now we are setting up the running program. */ |
| 568 | post_create_inferior (¤t_target, 0); |
| 569 | |
| 570 | /* Start the target running. */ |
| 571 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); |
| 572 | } |
| 573 | |
| 574 | |
| 575 | static void |
| 576 | run_command (char *args, int from_tty) |
| 577 | { |
| 578 | run_command_1 (args, from_tty, 0); |
| 579 | } |
| 580 | |
| 581 | static void |
| 582 | run_no_args_command (char *args, int from_tty) |
| 583 | { |
| 584 | char *old_args = set_inferior_args (xstrdup ("")); |
| 585 | xfree (old_args); |
| 586 | } |
| 587 | \f |
| 588 | |
| 589 | /* Start the execution of the program up until the beginning of the main |
| 590 | program. */ |
| 591 | |
| 592 | static void |
| 593 | start_command (char *args, int from_tty) |
| 594 | { |
| 595 | /* Some languages such as Ada need to search inside the program |
| 596 | minimal symbols for the location where to put the temporary |
| 597 | breakpoint before starting. */ |
| 598 | if (!have_minimal_symbols ()) |
| 599 | error (_("No symbol table loaded. Use the \"file\" command.")); |
| 600 | |
| 601 | /* Run the program until reaching the main procedure... */ |
| 602 | run_command_1 (args, from_tty, 1); |
| 603 | } |
| 604 | |
| 605 | void |
| 606 | continue_command (char *proc_count_exp, int from_tty) |
| 607 | { |
| 608 | int async_exec = 0; |
| 609 | ERROR_NO_INFERIOR; |
| 610 | |
| 611 | /* Find out whether we must run in the background. */ |
| 612 | if (proc_count_exp != NULL) |
| 613 | async_exec = strip_bg_char (&proc_count_exp); |
| 614 | |
| 615 | /* If we must run in the background, but the target can't do it, |
| 616 | error out. */ |
| 617 | if (async_exec && !target_can_async_p ()) |
| 618 | error (_("Asynchronous execution not supported on this target.")); |
| 619 | |
| 620 | /* If we are not asked to run in the bg, then prepare to run in the |
| 621 | foreground, synchronously. */ |
| 622 | if (!async_exec && target_can_async_p ()) |
| 623 | { |
| 624 | /* Simulate synchronous execution */ |
| 625 | async_disable_stdin (); |
| 626 | } |
| 627 | |
| 628 | /* If have argument (besides '&'), set proceed count of breakpoint |
| 629 | we stopped at. */ |
| 630 | if (proc_count_exp != NULL) |
| 631 | { |
| 632 | bpstat bs = stop_bpstat; |
| 633 | int num, stat; |
| 634 | int stopped = 0; |
| 635 | |
| 636 | while ((stat = bpstat_num (&bs, &num)) != 0) |
| 637 | if (stat > 0) |
| 638 | { |
| 639 | set_ignore_count (num, |
| 640 | parse_and_eval_long (proc_count_exp) - 1, |
| 641 | from_tty); |
| 642 | /* set_ignore_count prints a message ending with a period. |
| 643 | So print two spaces before "Continuing.". */ |
| 644 | if (from_tty) |
| 645 | printf_filtered (" "); |
| 646 | stopped = 1; |
| 647 | } |
| 648 | |
| 649 | if (!stopped && from_tty) |
| 650 | { |
| 651 | printf_filtered |
| 652 | ("Not stopped at any breakpoint; argument ignored.\n"); |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | if (from_tty) |
| 657 | printf_filtered (_("Continuing.\n")); |
| 658 | |
| 659 | clear_proceed_status (); |
| 660 | |
| 661 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
| 662 | } |
| 663 | \f |
| 664 | /* Step until outside of current statement. */ |
| 665 | |
| 666 | static void |
| 667 | step_command (char *count_string, int from_tty) |
| 668 | { |
| 669 | step_1 (0, 0, count_string); |
| 670 | } |
| 671 | |
| 672 | /* Likewise, but skip over subroutine calls as if single instructions. */ |
| 673 | |
| 674 | static void |
| 675 | next_command (char *count_string, int from_tty) |
| 676 | { |
| 677 | step_1 (1, 0, count_string); |
| 678 | } |
| 679 | |
| 680 | /* Likewise, but step only one instruction. */ |
| 681 | |
| 682 | void |
| 683 | stepi_command (char *count_string, int from_tty) |
| 684 | { |
| 685 | step_1 (0, 1, count_string); |
| 686 | } |
| 687 | |
| 688 | void |
| 689 | nexti_command (char *count_string, int from_tty) |
| 690 | { |
| 691 | step_1 (1, 1, count_string); |
| 692 | } |
| 693 | |
| 694 | static void |
| 695 | disable_longjmp_breakpoint_cleanup (void *ignore) |
| 696 | { |
| 697 | disable_longjmp_breakpoint (); |
| 698 | } |
| 699 | |
| 700 | static void |
| 701 | step_1 (int skip_subroutines, int single_inst, char *count_string) |
| 702 | { |
| 703 | int count = 1; |
| 704 | struct frame_info *frame; |
| 705 | struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); |
| 706 | int async_exec = 0; |
| 707 | |
| 708 | ERROR_NO_INFERIOR; |
| 709 | |
| 710 | if (count_string) |
| 711 | async_exec = strip_bg_char (&count_string); |
| 712 | |
| 713 | /* If we get a request for running in the bg but the target |
| 714 | doesn't support it, error out. */ |
| 715 | if (async_exec && !target_can_async_p ()) |
| 716 | error (_("Asynchronous execution not supported on this target.")); |
| 717 | |
| 718 | /* If we don't get a request of running in the bg, then we need |
| 719 | to simulate synchronous (fg) execution. */ |
| 720 | if (!async_exec && target_can_async_p ()) |
| 721 | { |
| 722 | /* Simulate synchronous execution */ |
| 723 | async_disable_stdin (); |
| 724 | } |
| 725 | |
| 726 | count = count_string ? parse_and_eval_long (count_string) : 1; |
| 727 | |
| 728 | if (!single_inst || skip_subroutines) /* leave si command alone */ |
| 729 | { |
| 730 | enable_longjmp_breakpoint (); |
| 731 | make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/); |
| 732 | } |
| 733 | |
| 734 | /* In synchronous case, all is well, just use the regular for loop. */ |
| 735 | if (!target_can_async_p ()) |
| 736 | { |
| 737 | for (; count > 0; count--) |
| 738 | { |
| 739 | clear_proceed_status (); |
| 740 | |
| 741 | frame = get_current_frame (); |
| 742 | if (!frame) /* Avoid coredump here. Why tho? */ |
| 743 | error (_("No current frame")); |
| 744 | step_frame_id = get_frame_id (frame); |
| 745 | |
| 746 | if (!single_inst) |
| 747 | { |
| 748 | find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); |
| 749 | if (step_range_end == 0) |
| 750 | { |
| 751 | char *name; |
| 752 | if (find_pc_partial_function (stop_pc, &name, &step_range_start, |
| 753 | &step_range_end) == 0) |
| 754 | error (_("Cannot find bounds of current function")); |
| 755 | |
| 756 | target_terminal_ours (); |
| 757 | printf_filtered (_("\ |
| 758 | Single stepping until exit from function %s, \n\ |
| 759 | which has no line number information.\n"), name); |
| 760 | } |
| 761 | } |
| 762 | else |
| 763 | { |
| 764 | /* Say we are stepping, but stop after one insn whatever it does. */ |
| 765 | step_range_start = step_range_end = 1; |
| 766 | if (!skip_subroutines) |
| 767 | /* It is stepi. |
| 768 | Don't step over function calls, not even to functions lacking |
| 769 | line numbers. */ |
| 770 | step_over_calls = STEP_OVER_NONE; |
| 771 | } |
| 772 | |
| 773 | if (skip_subroutines) |
| 774 | step_over_calls = STEP_OVER_ALL; |
| 775 | |
| 776 | step_multi = (count > 1); |
| 777 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
| 778 | |
| 779 | if (!stop_step) |
| 780 | break; |
| 781 | } |
| 782 | |
| 783 | do_cleanups (cleanups); |
| 784 | return; |
| 785 | } |
| 786 | /* In case of asynchronous target things get complicated, do only |
| 787 | one step for now, before returning control to the event loop. Let |
| 788 | the continuation figure out how many other steps we need to do, |
| 789 | and handle them one at the time, through step_once(). */ |
| 790 | else |
| 791 | { |
| 792 | step_once (skip_subroutines, single_inst, count); |
| 793 | /* We are running, and the contination is installed. It will |
| 794 | disable the longjmp breakpoint as appropriate. */ |
| 795 | discard_cleanups (cleanups); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | /* Called after we are done with one step operation, to check whether |
| 800 | we need to step again, before we print the prompt and return control |
| 801 | to the user. If count is > 1, we will need to do one more call to |
| 802 | proceed(), via step_once(). Basically it is like step_once and |
| 803 | step_1_continuation are co-recursive. */ |
| 804 | static void |
| 805 | step_1_continuation (struct continuation_arg *arg, int error_p) |
| 806 | { |
| 807 | int count; |
| 808 | int skip_subroutines; |
| 809 | int single_inst; |
| 810 | |
| 811 | skip_subroutines = arg->data.integer; |
| 812 | single_inst = arg->next->data.integer; |
| 813 | count = arg->next->next->data.integer; |
| 814 | |
| 815 | if (error_p || !step_multi || !stop_step) |
| 816 | { |
| 817 | /* We either hit an error, or stopped for some reason |
| 818 | that is not stepping, or there are no further steps |
| 819 | to make. Cleanup. */ |
| 820 | if (!single_inst || skip_subroutines) |
| 821 | disable_longjmp_breakpoint (); |
| 822 | step_multi = 0; |
| 823 | } |
| 824 | else |
| 825 | step_once (skip_subroutines, single_inst, count - 1); |
| 826 | } |
| 827 | |
| 828 | /* Do just one step operation. If count >1 we will have to set up a |
| 829 | continuation to be done after the target stops (after this one |
| 830 | step). This is useful to implement the 'step n' kind of commands, in |
| 831 | case of asynchronous targets. We had to split step_1 into two parts, |
| 832 | one to be done before proceed() and one afterwards. This function is |
| 833 | called in case of step n with n>1, after the first step operation has |
| 834 | been completed.*/ |
| 835 | static void |
| 836 | step_once (int skip_subroutines, int single_inst, int count) |
| 837 | { |
| 838 | struct continuation_arg *arg1; |
| 839 | struct continuation_arg *arg2; |
| 840 | struct continuation_arg *arg3; |
| 841 | struct frame_info *frame; |
| 842 | |
| 843 | if (count > 0) |
| 844 | { |
| 845 | clear_proceed_status (); |
| 846 | |
| 847 | frame = get_current_frame (); |
| 848 | if (!frame) /* Avoid coredump here. Why tho? */ |
| 849 | error (_("No current frame")); |
| 850 | step_frame_id = get_frame_id (frame); |
| 851 | |
| 852 | if (!single_inst) |
| 853 | { |
| 854 | find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); |
| 855 | |
| 856 | /* If we have no line info, switch to stepi mode. */ |
| 857 | if (step_range_end == 0 && step_stop_if_no_debug) |
| 858 | { |
| 859 | step_range_start = step_range_end = 1; |
| 860 | } |
| 861 | else if (step_range_end == 0) |
| 862 | { |
| 863 | char *name; |
| 864 | if (find_pc_partial_function (stop_pc, &name, &step_range_start, |
| 865 | &step_range_end) == 0) |
| 866 | error (_("Cannot find bounds of current function")); |
| 867 | |
| 868 | target_terminal_ours (); |
| 869 | printf_filtered (_("\ |
| 870 | Single stepping until exit from function %s, \n\ |
| 871 | which has no line number information.\n"), name); |
| 872 | } |
| 873 | } |
| 874 | else |
| 875 | { |
| 876 | /* Say we are stepping, but stop after one insn whatever it does. */ |
| 877 | step_range_start = step_range_end = 1; |
| 878 | if (!skip_subroutines) |
| 879 | /* It is stepi. |
| 880 | Don't step over function calls, not even to functions lacking |
| 881 | line numbers. */ |
| 882 | step_over_calls = STEP_OVER_NONE; |
| 883 | } |
| 884 | |
| 885 | if (skip_subroutines) |
| 886 | step_over_calls = STEP_OVER_ALL; |
| 887 | |
| 888 | step_multi = (count > 1); |
| 889 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
| 890 | arg1 = |
| 891 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 892 | arg2 = |
| 893 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 894 | arg3 = |
| 895 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 896 | arg1->next = arg2; |
| 897 | arg1->data.integer = skip_subroutines; |
| 898 | arg2->next = arg3; |
| 899 | arg2->data.integer = single_inst; |
| 900 | arg3->next = NULL; |
| 901 | arg3->data.integer = count; |
| 902 | add_intermediate_continuation (step_1_continuation, arg1); |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | \f |
| 907 | /* Continue program at specified address. */ |
| 908 | |
| 909 | static void |
| 910 | jump_command (char *arg, int from_tty) |
| 911 | { |
| 912 | CORE_ADDR addr; |
| 913 | struct symtabs_and_lines sals; |
| 914 | struct symtab_and_line sal; |
| 915 | struct symbol *fn; |
| 916 | struct symbol *sfn; |
| 917 | int async_exec = 0; |
| 918 | |
| 919 | ERROR_NO_INFERIOR; |
| 920 | |
| 921 | /* Find out whether we must run in the background. */ |
| 922 | if (arg != NULL) |
| 923 | async_exec = strip_bg_char (&arg); |
| 924 | |
| 925 | /* If we must run in the background, but the target can't do it, |
| 926 | error out. */ |
| 927 | if (async_exec && !target_can_async_p ()) |
| 928 | error (_("Asynchronous execution not supported on this target.")); |
| 929 | |
| 930 | if (!arg) |
| 931 | error_no_arg (_("starting address")); |
| 932 | |
| 933 | sals = decode_line_spec_1 (arg, 1); |
| 934 | if (sals.nelts != 1) |
| 935 | { |
| 936 | error (_("Unreasonable jump request")); |
| 937 | } |
| 938 | |
| 939 | sal = sals.sals[0]; |
| 940 | xfree (sals.sals); |
| 941 | |
| 942 | if (sal.symtab == 0 && sal.pc == 0) |
| 943 | error (_("No source file has been specified.")); |
| 944 | |
| 945 | resolve_sal_pc (&sal); /* May error out */ |
| 946 | |
| 947 | /* See if we are trying to jump to another function. */ |
| 948 | fn = get_frame_function (get_current_frame ()); |
| 949 | sfn = find_pc_function (sal.pc); |
| 950 | if (fn != NULL && sfn != fn) |
| 951 | { |
| 952 | if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, |
| 953 | SYMBOL_PRINT_NAME (fn))) |
| 954 | { |
| 955 | error (_("Not confirmed.")); |
| 956 | /* NOTREACHED */ |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | if (sfn != NULL) |
| 961 | { |
| 962 | fixup_symbol_section (sfn, 0); |
| 963 | if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && |
| 964 | !section_is_mapped (SYMBOL_BFD_SECTION (sfn))) |
| 965 | { |
| 966 | if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")) |
| 967 | { |
| 968 | error (_("Not confirmed.")); |
| 969 | /* NOTREACHED */ |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | addr = sal.pc; |
| 975 | |
| 976 | if (from_tty) |
| 977 | { |
| 978 | printf_filtered (_("Continuing at ")); |
| 979 | fputs_filtered (paddress (addr), gdb_stdout); |
| 980 | printf_filtered (".\n"); |
| 981 | } |
| 982 | |
| 983 | /* If we are not asked to run in the bg, then prepare to run in the |
| 984 | foreground, synchronously. */ |
| 985 | if (!async_exec && target_can_async_p ()) |
| 986 | { |
| 987 | /* Simulate synchronous execution */ |
| 988 | async_disable_stdin (); |
| 989 | } |
| 990 | |
| 991 | clear_proceed_status (); |
| 992 | proceed (addr, TARGET_SIGNAL_0, 0); |
| 993 | } |
| 994 | \f |
| 995 | |
| 996 | /* Go to line or address in current procedure */ |
| 997 | static void |
| 998 | go_command (char *line_no, int from_tty) |
| 999 | { |
| 1000 | if (line_no == (char *) NULL || !*line_no) |
| 1001 | printf_filtered (GO_USAGE); |
| 1002 | else |
| 1003 | { |
| 1004 | tbreak_command (line_no, from_tty); |
| 1005 | jump_command (line_no, from_tty); |
| 1006 | } |
| 1007 | } |
| 1008 | \f |
| 1009 | |
| 1010 | /* Continue program giving it specified signal. */ |
| 1011 | |
| 1012 | static void |
| 1013 | signal_command (char *signum_exp, int from_tty) |
| 1014 | { |
| 1015 | enum target_signal oursig; |
| 1016 | int async_exec = 0; |
| 1017 | |
| 1018 | dont_repeat (); /* Too dangerous. */ |
| 1019 | ERROR_NO_INFERIOR; |
| 1020 | |
| 1021 | /* Find out whether we must run in the background. */ |
| 1022 | if (signum_exp != NULL) |
| 1023 | async_exec = strip_bg_char (&signum_exp); |
| 1024 | |
| 1025 | /* If we must run in the background, but the target can't do it, |
| 1026 | error out. */ |
| 1027 | if (async_exec && !target_can_async_p ()) |
| 1028 | error (_("Asynchronous execution not supported on this target.")); |
| 1029 | |
| 1030 | /* If we are not asked to run in the bg, then prepare to run in the |
| 1031 | foreground, synchronously. */ |
| 1032 | if (!async_exec && target_can_async_p ()) |
| 1033 | { |
| 1034 | /* Simulate synchronous execution. */ |
| 1035 | async_disable_stdin (); |
| 1036 | } |
| 1037 | |
| 1038 | if (!signum_exp) |
| 1039 | error_no_arg (_("signal number")); |
| 1040 | |
| 1041 | /* It would be even slicker to make signal names be valid expressions, |
| 1042 | (the type could be "enum $signal" or some such), then the user could |
| 1043 | assign them to convenience variables. */ |
| 1044 | oursig = target_signal_from_name (signum_exp); |
| 1045 | |
| 1046 | if (oursig == TARGET_SIGNAL_UNKNOWN) |
| 1047 | { |
| 1048 | /* No, try numeric. */ |
| 1049 | int num = parse_and_eval_long (signum_exp); |
| 1050 | |
| 1051 | if (num == 0) |
| 1052 | oursig = TARGET_SIGNAL_0; |
| 1053 | else |
| 1054 | oursig = target_signal_from_command (num); |
| 1055 | } |
| 1056 | |
| 1057 | if (from_tty) |
| 1058 | { |
| 1059 | if (oursig == TARGET_SIGNAL_0) |
| 1060 | printf_filtered (_("Continuing with no signal.\n")); |
| 1061 | else |
| 1062 | printf_filtered (_("Continuing with signal %s.\n"), |
| 1063 | target_signal_to_name (oursig)); |
| 1064 | } |
| 1065 | |
| 1066 | clear_proceed_status (); |
| 1067 | /* "signal 0" should not get stuck if we are stopped at a breakpoint. |
| 1068 | FIXME: Neither should "signal foo" but when I tried passing |
| 1069 | (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't |
| 1070 | tried to track down yet. */ |
| 1071 | proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0); |
| 1072 | } |
| 1073 | |
| 1074 | /* Proceed until we reach a different source line with pc greater than |
| 1075 | our current one or exit the function. We skip calls in both cases. |
| 1076 | |
| 1077 | Note that eventually this command should probably be changed so |
| 1078 | that only source lines are printed out when we hit the breakpoint |
| 1079 | we set. This may involve changes to wait_for_inferior and the |
| 1080 | proceed status code. */ |
| 1081 | |
| 1082 | static void |
| 1083 | until_next_command (int from_tty) |
| 1084 | { |
| 1085 | struct frame_info *frame; |
| 1086 | CORE_ADDR pc; |
| 1087 | struct symbol *func; |
| 1088 | struct symtab_and_line sal; |
| 1089 | |
| 1090 | clear_proceed_status (); |
| 1091 | |
| 1092 | frame = get_current_frame (); |
| 1093 | |
| 1094 | /* Step until either exited from this function or greater |
| 1095 | than the current line (if in symbolic section) or pc (if |
| 1096 | not). */ |
| 1097 | |
| 1098 | pc = read_pc (); |
| 1099 | func = find_pc_function (pc); |
| 1100 | |
| 1101 | if (!func) |
| 1102 | { |
| 1103 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); |
| 1104 | |
| 1105 | if (msymbol == NULL) |
| 1106 | error (_("Execution is not within a known function.")); |
| 1107 | |
| 1108 | step_range_start = SYMBOL_VALUE_ADDRESS (msymbol); |
| 1109 | step_range_end = pc; |
| 1110 | } |
| 1111 | else |
| 1112 | { |
| 1113 | sal = find_pc_line (pc, 0); |
| 1114 | |
| 1115 | step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); |
| 1116 | step_range_end = sal.end; |
| 1117 | } |
| 1118 | |
| 1119 | step_over_calls = STEP_OVER_ALL; |
| 1120 | step_frame_id = get_frame_id (frame); |
| 1121 | |
| 1122 | step_multi = 0; /* Only one call to proceed */ |
| 1123 | |
| 1124 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
| 1125 | } |
| 1126 | |
| 1127 | static void |
| 1128 | until_command (char *arg, int from_tty) |
| 1129 | { |
| 1130 | int async_exec = 0; |
| 1131 | |
| 1132 | if (!target_has_execution) |
| 1133 | error (_("The program is not running.")); |
| 1134 | |
| 1135 | /* Find out whether we must run in the background. */ |
| 1136 | if (arg != NULL) |
| 1137 | async_exec = strip_bg_char (&arg); |
| 1138 | |
| 1139 | /* If we must run in the background, but the target can't do it, |
| 1140 | error out. */ |
| 1141 | if (async_exec && !target_can_async_p ()) |
| 1142 | error (_("Asynchronous execution not supported on this target.")); |
| 1143 | |
| 1144 | /* If we are not asked to run in the bg, then prepare to run in the |
| 1145 | foreground, synchronously. */ |
| 1146 | if (!async_exec && target_can_async_p ()) |
| 1147 | { |
| 1148 | /* Simulate synchronous execution */ |
| 1149 | async_disable_stdin (); |
| 1150 | } |
| 1151 | |
| 1152 | if (arg) |
| 1153 | until_break_command (arg, from_tty, 0); |
| 1154 | else |
| 1155 | until_next_command (from_tty); |
| 1156 | } |
| 1157 | |
| 1158 | static void |
| 1159 | advance_command (char *arg, int from_tty) |
| 1160 | { |
| 1161 | int async_exec = 0; |
| 1162 | |
| 1163 | if (!target_has_execution) |
| 1164 | error (_("The program is not running.")); |
| 1165 | |
| 1166 | if (arg == NULL) |
| 1167 | error_no_arg (_("a location")); |
| 1168 | |
| 1169 | /* Find out whether we must run in the background. */ |
| 1170 | if (arg != NULL) |
| 1171 | async_exec = strip_bg_char (&arg); |
| 1172 | |
| 1173 | /* If we must run in the background, but the target can't do it, |
| 1174 | error out. */ |
| 1175 | if (async_exec && !target_can_async_p ()) |
| 1176 | error (_("Asynchronous execution not supported on this target.")); |
| 1177 | |
| 1178 | /* If we are not asked to run in the bg, then prepare to run in the |
| 1179 | foreground, synchronously. */ |
| 1180 | if (!async_exec && target_can_async_p ()) |
| 1181 | { |
| 1182 | /* Simulate synchronous execution. */ |
| 1183 | async_disable_stdin (); |
| 1184 | } |
| 1185 | |
| 1186 | until_break_command (arg, from_tty, 1); |
| 1187 | } |
| 1188 | \f |
| 1189 | /* Print the result of a function at the end of a 'finish' command. */ |
| 1190 | |
| 1191 | static void |
| 1192 | print_return_value (struct type *func_type, struct type *value_type) |
| 1193 | { |
| 1194 | struct gdbarch *gdbarch = current_gdbarch; |
| 1195 | struct cleanup *old_chain; |
| 1196 | struct ui_stream *stb; |
| 1197 | struct value *value; |
| 1198 | |
| 1199 | CHECK_TYPEDEF (value_type); |
| 1200 | gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID); |
| 1201 | |
| 1202 | /* FIXME: 2003-09-27: When returning from a nested inferior function |
| 1203 | call, it's possible (with no help from the architecture vector) |
| 1204 | to locate and return/print a "struct return" value. This is just |
| 1205 | a more complicated case of what is already being done in in the |
| 1206 | inferior function call code. In fact, when inferior function |
| 1207 | calls are made async, this will likely be made the norm. */ |
| 1208 | |
| 1209 | switch (gdbarch_return_value (gdbarch, func_type, value_type, |
| 1210 | NULL, NULL, NULL)) |
| 1211 | { |
| 1212 | case RETURN_VALUE_REGISTER_CONVENTION: |
| 1213 | case RETURN_VALUE_ABI_RETURNS_ADDRESS: |
| 1214 | case RETURN_VALUE_ABI_PRESERVES_ADDRESS: |
| 1215 | value = allocate_value (value_type); |
| 1216 | gdbarch_return_value (gdbarch, func_type, value_type, stop_registers, |
| 1217 | value_contents_raw (value), NULL); |
| 1218 | break; |
| 1219 | case RETURN_VALUE_STRUCT_CONVENTION: |
| 1220 | value = NULL; |
| 1221 | break; |
| 1222 | default: |
| 1223 | internal_error (__FILE__, __LINE__, _("bad switch")); |
| 1224 | } |
| 1225 | |
| 1226 | if (value) |
| 1227 | { |
| 1228 | /* Print it. */ |
| 1229 | stb = ui_out_stream_new (uiout); |
| 1230 | old_chain = make_cleanup_ui_out_stream_delete (stb); |
| 1231 | ui_out_text (uiout, "Value returned is "); |
| 1232 | ui_out_field_fmt (uiout, "gdb-result-var", "$%d", |
| 1233 | record_latest_value (value)); |
| 1234 | ui_out_text (uiout, " = "); |
| 1235 | value_print (value, stb->stream, 0, Val_no_prettyprint); |
| 1236 | ui_out_field_stream (uiout, "return-value", stb); |
| 1237 | ui_out_text (uiout, "\n"); |
| 1238 | do_cleanups (old_chain); |
| 1239 | } |
| 1240 | else |
| 1241 | { |
| 1242 | ui_out_text (uiout, "Value returned has type: "); |
| 1243 | ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type)); |
| 1244 | ui_out_text (uiout, "."); |
| 1245 | ui_out_text (uiout, " Cannot determine contents\n"); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | /* Stuff that needs to be done by the finish command after the target |
| 1250 | has stopped. In asynchronous mode, we wait for the target to stop |
| 1251 | in the call to poll or select in the event loop, so it is |
| 1252 | impossible to do all the stuff as part of the finish_command |
| 1253 | function itself. The only chance we have to complete this command |
| 1254 | is in fetch_inferior_event, which is called by the event loop as |
| 1255 | soon as it detects that the target has stopped. This function is |
| 1256 | called via the cmd_continuation pointer. */ |
| 1257 | |
| 1258 | static void |
| 1259 | finish_command_continuation (struct continuation_arg *arg, int error_p) |
| 1260 | { |
| 1261 | struct symbol *function; |
| 1262 | struct breakpoint *breakpoint; |
| 1263 | struct cleanup *cleanups; |
| 1264 | |
| 1265 | breakpoint = (struct breakpoint *) arg->data.pointer; |
| 1266 | function = (struct symbol *) arg->next->data.pointer; |
| 1267 | cleanups = (struct cleanup *) arg->next->next->data.pointer; |
| 1268 | |
| 1269 | if (!error_p) |
| 1270 | { |
| 1271 | if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL |
| 1272 | && function != NULL) |
| 1273 | { |
| 1274 | struct type *value_type; |
| 1275 | |
| 1276 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); |
| 1277 | if (!value_type) |
| 1278 | internal_error (__FILE__, __LINE__, |
| 1279 | _("finish_command: function has no target type")); |
| 1280 | |
| 1281 | if (TYPE_CODE (value_type) != TYPE_CODE_VOID) |
| 1282 | print_return_value (SYMBOL_TYPE (function), value_type); |
| 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | delete_breakpoint (breakpoint); |
| 1287 | } |
| 1288 | |
| 1289 | /* "finish": Set a temporary breakpoint at the place the selected |
| 1290 | frame will return to, then continue. */ |
| 1291 | |
| 1292 | static void |
| 1293 | finish_command (char *arg, int from_tty) |
| 1294 | { |
| 1295 | struct symtab_and_line sal; |
| 1296 | struct frame_info *frame; |
| 1297 | struct symbol *function; |
| 1298 | struct breakpoint *breakpoint; |
| 1299 | struct cleanup *old_chain; |
| 1300 | struct continuation_arg *arg1, *arg2, *arg3; |
| 1301 | |
| 1302 | int async_exec = 0; |
| 1303 | |
| 1304 | /* Find out whether we must run in the background. */ |
| 1305 | if (arg != NULL) |
| 1306 | async_exec = strip_bg_char (&arg); |
| 1307 | |
| 1308 | /* If we must run in the background, but the target can't do it, |
| 1309 | error out. */ |
| 1310 | if (async_exec && !target_can_async_p ()) |
| 1311 | error (_("Asynchronous execution not supported on this target.")); |
| 1312 | |
| 1313 | /* If we are not asked to run in the bg, then prepare to run in the |
| 1314 | foreground, synchronously. */ |
| 1315 | if (!async_exec && target_can_async_p ()) |
| 1316 | { |
| 1317 | /* Simulate synchronous execution. */ |
| 1318 | async_disable_stdin (); |
| 1319 | } |
| 1320 | |
| 1321 | if (arg) |
| 1322 | error (_("The \"finish\" command does not take any arguments.")); |
| 1323 | if (!target_has_execution) |
| 1324 | error (_("The program is not running.")); |
| 1325 | |
| 1326 | frame = get_prev_frame (get_selected_frame (_("No selected frame."))); |
| 1327 | if (frame == 0) |
| 1328 | error (_("\"finish\" not meaningful in the outermost frame.")); |
| 1329 | |
| 1330 | clear_proceed_status (); |
| 1331 | |
| 1332 | sal = find_pc_line (get_frame_pc (frame), 0); |
| 1333 | sal.pc = get_frame_pc (frame); |
| 1334 | |
| 1335 | breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish); |
| 1336 | |
| 1337 | old_chain = make_cleanup_delete_breakpoint (breakpoint); |
| 1338 | |
| 1339 | /* Find the function we will return from. */ |
| 1340 | |
| 1341 | function = find_pc_function (get_frame_pc (get_selected_frame (NULL))); |
| 1342 | |
| 1343 | /* Print info on the selected frame, including level number but not |
| 1344 | source. */ |
| 1345 | if (from_tty) |
| 1346 | { |
| 1347 | printf_filtered (_("Run till exit from ")); |
| 1348 | print_stack_frame (get_selected_frame (NULL), 1, LOCATION); |
| 1349 | } |
| 1350 | |
| 1351 | proceed_to_finish = 1; /* We want stop_registers, please... */ |
| 1352 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
| 1353 | |
| 1354 | arg1 = |
| 1355 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 1356 | arg2 = |
| 1357 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 1358 | arg3 = |
| 1359 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 1360 | arg1->next = arg2; |
| 1361 | arg2->next = arg3; |
| 1362 | arg3->next = NULL; |
| 1363 | arg1->data.pointer = breakpoint; |
| 1364 | arg2->data.pointer = function; |
| 1365 | arg3->data.pointer = old_chain; |
| 1366 | add_continuation (finish_command_continuation, arg1); |
| 1367 | |
| 1368 | /* Do this only if not running asynchronously or if the target |
| 1369 | cannot do async execution. Otherwise, complete this command when |
| 1370 | the target actually stops, in fetch_inferior_event. */ |
| 1371 | discard_cleanups (old_chain); |
| 1372 | if (!target_can_async_p ()) |
| 1373 | do_all_continuations (0); |
| 1374 | } |
| 1375 | \f |
| 1376 | |
| 1377 | static void |
| 1378 | program_info (char *args, int from_tty) |
| 1379 | { |
| 1380 | bpstat bs = stop_bpstat; |
| 1381 | int num; |
| 1382 | int stat = bpstat_num (&bs, &num); |
| 1383 | |
| 1384 | if (!target_has_execution) |
| 1385 | { |
| 1386 | printf_filtered (_("The program being debugged is not being run.\n")); |
| 1387 | return; |
| 1388 | } |
| 1389 | |
| 1390 | target_files_info (); |
| 1391 | printf_filtered (_("Program stopped at %s.\n"), |
| 1392 | hex_string ((unsigned long) stop_pc)); |
| 1393 | if (stop_step) |
| 1394 | printf_filtered (_("It stopped after being stepped.\n")); |
| 1395 | else if (stat != 0) |
| 1396 | { |
| 1397 | /* There may be several breakpoints in the same place, so this |
| 1398 | isn't as strange as it seems. */ |
| 1399 | while (stat != 0) |
| 1400 | { |
| 1401 | if (stat < 0) |
| 1402 | { |
| 1403 | printf_filtered (_("\ |
| 1404 | It stopped at a breakpoint that has since been deleted.\n")); |
| 1405 | } |
| 1406 | else |
| 1407 | printf_filtered (_("It stopped at breakpoint %d.\n"), num); |
| 1408 | stat = bpstat_num (&bs, &num); |
| 1409 | } |
| 1410 | } |
| 1411 | else if (stop_signal != TARGET_SIGNAL_0) |
| 1412 | { |
| 1413 | printf_filtered (_("It stopped with signal %s, %s.\n"), |
| 1414 | target_signal_to_name (stop_signal), |
| 1415 | target_signal_to_string (stop_signal)); |
| 1416 | } |
| 1417 | |
| 1418 | if (!from_tty) |
| 1419 | { |
| 1420 | printf_filtered (_("\ |
| 1421 | Type \"info stack\" or \"info registers\" for more information.\n")); |
| 1422 | } |
| 1423 | } |
| 1424 | \f |
| 1425 | static void |
| 1426 | environment_info (char *var, int from_tty) |
| 1427 | { |
| 1428 | if (var) |
| 1429 | { |
| 1430 | char *val = get_in_environ (inferior_environ, var); |
| 1431 | if (val) |
| 1432 | { |
| 1433 | puts_filtered (var); |
| 1434 | puts_filtered (" = "); |
| 1435 | puts_filtered (val); |
| 1436 | puts_filtered ("\n"); |
| 1437 | } |
| 1438 | else |
| 1439 | { |
| 1440 | puts_filtered ("Environment variable \""); |
| 1441 | puts_filtered (var); |
| 1442 | puts_filtered ("\" not defined.\n"); |
| 1443 | } |
| 1444 | } |
| 1445 | else |
| 1446 | { |
| 1447 | char **vector = environ_vector (inferior_environ); |
| 1448 | while (*vector) |
| 1449 | { |
| 1450 | puts_filtered (*vector++); |
| 1451 | puts_filtered ("\n"); |
| 1452 | } |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | static void |
| 1457 | set_environment_command (char *arg, int from_tty) |
| 1458 | { |
| 1459 | char *p, *val, *var; |
| 1460 | int nullset = 0; |
| 1461 | |
| 1462 | if (arg == 0) |
| 1463 | error_no_arg (_("environment variable and value")); |
| 1464 | |
| 1465 | /* Find seperation between variable name and value */ |
| 1466 | p = (char *) strchr (arg, '='); |
| 1467 | val = (char *) strchr (arg, ' '); |
| 1468 | |
| 1469 | if (p != 0 && val != 0) |
| 1470 | { |
| 1471 | /* We have both a space and an equals. If the space is before the |
| 1472 | equals, walk forward over the spaces til we see a nonspace |
| 1473 | (possibly the equals). */ |
| 1474 | if (p > val) |
| 1475 | while (*val == ' ') |
| 1476 | val++; |
| 1477 | |
| 1478 | /* Now if the = is after the char following the spaces, |
| 1479 | take the char following the spaces. */ |
| 1480 | if (p > val) |
| 1481 | p = val - 1; |
| 1482 | } |
| 1483 | else if (val != 0 && p == 0) |
| 1484 | p = val; |
| 1485 | |
| 1486 | if (p == arg) |
| 1487 | error_no_arg (_("environment variable to set")); |
| 1488 | |
| 1489 | if (p == 0 || p[1] == 0) |
| 1490 | { |
| 1491 | nullset = 1; |
| 1492 | if (p == 0) |
| 1493 | p = arg + strlen (arg); /* So that savestring below will work */ |
| 1494 | } |
| 1495 | else |
| 1496 | { |
| 1497 | /* Not setting variable value to null */ |
| 1498 | val = p + 1; |
| 1499 | while (*val == ' ' || *val == '\t') |
| 1500 | val++; |
| 1501 | } |
| 1502 | |
| 1503 | while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) |
| 1504 | p--; |
| 1505 | |
| 1506 | var = savestring (arg, p - arg); |
| 1507 | if (nullset) |
| 1508 | { |
| 1509 | printf_filtered (_("\ |
| 1510 | Setting environment variable \"%s\" to null value.\n"), |
| 1511 | var); |
| 1512 | set_in_environ (inferior_environ, var, ""); |
| 1513 | } |
| 1514 | else |
| 1515 | set_in_environ (inferior_environ, var, val); |
| 1516 | xfree (var); |
| 1517 | } |
| 1518 | |
| 1519 | static void |
| 1520 | unset_environment_command (char *var, int from_tty) |
| 1521 | { |
| 1522 | if (var == 0) |
| 1523 | { |
| 1524 | /* If there is no argument, delete all environment variables. |
| 1525 | Ask for confirmation if reading from the terminal. */ |
| 1526 | if (!from_tty || query (_("Delete all environment variables? "))) |
| 1527 | { |
| 1528 | free_environ (inferior_environ); |
| 1529 | inferior_environ = make_environ (); |
| 1530 | } |
| 1531 | } |
| 1532 | else |
| 1533 | unset_in_environ (inferior_environ, var); |
| 1534 | } |
| 1535 | |
| 1536 | /* Handle the execution path (PATH variable) */ |
| 1537 | |
| 1538 | static const char path_var_name[] = "PATH"; |
| 1539 | |
| 1540 | static void |
| 1541 | path_info (char *args, int from_tty) |
| 1542 | { |
| 1543 | puts_filtered ("Executable and object file path: "); |
| 1544 | puts_filtered (get_in_environ (inferior_environ, path_var_name)); |
| 1545 | puts_filtered ("\n"); |
| 1546 | } |
| 1547 | |
| 1548 | /* Add zero or more directories to the front of the execution path. */ |
| 1549 | |
| 1550 | static void |
| 1551 | path_command (char *dirname, int from_tty) |
| 1552 | { |
| 1553 | char *exec_path; |
| 1554 | char *env; |
| 1555 | dont_repeat (); |
| 1556 | env = get_in_environ (inferior_environ, path_var_name); |
| 1557 | /* Can be null if path is not set */ |
| 1558 | if (!env) |
| 1559 | env = ""; |
| 1560 | exec_path = xstrdup (env); |
| 1561 | mod_path (dirname, &exec_path); |
| 1562 | set_in_environ (inferior_environ, path_var_name, exec_path); |
| 1563 | xfree (exec_path); |
| 1564 | if (from_tty) |
| 1565 | path_info ((char *) NULL, from_tty); |
| 1566 | } |
| 1567 | \f |
| 1568 | |
| 1569 | /* Print out the machine register regnum. If regnum is -1, print all |
| 1570 | registers (print_all == 1) or all non-float and non-vector |
| 1571 | registers (print_all == 0). |
| 1572 | |
| 1573 | For most machines, having all_registers_info() print the |
| 1574 | register(s) one per line is good enough. If a different format is |
| 1575 | required, (eg, for MIPS or Pyramid 90x, which both have lots of |
| 1576 | regs), or there is an existing convention for showing all the |
| 1577 | registers, define the architecture method PRINT_REGISTERS_INFO to |
| 1578 | provide that format. */ |
| 1579 | |
| 1580 | void |
| 1581 | default_print_registers_info (struct gdbarch *gdbarch, |
| 1582 | struct ui_file *file, |
| 1583 | struct frame_info *frame, |
| 1584 | int regnum, int print_all) |
| 1585 | { |
| 1586 | int i; |
| 1587 | const int numregs = gdbarch_num_regs (gdbarch) |
| 1588 | + gdbarch_num_pseudo_regs (gdbarch); |
| 1589 | gdb_byte buffer[MAX_REGISTER_SIZE]; |
| 1590 | |
| 1591 | for (i = 0; i < numregs; i++) |
| 1592 | { |
| 1593 | /* Decide between printing all regs, non-float / vector regs, or |
| 1594 | specific reg. */ |
| 1595 | if (regnum == -1) |
| 1596 | { |
| 1597 | if (print_all) |
| 1598 | { |
| 1599 | if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup)) |
| 1600 | continue; |
| 1601 | } |
| 1602 | else |
| 1603 | { |
| 1604 | if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup)) |
| 1605 | continue; |
| 1606 | } |
| 1607 | } |
| 1608 | else |
| 1609 | { |
| 1610 | if (i != regnum) |
| 1611 | continue; |
| 1612 | } |
| 1613 | |
| 1614 | /* If the register name is empty, it is undefined for this |
| 1615 | processor, so don't display anything. */ |
| 1616 | if (gdbarch_register_name (gdbarch, i) == NULL |
| 1617 | || *(gdbarch_register_name (gdbarch, i)) == '\0') |
| 1618 | continue; |
| 1619 | |
| 1620 | fputs_filtered (gdbarch_register_name (gdbarch, i), file); |
| 1621 | print_spaces_filtered (15 - strlen (gdbarch_register_name |
| 1622 | (gdbarch, i)), file); |
| 1623 | |
| 1624 | /* Get the data in raw format. */ |
| 1625 | if (! frame_register_read (frame, i, buffer)) |
| 1626 | { |
| 1627 | fprintf_filtered (file, "*value not available*\n"); |
| 1628 | continue; |
| 1629 | } |
| 1630 | |
| 1631 | /* If virtual format is floating, print it that way, and in raw |
| 1632 | hex. */ |
| 1633 | if (TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_FLT |
| 1634 | || TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT) |
| 1635 | { |
| 1636 | int j; |
| 1637 | |
| 1638 | val_print (register_type (gdbarch, i), buffer, 0, 0, |
| 1639 | file, 0, 1, 0, Val_pretty_default); |
| 1640 | |
| 1641 | fprintf_filtered (file, "\t(raw 0x"); |
| 1642 | for (j = 0; j < register_size (gdbarch, i); j++) |
| 1643 | { |
| 1644 | int idx; |
| 1645 | if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) |
| 1646 | idx = j; |
| 1647 | else |
| 1648 | idx = register_size (gdbarch, i) - 1 - j; |
| 1649 | fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]); |
| 1650 | } |
| 1651 | fprintf_filtered (file, ")"); |
| 1652 | } |
| 1653 | else |
| 1654 | { |
| 1655 | /* Print the register in hex. */ |
| 1656 | val_print (register_type (gdbarch, i), buffer, 0, 0, |
| 1657 | file, 'x', 1, 0, Val_pretty_default); |
| 1658 | /* If not a vector register, print it also according to its |
| 1659 | natural format. */ |
| 1660 | if (TYPE_VECTOR (register_type (gdbarch, i)) == 0) |
| 1661 | { |
| 1662 | fprintf_filtered (file, "\t"); |
| 1663 | val_print (register_type (gdbarch, i), buffer, 0, 0, |
| 1664 | file, 0, 1, 0, Val_pretty_default); |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | fprintf_filtered (file, "\n"); |
| 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | void |
| 1673 | registers_info (char *addr_exp, int fpregs) |
| 1674 | { |
| 1675 | struct frame_info *frame; |
| 1676 | struct gdbarch *gdbarch; |
| 1677 | int regnum, numregs; |
| 1678 | char *end; |
| 1679 | |
| 1680 | if (!target_has_registers) |
| 1681 | error (_("The program has no registers now.")); |
| 1682 | frame = get_selected_frame (NULL); |
| 1683 | gdbarch = get_frame_arch (frame); |
| 1684 | |
| 1685 | if (!addr_exp) |
| 1686 | { |
| 1687 | gdbarch_print_registers_info (gdbarch, gdb_stdout, |
| 1688 | frame, -1, fpregs); |
| 1689 | return; |
| 1690 | } |
| 1691 | |
| 1692 | while (*addr_exp != '\0') |
| 1693 | { |
| 1694 | char *start; |
| 1695 | const char *end; |
| 1696 | |
| 1697 | /* Keep skipping leading white space. */ |
| 1698 | if (isspace ((*addr_exp))) |
| 1699 | { |
| 1700 | addr_exp++; |
| 1701 | continue; |
| 1702 | } |
| 1703 | |
| 1704 | /* Discard any leading ``$''. Check that there is something |
| 1705 | resembling a register following it. */ |
| 1706 | if (addr_exp[0] == '$') |
| 1707 | addr_exp++; |
| 1708 | if (isspace ((*addr_exp)) || (*addr_exp) == '\0') |
| 1709 | error (_("Missing register name")); |
| 1710 | |
| 1711 | /* Find the start/end of this register name/num/group. */ |
| 1712 | start = addr_exp; |
| 1713 | while ((*addr_exp) != '\0' && !isspace ((*addr_exp))) |
| 1714 | addr_exp++; |
| 1715 | end = addr_exp; |
| 1716 | |
| 1717 | /* Figure out what we've found and display it. */ |
| 1718 | |
| 1719 | /* A register name? */ |
| 1720 | { |
| 1721 | int regnum = frame_map_name_to_regnum (frame, start, end - start); |
| 1722 | if (regnum >= 0) |
| 1723 | { |
| 1724 | /* User registers lie completely outside of the range of |
| 1725 | normal registers. Catch them early so that the target |
| 1726 | never sees them. */ |
| 1727 | if (regnum >= gdbarch_num_regs (gdbarch) |
| 1728 | + gdbarch_num_pseudo_regs (gdbarch)) |
| 1729 | { |
| 1730 | struct value *val = value_of_user_reg (regnum, frame); |
| 1731 | |
| 1732 | printf_filtered ("%s: ", start); |
| 1733 | print_scalar_formatted (value_contents (val), |
| 1734 | check_typedef (value_type (val)), |
| 1735 | 'x', 0, gdb_stdout); |
| 1736 | printf_filtered ("\n"); |
| 1737 | } |
| 1738 | else |
| 1739 | gdbarch_print_registers_info (gdbarch, gdb_stdout, |
| 1740 | frame, regnum, fpregs); |
| 1741 | continue; |
| 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | /* A register number? (how portable is this one?). */ |
| 1746 | { |
| 1747 | char *endptr; |
| 1748 | int regnum = strtol (start, &endptr, 0); |
| 1749 | if (endptr == end |
| 1750 | && regnum >= 0 |
| 1751 | && regnum < gdbarch_num_regs (gdbarch) |
| 1752 | + gdbarch_num_pseudo_regs (gdbarch)) |
| 1753 | { |
| 1754 | gdbarch_print_registers_info (gdbarch, gdb_stdout, |
| 1755 | frame, regnum, fpregs); |
| 1756 | continue; |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | /* A register group? */ |
| 1761 | { |
| 1762 | struct reggroup *group; |
| 1763 | for (group = reggroup_next (gdbarch, NULL); |
| 1764 | group != NULL; |
| 1765 | group = reggroup_next (gdbarch, group)) |
| 1766 | { |
| 1767 | /* Don't bother with a length check. Should the user |
| 1768 | enter a short register group name, go with the first |
| 1769 | group that matches. */ |
| 1770 | if (strncmp (start, reggroup_name (group), end - start) == 0) |
| 1771 | break; |
| 1772 | } |
| 1773 | if (group != NULL) |
| 1774 | { |
| 1775 | int regnum; |
| 1776 | for (regnum = 0; |
| 1777 | regnum < gdbarch_num_regs (gdbarch) |
| 1778 | + gdbarch_num_pseudo_regs (gdbarch); |
| 1779 | regnum++) |
| 1780 | { |
| 1781 | if (gdbarch_register_reggroup_p (gdbarch, regnum, group)) |
| 1782 | gdbarch_print_registers_info (gdbarch, |
| 1783 | gdb_stdout, frame, |
| 1784 | regnum, fpregs); |
| 1785 | } |
| 1786 | continue; |
| 1787 | } |
| 1788 | } |
| 1789 | |
| 1790 | /* Nothing matched. */ |
| 1791 | error (_("Invalid register `%.*s'"), (int) (end - start), start); |
| 1792 | } |
| 1793 | } |
| 1794 | |
| 1795 | void |
| 1796 | all_registers_info (char *addr_exp, int from_tty) |
| 1797 | { |
| 1798 | registers_info (addr_exp, 1); |
| 1799 | } |
| 1800 | |
| 1801 | static void |
| 1802 | nofp_registers_info (char *addr_exp, int from_tty) |
| 1803 | { |
| 1804 | registers_info (addr_exp, 0); |
| 1805 | } |
| 1806 | |
| 1807 | static void |
| 1808 | print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, |
| 1809 | struct frame_info *frame, const char *args) |
| 1810 | { |
| 1811 | if (gdbarch_print_vector_info_p (gdbarch)) |
| 1812 | gdbarch_print_vector_info (gdbarch, file, frame, args); |
| 1813 | else |
| 1814 | { |
| 1815 | int regnum; |
| 1816 | int printed_something = 0; |
| 1817 | |
| 1818 | for (regnum = 0; |
| 1819 | regnum < gdbarch_num_regs (gdbarch) |
| 1820 | + gdbarch_num_pseudo_regs (gdbarch); |
| 1821 | regnum++) |
| 1822 | { |
| 1823 | if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup)) |
| 1824 | { |
| 1825 | printed_something = 1; |
| 1826 | gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); |
| 1827 | } |
| 1828 | } |
| 1829 | if (!printed_something) |
| 1830 | fprintf_filtered (file, "No vector information\n"); |
| 1831 | } |
| 1832 | } |
| 1833 | |
| 1834 | static void |
| 1835 | vector_info (char *args, int from_tty) |
| 1836 | { |
| 1837 | if (!target_has_registers) |
| 1838 | error (_("The program has no registers now.")); |
| 1839 | |
| 1840 | print_vector_info (current_gdbarch, gdb_stdout, |
| 1841 | get_selected_frame (NULL), args); |
| 1842 | } |
| 1843 | \f |
| 1844 | |
| 1845 | /* |
| 1846 | * TODO: |
| 1847 | * Should save/restore the tty state since it might be that the |
| 1848 | * program to be debugged was started on this tty and it wants |
| 1849 | * the tty in some state other than what we want. If it's running |
| 1850 | * on another terminal or without a terminal, then saving and |
| 1851 | * restoring the tty state is a harmless no-op. |
| 1852 | * This only needs to be done if we are attaching to a process. |
| 1853 | */ |
| 1854 | |
| 1855 | /* |
| 1856 | attach_command -- |
| 1857 | takes a program started up outside of gdb and ``attaches'' to it. |
| 1858 | This stops it cold in its tracks and allows us to start debugging it. |
| 1859 | and wait for the trace-trap that results from attaching. */ |
| 1860 | |
| 1861 | static void |
| 1862 | attach_command_post_wait (char *args, int from_tty, int async_exec) |
| 1863 | { |
| 1864 | char *exec_file; |
| 1865 | char *full_exec_path = NULL; |
| 1866 | |
| 1867 | stop_soon = NO_STOP_QUIETLY; |
| 1868 | |
| 1869 | /* If no exec file is yet known, try to determine it from the |
| 1870 | process itself. */ |
| 1871 | exec_file = (char *) get_exec_file (0); |
| 1872 | if (!exec_file) |
| 1873 | { |
| 1874 | exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid)); |
| 1875 | if (exec_file) |
| 1876 | { |
| 1877 | /* It's possible we don't have a full path, but rather just a |
| 1878 | filename. Some targets, such as HP-UX, don't provide the |
| 1879 | full path, sigh. |
| 1880 | |
| 1881 | Attempt to qualify the filename against the source path. |
| 1882 | (If that fails, we'll just fall back on the original |
| 1883 | filename. Not much more we can do...) |
| 1884 | */ |
| 1885 | if (!source_full_path_of (exec_file, &full_exec_path)) |
| 1886 | full_exec_path = savestring (exec_file, strlen (exec_file)); |
| 1887 | |
| 1888 | exec_file_attach (full_exec_path, from_tty); |
| 1889 | symbol_file_add_main (full_exec_path, from_tty); |
| 1890 | } |
| 1891 | } |
| 1892 | else |
| 1893 | { |
| 1894 | reopen_exec_file (); |
| 1895 | reread_symbols (); |
| 1896 | } |
| 1897 | |
| 1898 | /* Take any necessary post-attaching actions for this platform. */ |
| 1899 | target_post_attach (PIDGET (inferior_ptid)); |
| 1900 | |
| 1901 | post_create_inferior (¤t_target, from_tty); |
| 1902 | |
| 1903 | /* Install inferior's terminal modes. */ |
| 1904 | target_terminal_inferior (); |
| 1905 | |
| 1906 | if (async_exec) |
| 1907 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); |
| 1908 | else |
| 1909 | { |
| 1910 | if (target_can_async_p ()) |
| 1911 | async_enable_stdin (); |
| 1912 | normal_stop (); |
| 1913 | if (deprecated_attach_hook) |
| 1914 | deprecated_attach_hook (); |
| 1915 | } |
| 1916 | } |
| 1917 | |
| 1918 | static void |
| 1919 | attach_command_continuation (struct continuation_arg *arg, int error_p) |
| 1920 | { |
| 1921 | char *args; |
| 1922 | int from_tty; |
| 1923 | int async_exec; |
| 1924 | |
| 1925 | args = (char *) arg->data.pointer; |
| 1926 | from_tty = arg->next->data.integer; |
| 1927 | async_exec = arg->next->next->data.integer; |
| 1928 | |
| 1929 | attach_command_post_wait (args, from_tty, async_exec); |
| 1930 | } |
| 1931 | |
| 1932 | void |
| 1933 | attach_command (char *args, int from_tty) |
| 1934 | { |
| 1935 | char *exec_file; |
| 1936 | char *full_exec_path = NULL; |
| 1937 | int async_exec = 0; |
| 1938 | |
| 1939 | dont_repeat (); /* Not for the faint of heart */ |
| 1940 | |
| 1941 | if (target_has_execution) |
| 1942 | { |
| 1943 | if (query ("A program is being debugged already. Kill it? ")) |
| 1944 | target_kill (); |
| 1945 | else |
| 1946 | error (_("Not killed.")); |
| 1947 | } |
| 1948 | |
| 1949 | /* Clean up any leftovers from other runs. Some other things from |
| 1950 | this function should probably be moved into target_pre_inferior. */ |
| 1951 | target_pre_inferior (from_tty); |
| 1952 | |
| 1953 | /* Clear out solib state. Otherwise the solib state of the previous |
| 1954 | inferior might have survived and is entirely wrong for the new |
| 1955 | target. This has been observed on GNU/Linux using glibc 2.3. How |
| 1956 | to reproduce: |
| 1957 | |
| 1958 | bash$ ./foo& |
| 1959 | [1] 4711 |
| 1960 | bash$ ./foo& |
| 1961 | [1] 4712 |
| 1962 | bash$ gdb ./foo |
| 1963 | [...] |
| 1964 | (gdb) attach 4711 |
| 1965 | (gdb) detach |
| 1966 | (gdb) attach 4712 |
| 1967 | Cannot access memory at address 0xdeadbeef |
| 1968 | */ |
| 1969 | clear_solib (); |
| 1970 | |
| 1971 | if (args) |
| 1972 | { |
| 1973 | async_exec = strip_bg_char (&args); |
| 1974 | |
| 1975 | /* If we get a request for running in the bg but the target |
| 1976 | doesn't support it, error out. */ |
| 1977 | if (async_exec && !target_can_async_p ()) |
| 1978 | error (_("Asynchronous execution not supported on this target.")); |
| 1979 | } |
| 1980 | |
| 1981 | /* If we don't get a request of running in the bg, then we need |
| 1982 | to simulate synchronous (fg) execution. */ |
| 1983 | if (!async_exec && target_can_async_p ()) |
| 1984 | { |
| 1985 | /* Simulate synchronous execution */ |
| 1986 | async_disable_stdin (); |
| 1987 | } |
| 1988 | |
| 1989 | target_attach (args, from_tty); |
| 1990 | |
| 1991 | /* Set up the "saved terminal modes" of the inferior |
| 1992 | based on what modes we are starting it with. */ |
| 1993 | target_terminal_init (); |
| 1994 | |
| 1995 | /* Set up execution context to know that we should return from |
| 1996 | wait_for_inferior as soon as the target reports a stop. */ |
| 1997 | init_wait_for_inferior (); |
| 1998 | clear_proceed_status (); |
| 1999 | |
| 2000 | /* No traps are generated when attaching to inferior under Mach 3 |
| 2001 | or GNU hurd. */ |
| 2002 | #ifndef ATTACH_NO_WAIT |
| 2003 | /* Careful here. See comments in inferior.h. Basically some OSes |
| 2004 | don't ignore SIGSTOPs on continue requests anymore. We need a |
| 2005 | way for handle_inferior_event to reset the stop_signal variable |
| 2006 | after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */ |
| 2007 | stop_soon = STOP_QUIETLY_NO_SIGSTOP; |
| 2008 | |
| 2009 | if (target_can_async_p ()) |
| 2010 | { |
| 2011 | /* sync_execution mode. Wait for stop. */ |
| 2012 | struct continuation_arg *arg1, *arg2, *arg3; |
| 2013 | |
| 2014 | arg1 = |
| 2015 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 2016 | arg2 = |
| 2017 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 2018 | arg3 = |
| 2019 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 2020 | arg1->next = arg2; |
| 2021 | arg2->next = arg3; |
| 2022 | arg3->next = NULL; |
| 2023 | arg1->data.pointer = args; |
| 2024 | arg2->data.integer = from_tty; |
| 2025 | arg3->data.integer = async_exec; |
| 2026 | add_continuation (attach_command_continuation, arg1); |
| 2027 | return; |
| 2028 | } |
| 2029 | |
| 2030 | wait_for_inferior (0); |
| 2031 | #endif |
| 2032 | |
| 2033 | attach_command_post_wait (args, from_tty, async_exec); |
| 2034 | } |
| 2035 | |
| 2036 | /* |
| 2037 | * detach_command -- |
| 2038 | * takes a program previously attached to and detaches it. |
| 2039 | * The program resumes execution and will no longer stop |
| 2040 | * on signals, etc. We better not have left any breakpoints |
| 2041 | * in the program or it'll die when it hits one. For this |
| 2042 | * to work, it may be necessary for the process to have been |
| 2043 | * previously attached. It *might* work if the program was |
| 2044 | * started via the normal ptrace (PTRACE_TRACEME). |
| 2045 | */ |
| 2046 | |
| 2047 | static void |
| 2048 | detach_command (char *args, int from_tty) |
| 2049 | { |
| 2050 | dont_repeat (); /* Not for the faint of heart. */ |
| 2051 | target_detach (args, from_tty); |
| 2052 | no_shared_libraries (NULL, from_tty); |
| 2053 | if (deprecated_detach_hook) |
| 2054 | deprecated_detach_hook (); |
| 2055 | } |
| 2056 | |
| 2057 | /* Disconnect from the current target without resuming it (leaving it |
| 2058 | waiting for a debugger). |
| 2059 | |
| 2060 | We'd better not have left any breakpoints in the program or the |
| 2061 | next debugger will get confused. Currently only supported for some |
| 2062 | remote targets, since the normal attach mechanisms don't work on |
| 2063 | stopped processes on some native platforms (e.g. GNU/Linux). */ |
| 2064 | |
| 2065 | static void |
| 2066 | disconnect_command (char *args, int from_tty) |
| 2067 | { |
| 2068 | dont_repeat (); /* Not for the faint of heart */ |
| 2069 | target_disconnect (args, from_tty); |
| 2070 | no_shared_libraries (NULL, from_tty); |
| 2071 | if (deprecated_detach_hook) |
| 2072 | deprecated_detach_hook (); |
| 2073 | } |
| 2074 | |
| 2075 | /* Stop the execution of the target while running in async mode, in |
| 2076 | the backgound. */ |
| 2077 | void |
| 2078 | interrupt_target_command (char *args, int from_tty) |
| 2079 | { |
| 2080 | if (target_can_async_p ()) |
| 2081 | { |
| 2082 | dont_repeat (); /* Not for the faint of heart */ |
| 2083 | target_stop (); |
| 2084 | } |
| 2085 | } |
| 2086 | |
| 2087 | static void |
| 2088 | print_float_info (struct gdbarch *gdbarch, struct ui_file *file, |
| 2089 | struct frame_info *frame, const char *args) |
| 2090 | { |
| 2091 | if (gdbarch_print_float_info_p (gdbarch)) |
| 2092 | gdbarch_print_float_info (gdbarch, file, frame, args); |
| 2093 | else |
| 2094 | { |
| 2095 | int regnum; |
| 2096 | int printed_something = 0; |
| 2097 | |
| 2098 | for (regnum = 0; |
| 2099 | regnum < gdbarch_num_regs (gdbarch) |
| 2100 | + gdbarch_num_pseudo_regs (gdbarch); |
| 2101 | regnum++) |
| 2102 | { |
| 2103 | if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup)) |
| 2104 | { |
| 2105 | printed_something = 1; |
| 2106 | gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1); |
| 2107 | } |
| 2108 | } |
| 2109 | if (!printed_something) |
| 2110 | fprintf_filtered (file, "\ |
| 2111 | No floating-point info available for this processor.\n"); |
| 2112 | } |
| 2113 | } |
| 2114 | |
| 2115 | static void |
| 2116 | float_info (char *args, int from_tty) |
| 2117 | { |
| 2118 | if (!target_has_registers) |
| 2119 | error (_("The program has no registers now.")); |
| 2120 | |
| 2121 | print_float_info (current_gdbarch, gdb_stdout, |
| 2122 | get_selected_frame (NULL), args); |
| 2123 | } |
| 2124 | \f |
| 2125 | static void |
| 2126 | unset_command (char *args, int from_tty) |
| 2127 | { |
| 2128 | printf_filtered (_("\ |
| 2129 | \"unset\" must be followed by the name of an unset subcommand.\n")); |
| 2130 | help_list (unsetlist, "unset ", -1, gdb_stdout); |
| 2131 | } |
| 2132 | |
| 2133 | void |
| 2134 | _initialize_infcmd (void) |
| 2135 | { |
| 2136 | struct cmd_list_element *c = NULL; |
| 2137 | |
| 2138 | /* add the filename of the terminal connected to inferior I/O */ |
| 2139 | add_setshow_filename_cmd ("inferior-tty", class_run, |
| 2140 | &inferior_io_terminal, _("\ |
| 2141 | Set terminal for future runs of program being debugged."), _("\ |
| 2142 | Show terminal for future runs of program being debugged."), _("\ |
| 2143 | Usage: set inferior-tty /dev/pts/1"), NULL, NULL, &setlist, &showlist); |
| 2144 | add_com_alias ("tty", "set inferior-tty", class_alias, 0); |
| 2145 | |
| 2146 | add_setshow_optional_filename_cmd ("args", class_run, |
| 2147 | &inferior_args, _("\ |
| 2148 | Set argument list to give program being debugged when it is started."), _("\ |
| 2149 | Show argument list to give program being debugged when it is started."), _("\ |
| 2150 | Follow this command with any number of args, to be passed to the program."), |
| 2151 | notice_args_set, |
| 2152 | notice_args_read, |
| 2153 | &setlist, &showlist); |
| 2154 | |
| 2155 | c = add_cmd ("environment", no_class, environment_info, _("\ |
| 2156 | The environment to give the program, or one variable's value.\n\ |
| 2157 | With an argument VAR, prints the value of environment variable VAR to\n\ |
| 2158 | give the program being debugged. With no arguments, prints the entire\n\ |
| 2159 | environment to be given to the program."), &showlist); |
| 2160 | set_cmd_completer (c, noop_completer); |
| 2161 | |
| 2162 | add_prefix_cmd ("unset", no_class, unset_command, |
| 2163 | _("Complement to certain \"set\" commands."), |
| 2164 | &unsetlist, "unset ", 0, &cmdlist); |
| 2165 | |
| 2166 | c = add_cmd ("environment", class_run, unset_environment_command, _("\ |
| 2167 | Cancel environment variable VAR for the program.\n\ |
| 2168 | This does not affect the program until the next \"run\" command."), |
| 2169 | &unsetlist); |
| 2170 | set_cmd_completer (c, noop_completer); |
| 2171 | |
| 2172 | c = add_cmd ("environment", class_run, set_environment_command, _("\ |
| 2173 | Set environment variable value to give the program.\n\ |
| 2174 | Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ |
| 2175 | VALUES of environment variables are uninterpreted strings.\n\ |
| 2176 | This does not affect the program until the next \"run\" command."), |
| 2177 | &setlist); |
| 2178 | set_cmd_completer (c, noop_completer); |
| 2179 | |
| 2180 | c = add_com ("path", class_files, path_command, _("\ |
| 2181 | Add directory DIR(s) to beginning of search path for object files.\n\ |
| 2182 | $cwd in the path means the current working directory.\n\ |
| 2183 | This path is equivalent to the $PATH shell variable. It is a list of\n\ |
| 2184 | directories, separated by colons. These directories are searched to find\n\ |
| 2185 | fully linked executable files and separately compiled object files as needed.")); |
| 2186 | set_cmd_completer (c, filename_completer); |
| 2187 | |
| 2188 | c = add_cmd ("paths", no_class, path_info, _("\ |
| 2189 | Current search path for finding object files.\n\ |
| 2190 | $cwd in the path means the current working directory.\n\ |
| 2191 | This path is equivalent to the $PATH shell variable. It is a list of\n\ |
| 2192 | directories, separated by colons. These directories are searched to find\n\ |
| 2193 | fully linked executable files and separately compiled object files as needed."), |
| 2194 | &showlist); |
| 2195 | set_cmd_completer (c, noop_completer); |
| 2196 | |
| 2197 | add_com ("attach", class_run, attach_command, _("\ |
| 2198 | Attach to a process or file outside of GDB.\n\ |
| 2199 | This command attaches to another target, of the same type as your last\n\ |
| 2200 | \"target\" command (\"info files\" will show your target stack).\n\ |
| 2201 | The command may take as argument a process id or a device file.\n\ |
| 2202 | For a process id, you must have permission to send the process a signal,\n\ |
| 2203 | and it must have the same effective uid as the debugger.\n\ |
| 2204 | When using \"attach\" with a process id, the debugger finds the\n\ |
| 2205 | program running in the process, looking first in the current working\n\ |
| 2206 | directory, or (if not found there) using the source file search path\n\ |
| 2207 | (see the \"directory\" command). You can also use the \"file\" command\n\ |
| 2208 | to specify the program, and to load its symbol table.")); |
| 2209 | |
| 2210 | add_prefix_cmd ("detach", class_run, detach_command, _("\ |
| 2211 | Detach a process or file previously attached.\n\ |
| 2212 | If a process, it is no longer traced, and it continues its execution. If\n\ |
| 2213 | you were debugging a file, the file is closed and gdb no longer accesses it."), |
| 2214 | &detachlist, "detach ", 0, &cmdlist); |
| 2215 | |
| 2216 | add_com ("disconnect", class_run, disconnect_command, _("\ |
| 2217 | Disconnect from a target.\n\ |
| 2218 | The target will wait for another debugger to connect. Not available for\n\ |
| 2219 | all targets.")); |
| 2220 | |
| 2221 | add_com ("signal", class_run, signal_command, _("\ |
| 2222 | Continue program giving it signal specified by the argument.\n\ |
| 2223 | An argument of \"0\" means continue program without giving it a signal.")); |
| 2224 | |
| 2225 | add_com ("stepi", class_run, stepi_command, _("\ |
| 2226 | Step one instruction exactly.\n\ |
| 2227 | Argument N means do this N times (or till program stops for another reason).")); |
| 2228 | add_com_alias ("si", "stepi", class_alias, 0); |
| 2229 | |
| 2230 | add_com ("nexti", class_run, nexti_command, _("\ |
| 2231 | Step one instruction, but proceed through subroutine calls.\n\ |
| 2232 | Argument N means do this N times (or till program stops for another reason).")); |
| 2233 | add_com_alias ("ni", "nexti", class_alias, 0); |
| 2234 | |
| 2235 | add_com ("finish", class_run, finish_command, _("\ |
| 2236 | Execute until selected stack frame returns.\n\ |
| 2237 | Upon return, the value returned is printed and put in the value history.")); |
| 2238 | |
| 2239 | add_com ("next", class_run, next_command, _("\ |
| 2240 | Step program, proceeding through subroutine calls.\n\ |
| 2241 | Like the \"step\" command as long as subroutine calls do not happen;\n\ |
| 2242 | when they do, the call is treated as one instruction.\n\ |
| 2243 | Argument N means do this N times (or till program stops for another reason).")); |
| 2244 | add_com_alias ("n", "next", class_run, 1); |
| 2245 | if (xdb_commands) |
| 2246 | add_com_alias ("S", "next", class_run, 1); |
| 2247 | |
| 2248 | add_com ("step", class_run, step_command, _("\ |
| 2249 | Step program until it reaches a different source line.\n\ |
| 2250 | Argument N means do this N times (or till program stops for another reason).")); |
| 2251 | add_com_alias ("s", "step", class_run, 1); |
| 2252 | |
| 2253 | c = add_com ("until", class_run, until_command, _("\ |
| 2254 | Execute until the program reaches a source line greater than the current\n\ |
| 2255 | or a specified location (same args as break command) within the current frame.")); |
| 2256 | set_cmd_completer (c, location_completer); |
| 2257 | add_com_alias ("u", "until", class_run, 1); |
| 2258 | |
| 2259 | c = add_com ("advance", class_run, advance_command, _("\ |
| 2260 | Continue the program up to the given location (same form as args for break command).\n\ |
| 2261 | Execution will also stop upon exit from the current stack frame.")); |
| 2262 | set_cmd_completer (c, location_completer); |
| 2263 | |
| 2264 | c = add_com ("jump", class_run, jump_command, _("\ |
| 2265 | Continue program being debugged at specified line or address.\n\ |
| 2266 | Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ |
| 2267 | for an address to start at.")); |
| 2268 | set_cmd_completer (c, location_completer); |
| 2269 | |
| 2270 | if (xdb_commands) |
| 2271 | { |
| 2272 | c = add_com ("go", class_run, go_command, _("\ |
| 2273 | Usage: go <location>\n\ |
| 2274 | Continue program being debugged, stopping at specified line or \n\ |
| 2275 | address.\n\ |
| 2276 | Give as argument either LINENUM or *ADDR, where ADDR is an \n\ |
| 2277 | expression for an address to start at.\n\ |
| 2278 | This command is a combination of tbreak and jump.")); |
| 2279 | set_cmd_completer (c, location_completer); |
| 2280 | } |
| 2281 | |
| 2282 | if (xdb_commands) |
| 2283 | add_com_alias ("g", "go", class_run, 1); |
| 2284 | |
| 2285 | add_com ("continue", class_run, continue_command, _("\ |
| 2286 | Continue program being debugged, after signal or breakpoint.\n\ |
| 2287 | If proceeding from breakpoint, a number N may be used as an argument,\n\ |
| 2288 | which means to set the ignore count of that breakpoint to N - 1 (so that\n\ |
| 2289 | the breakpoint won't break until the Nth time it is reached).")); |
| 2290 | add_com_alias ("c", "cont", class_run, 1); |
| 2291 | add_com_alias ("fg", "cont", class_run, 1); |
| 2292 | |
| 2293 | c = add_com ("run", class_run, run_command, _("\ |
| 2294 | Start debugged program. You may specify arguments to give it.\n\ |
| 2295 | Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ |
| 2296 | Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\ |
| 2297 | With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\ |
| 2298 | To cancel previous arguments and run with no arguments,\n\ |
| 2299 | use \"set args\" without arguments.")); |
| 2300 | set_cmd_completer (c, filename_completer); |
| 2301 | add_com_alias ("r", "run", class_run, 1); |
| 2302 | if (xdb_commands) |
| 2303 | add_com ("R", class_run, run_no_args_command, |
| 2304 | _("Start debugged program with no arguments.")); |
| 2305 | |
| 2306 | c = add_com ("start", class_run, start_command, _("\ |
| 2307 | Run the debugged program until the beginning of the main procedure.\n\ |
| 2308 | You may specify arguments to give to your program, just as with the\n\ |
| 2309 | \"run\" command.")); |
| 2310 | set_cmd_completer (c, filename_completer); |
| 2311 | |
| 2312 | c = add_com ("interrupt", class_run, interrupt_target_command, |
| 2313 | _("Interrupt the execution of the debugged program.")); |
| 2314 | set_cmd_async_ok (c); |
| 2315 | |
| 2316 | add_info ("registers", nofp_registers_info, _("\ |
| 2317 | List of integer registers and their contents, for selected stack frame.\n\ |
| 2318 | Register name as argument means describe only that register.")); |
| 2319 | add_info_alias ("r", "registers", 1); |
| 2320 | |
| 2321 | if (xdb_commands) |
| 2322 | add_com ("lr", class_info, nofp_registers_info, _("\ |
| 2323 | List of integer registers and their contents, for selected stack frame.\n\ |
| 2324 | Register name as argument means describe only that register.")); |
| 2325 | add_info ("all-registers", all_registers_info, _("\ |
| 2326 | List of all registers and their contents, for selected stack frame.\n\ |
| 2327 | Register name as argument means describe only that register.")); |
| 2328 | |
| 2329 | add_info ("program", program_info, |
| 2330 | _("Execution status of the program.")); |
| 2331 | |
| 2332 | add_info ("float", float_info, |
| 2333 | _("Print the status of the floating point unit\n")); |
| 2334 | |
| 2335 | add_info ("vector", vector_info, |
| 2336 | _("Print the status of the vector unit\n")); |
| 2337 | |
| 2338 | inferior_environ = make_environ (); |
| 2339 | init_environ (inferior_environ); |
| 2340 | } |