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