| 1 | /* Memory-access and commands for "inferior" process, for GDB. |
| 2 | Copyright 1986, 87, 88, 89, 91, 92, 95, 96, 1998 |
| 3 | 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 2 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, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | Boston, MA 02111-1307, USA. */ |
| 21 | |
| 22 | #include "defs.h" |
| 23 | #include <signal.h> |
| 24 | #include "gdb_string.h" |
| 25 | #include "symtab.h" |
| 26 | #include "gdbtypes.h" |
| 27 | #include "frame.h" |
| 28 | #include "inferior.h" |
| 29 | #include "environ.h" |
| 30 | #include "value.h" |
| 31 | #include "gdbcmd.h" |
| 32 | #include "gdbcore.h" |
| 33 | #include "target.h" |
| 34 | #include "language.h" |
| 35 | #include "symfile.h" |
| 36 | #include "objfiles.h" |
| 37 | #include "event-loop.h" |
| 38 | |
| 39 | /* Functions exported for general use: */ |
| 40 | |
| 41 | void nofp_registers_info PARAMS ((char *, int)); |
| 42 | |
| 43 | void all_registers_info PARAMS ((char *, int)); |
| 44 | |
| 45 | void registers_info PARAMS ((char *, int)); |
| 46 | |
| 47 | /* Local functions: */ |
| 48 | |
| 49 | void continue_command PARAMS ((char *, int)); |
| 50 | |
| 51 | static void finish_command_continuation PARAMS ((struct continuation_arg *)); |
| 52 | |
| 53 | static void until_next_command PARAMS ((int)); |
| 54 | |
| 55 | static void until_command PARAMS ((char *, int)); |
| 56 | |
| 57 | static void path_info PARAMS ((char *, int)); |
| 58 | |
| 59 | static void path_command PARAMS ((char *, int)); |
| 60 | |
| 61 | static void unset_command PARAMS ((char *, int)); |
| 62 | |
| 63 | static void float_info PARAMS ((char *, int)); |
| 64 | |
| 65 | static void detach_command PARAMS ((char *, int)); |
| 66 | |
| 67 | #if !defined (DO_REGISTERS_INFO) |
| 68 | static void do_registers_info PARAMS ((int, int)); |
| 69 | #endif |
| 70 | |
| 71 | static void unset_environment_command PARAMS ((char *, int)); |
| 72 | |
| 73 | static void set_environment_command PARAMS ((char *, int)); |
| 74 | |
| 75 | static void environment_info PARAMS ((char *, int)); |
| 76 | |
| 77 | static void program_info PARAMS ((char *, int)); |
| 78 | |
| 79 | static void finish_command PARAMS ((char *, int)); |
| 80 | |
| 81 | static void signal_command PARAMS ((char *, int)); |
| 82 | |
| 83 | static void jump_command PARAMS ((char *, int)); |
| 84 | |
| 85 | static void step_1 PARAMS ((int, int, char *)); |
| 86 | |
| 87 | void nexti_command PARAMS ((char *, int)); |
| 88 | |
| 89 | void stepi_command PARAMS ((char *, int)); |
| 90 | |
| 91 | static void next_command PARAMS ((char *, int)); |
| 92 | |
| 93 | static void step_command PARAMS ((char *, int)); |
| 94 | |
| 95 | static void run_command PARAMS ((char *, int)); |
| 96 | |
| 97 | static void run_no_args_command PARAMS ((char *args, int from_tty)); |
| 98 | |
| 99 | static void go_command PARAMS ((char *line_no, int from_tty)); |
| 100 | |
| 101 | static int strip_bg_char PARAMS ((char **)); |
| 102 | |
| 103 | void _initialize_infcmd PARAMS ((void)); |
| 104 | |
| 105 | #define GO_USAGE "Usage: go <location>\n" |
| 106 | |
| 107 | static void breakpoint_auto_delete_contents PARAMS ((PTR)); |
| 108 | |
| 109 | #define ERROR_NO_INFERIOR \ |
| 110 | if (!target_has_execution) error ("The program is not being run."); |
| 111 | |
| 112 | /* String containing arguments to give to the program, separated by spaces. |
| 113 | Empty string (pointer to '\0') means no args. */ |
| 114 | |
| 115 | static char *inferior_args; |
| 116 | |
| 117 | /* File name for default use for standard in/out in the inferior. */ |
| 118 | |
| 119 | char *inferior_io_terminal; |
| 120 | |
| 121 | /* Pid of our debugged inferior, or 0 if no inferior now. |
| 122 | Since various parts of infrun.c test this to see whether there is a program |
| 123 | being debugged it should be nonzero (currently 3 is used) for remote |
| 124 | debugging. */ |
| 125 | |
| 126 | int inferior_pid; |
| 127 | |
| 128 | /* Last signal that the inferior received (why it stopped). */ |
| 129 | |
| 130 | enum target_signal stop_signal; |
| 131 | |
| 132 | /* Address at which inferior stopped. */ |
| 133 | |
| 134 | CORE_ADDR stop_pc; |
| 135 | |
| 136 | /* Chain containing status of breakpoint(s) that we have stopped at. */ |
| 137 | |
| 138 | bpstat stop_bpstat; |
| 139 | |
| 140 | /* Flag indicating that a command has proceeded the inferior past the |
| 141 | current breakpoint. */ |
| 142 | |
| 143 | int breakpoint_proceeded; |
| 144 | |
| 145 | /* Nonzero if stopped due to a step command. */ |
| 146 | |
| 147 | int stop_step; |
| 148 | |
| 149 | /* Nonzero if stopped due to completion of a stack dummy routine. */ |
| 150 | |
| 151 | int stop_stack_dummy; |
| 152 | |
| 153 | /* Nonzero if stopped due to a random (unexpected) signal in inferior |
| 154 | process. */ |
| 155 | |
| 156 | int stopped_by_random_signal; |
| 157 | |
| 158 | /* Range to single step within. |
| 159 | If this is nonzero, respond to a single-step signal |
| 160 | by continuing to step if the pc is in this range. */ |
| 161 | |
| 162 | CORE_ADDR step_range_start; /* Inclusive */ |
| 163 | CORE_ADDR step_range_end; /* Exclusive */ |
| 164 | |
| 165 | /* Stack frame address as of when stepping command was issued. |
| 166 | This is how we know when we step into a subroutine call, |
| 167 | and how to set the frame for the breakpoint used to step out. */ |
| 168 | |
| 169 | CORE_ADDR step_frame_address; |
| 170 | |
| 171 | /* Our notion of the current stack pointer. */ |
| 172 | |
| 173 | CORE_ADDR step_sp; |
| 174 | |
| 175 | /* 1 means step over all subroutine calls. |
| 176 | 0 means don't step over calls (used by stepi). |
| 177 | -1 means step over calls to undebuggable functions. */ |
| 178 | |
| 179 | int step_over_calls; |
| 180 | |
| 181 | /* If stepping, nonzero means step count is > 1 |
| 182 | so don't print frame next time inferior stops |
| 183 | if it stops due to stepping. */ |
| 184 | |
| 185 | int step_multi; |
| 186 | |
| 187 | /* Environment to use for running inferior, |
| 188 | in format described in environ.h. */ |
| 189 | |
| 190 | struct environ *inferior_environ; |
| 191 | \f |
| 192 | |
| 193 | /* This function detects whether or not a '&' character (indicating |
| 194 | background execution) has been added as *the last* of the arguments ARGS |
| 195 | of a command. If it has, it removes it and returns 1. Otherwise it |
| 196 | does nothing and returns 0. */ |
| 197 | static int |
| 198 | strip_bg_char (args) |
| 199 | char **args; |
| 200 | { |
| 201 | char *p = NULL; |
| 202 | |
| 203 | p = strchr (*args, '&'); |
| 204 | |
| 205 | if (p) |
| 206 | { |
| 207 | if (p == (*args + strlen (*args) - 1)) |
| 208 | { |
| 209 | if (strlen (*args) > 1) |
| 210 | { |
| 211 | do |
| 212 | p--; |
| 213 | while (*p == ' ' || *p == '\t'); |
| 214 | *(p + 1) = '\0'; |
| 215 | } |
| 216 | else |
| 217 | *args = 0; |
| 218 | return 1; |
| 219 | } |
| 220 | } |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | /* ARGSUSED */ |
| 225 | void |
| 226 | tty_command (file, from_tty) |
| 227 | char *file; |
| 228 | int from_tty; |
| 229 | { |
| 230 | if (file == 0) |
| 231 | error_no_arg ("terminal name for running target process"); |
| 232 | |
| 233 | inferior_io_terminal = savestring (file, strlen (file)); |
| 234 | } |
| 235 | |
| 236 | static void |
| 237 | run_command (args, from_tty) |
| 238 | char *args; |
| 239 | int from_tty; |
| 240 | { |
| 241 | char *exec_file; |
| 242 | |
| 243 | dont_repeat (); |
| 244 | |
| 245 | if (inferior_pid != 0 && target_has_execution) |
| 246 | { |
| 247 | if ( |
| 248 | !query ("The program being debugged has been started already.\n\ |
| 249 | Start it from the beginning? ")) |
| 250 | error ("Program not restarted."); |
| 251 | target_kill (); |
| 252 | #if defined(SOLIB_RESTART) |
| 253 | SOLIB_RESTART (); |
| 254 | #endif |
| 255 | init_wait_for_inferior (); |
| 256 | } |
| 257 | |
| 258 | clear_breakpoint_hit_counts (); |
| 259 | |
| 260 | exec_file = (char *) get_exec_file (0); |
| 261 | |
| 262 | /* Purge old solib objfiles. */ |
| 263 | objfile_purge_solibs (); |
| 264 | |
| 265 | do_run_cleanups (NULL); |
| 266 | |
| 267 | /* The exec file is re-read every time we do a generic_mourn_inferior, so |
| 268 | we just have to worry about the symbol file. */ |
| 269 | reread_symbols (); |
| 270 | |
| 271 | /* We keep symbols from add-symbol-file, on the grounds that the |
| 272 | user might want to add some symbols before running the program |
| 273 | (right?). But sometimes (dynamic loading where the user manually |
| 274 | introduces the new symbols with add-symbol-file), the code which |
| 275 | the symbols describe does not persist between runs. Currently |
| 276 | the user has to manually nuke all symbols between runs if they |
| 277 | want them to go away (PR 2207). This is probably reasonable. */ |
| 278 | |
| 279 | if (!args) |
| 280 | sync_execution = 1; |
| 281 | else |
| 282 | { |
| 283 | char *cmd; |
| 284 | int async_exec = strip_bg_char (&args); |
| 285 | |
| 286 | /* If we get a request for running in the bg but the target |
| 287 | doesn't support it, error out. */ |
| 288 | if (async_p && async_exec && !target_has_async) |
| 289 | error ("Asynchronous execution not supported on this target."); |
| 290 | |
| 291 | /* If we don't get a request of running in the bg, then we need |
| 292 | to simulate synchronous (fg) execution. */ |
| 293 | if (async_p && !async_exec && target_has_async) |
| 294 | { |
| 295 | /* Simulate synchronous execution */ |
| 296 | sync_execution = 1; |
| 297 | } |
| 298 | |
| 299 | /* If there were other args, beside '&', process them. */ |
| 300 | if (args) |
| 301 | { |
| 302 | cmd = concat ("set args ", args, NULL); |
| 303 | make_cleanup (free, cmd); |
| 304 | execute_command (cmd, from_tty); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | if (from_tty) |
| 309 | { |
| 310 | puts_filtered ("Starting program: "); |
| 311 | if (exec_file) |
| 312 | puts_filtered (exec_file); |
| 313 | puts_filtered (" "); |
| 314 | puts_filtered (inferior_args); |
| 315 | puts_filtered ("\n"); |
| 316 | gdb_flush (gdb_stdout); |
| 317 | } |
| 318 | |
| 319 | target_create_inferior (exec_file, inferior_args, |
| 320 | environ_vector (inferior_environ)); |
| 321 | } |
| 322 | |
| 323 | |
| 324 | static void |
| 325 | run_no_args_command (args, from_tty) |
| 326 | char *args; |
| 327 | int from_tty; |
| 328 | { |
| 329 | execute_command ("set args", from_tty); |
| 330 | run_command ((char *) NULL, from_tty); |
| 331 | } |
| 332 | \f |
| 333 | |
| 334 | void |
| 335 | continue_command (proc_count_exp, from_tty) |
| 336 | char *proc_count_exp; |
| 337 | int from_tty; |
| 338 | { |
| 339 | int async_exec = 0; |
| 340 | ERROR_NO_INFERIOR; |
| 341 | |
| 342 | /* Find out whether we must run in the background. */ |
| 343 | if (proc_count_exp != NULL) |
| 344 | async_exec = strip_bg_char (&proc_count_exp); |
| 345 | |
| 346 | /* If we must run in the background, but the target can't do it, |
| 347 | error out. */ |
| 348 | if (async_p && async_exec && !target_has_async) |
| 349 | error ("Asynchronous execution not supported on this target."); |
| 350 | |
| 351 | /* If we are not asked to run in the bg, then prepare to run in the |
| 352 | foreground, synchronously. */ |
| 353 | if (async_p && !async_exec && target_has_async) |
| 354 | { |
| 355 | /* Simulate synchronous execution */ |
| 356 | sync_execution = 1; |
| 357 | } |
| 358 | |
| 359 | /* If have argument (besides '&'), set proceed count of breakpoint |
| 360 | we stopped at. */ |
| 361 | if (proc_count_exp != NULL) |
| 362 | { |
| 363 | bpstat bs = stop_bpstat; |
| 364 | int num = bpstat_num (&bs); |
| 365 | if (num == 0 && from_tty) |
| 366 | { |
| 367 | printf_filtered |
| 368 | ("Not stopped at any breakpoint; argument ignored.\n"); |
| 369 | } |
| 370 | while (num != 0) |
| 371 | { |
| 372 | set_ignore_count (num, |
| 373 | parse_and_eval_address (proc_count_exp) - 1, |
| 374 | from_tty); |
| 375 | /* set_ignore_count prints a message ending with a period. |
| 376 | So print two spaces before "Continuing.". */ |
| 377 | if (from_tty) |
| 378 | printf_filtered (" "); |
| 379 | num = bpstat_num (&bs); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | if (from_tty) |
| 384 | printf_filtered ("Continuing.\n"); |
| 385 | |
| 386 | clear_proceed_status (); |
| 387 | |
| 388 | proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_DEFAULT, 0); |
| 389 | } |
| 390 | \f |
| 391 | /* Step until outside of current statement. */ |
| 392 | |
| 393 | /* ARGSUSED */ |
| 394 | static void |
| 395 | step_command (count_string, from_tty) |
| 396 | char *count_string; |
| 397 | int from_tty; |
| 398 | { |
| 399 | step_1 (0, 0, count_string); |
| 400 | } |
| 401 | |
| 402 | /* Likewise, but skip over subroutine calls as if single instructions. */ |
| 403 | |
| 404 | /* ARGSUSED */ |
| 405 | static void |
| 406 | next_command (count_string, from_tty) |
| 407 | char *count_string; |
| 408 | int from_tty; |
| 409 | { |
| 410 | step_1 (1, 0, count_string); |
| 411 | } |
| 412 | |
| 413 | /* Likewise, but step only one instruction. */ |
| 414 | |
| 415 | /* ARGSUSED */ |
| 416 | void |
| 417 | stepi_command (count_string, from_tty) |
| 418 | char *count_string; |
| 419 | int from_tty; |
| 420 | { |
| 421 | step_1 (0, 1, count_string); |
| 422 | } |
| 423 | |
| 424 | /* ARGSUSED */ |
| 425 | void |
| 426 | nexti_command (count_string, from_tty) |
| 427 | char *count_string; |
| 428 | int from_tty; |
| 429 | { |
| 430 | step_1 (1, 1, count_string); |
| 431 | } |
| 432 | |
| 433 | static void |
| 434 | step_1 (skip_subroutines, single_inst, count_string) |
| 435 | int skip_subroutines; |
| 436 | int single_inst; |
| 437 | char *count_string; |
| 438 | { |
| 439 | register int count = 1; |
| 440 | struct frame_info *frame; |
| 441 | struct cleanup *cleanups = 0; |
| 442 | int async_exec = 0; |
| 443 | |
| 444 | ERROR_NO_INFERIOR; |
| 445 | |
| 446 | if (count_string) |
| 447 | async_exec = strip_bg_char (&count_string); |
| 448 | |
| 449 | /* If we get a request for running in the bg but the target |
| 450 | doesn't support it, error out. */ |
| 451 | if (async_p && async_exec && !target_has_async) |
| 452 | error ("Asynchronous execution not supported on this target."); |
| 453 | |
| 454 | /* If we don't get a request of running in the bg, then we need |
| 455 | to simulate synchronous (fg) execution. */ |
| 456 | if (async_p && !async_exec && target_has_async) |
| 457 | { |
| 458 | /* Simulate synchronous execution */ |
| 459 | sync_execution = 1; |
| 460 | } |
| 461 | |
| 462 | count = count_string ? parse_and_eval_address (count_string) : 1; |
| 463 | |
| 464 | if (!single_inst || skip_subroutines) /* leave si command alone */ |
| 465 | { |
| 466 | enable_longjmp_breakpoint (); |
| 467 | cleanups = make_cleanup ((make_cleanup_func) disable_longjmp_breakpoint, |
| 468 | 0); |
| 469 | } |
| 470 | |
| 471 | for (; count > 0; count--) |
| 472 | { |
| 473 | clear_proceed_status (); |
| 474 | |
| 475 | frame = get_current_frame (); |
| 476 | if (!frame) /* Avoid coredump here. Why tho? */ |
| 477 | error ("No current frame"); |
| 478 | step_frame_address = FRAME_FP (frame); |
| 479 | step_sp = read_sp (); |
| 480 | |
| 481 | if (!single_inst) |
| 482 | { |
| 483 | find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); |
| 484 | if (step_range_end == 0) |
| 485 | { |
| 486 | char *name; |
| 487 | if (find_pc_partial_function (stop_pc, &name, &step_range_start, |
| 488 | &step_range_end) == 0) |
| 489 | error ("Cannot find bounds of current function"); |
| 490 | |
| 491 | target_terminal_ours (); |
| 492 | printf_filtered ("\ |
| 493 | Single stepping until exit from function %s, \n\ |
| 494 | which has no line number information.\n", name); |
| 495 | } |
| 496 | } |
| 497 | else |
| 498 | { |
| 499 | /* Say we are stepping, but stop after one insn whatever it does. */ |
| 500 | step_range_start = step_range_end = 1; |
| 501 | if (!skip_subroutines) |
| 502 | /* It is stepi. |
| 503 | Don't step over function calls, not even to functions lacking |
| 504 | line numbers. */ |
| 505 | step_over_calls = 0; |
| 506 | } |
| 507 | |
| 508 | if (skip_subroutines) |
| 509 | step_over_calls = 1; |
| 510 | |
| 511 | step_multi = (count > 1); |
| 512 | proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_DEFAULT, 1); |
| 513 | if (!stop_step) |
| 514 | break; |
| 515 | |
| 516 | /* FIXME: On nexti, this may have already been done (when we hit the |
| 517 | step resume break, I think). Probably this should be moved to |
| 518 | wait_for_inferior (near the top). */ |
| 519 | #if defined (SHIFT_INST_REGS) |
| 520 | SHIFT_INST_REGS (); |
| 521 | #endif |
| 522 | } |
| 523 | |
| 524 | if (!single_inst || skip_subroutines) |
| 525 | do_cleanups (cleanups); |
| 526 | } |
| 527 | \f |
| 528 | /* Continue program at specified address. */ |
| 529 | |
| 530 | static void |
| 531 | jump_command (arg, from_tty) |
| 532 | char *arg; |
| 533 | int from_tty; |
| 534 | { |
| 535 | register CORE_ADDR addr; |
| 536 | struct symtabs_and_lines sals; |
| 537 | struct symtab_and_line sal; |
| 538 | struct symbol *fn; |
| 539 | struct symbol *sfn; |
| 540 | int async_exec = 0; |
| 541 | |
| 542 | ERROR_NO_INFERIOR; |
| 543 | |
| 544 | /* Find out whether we must run in the background. */ |
| 545 | if (arg != NULL) |
| 546 | async_exec = strip_bg_char (&arg); |
| 547 | |
| 548 | /* If we must run in the background, but the target can't do it, |
| 549 | error out. */ |
| 550 | if (async_p && async_exec && !target_has_async) |
| 551 | error ("Asynchronous execution not supported on this target."); |
| 552 | |
| 553 | /* If we are not asked to run in the bg, then prepare to run in the |
| 554 | foreground, synchronously. */ |
| 555 | if (async_p && !async_exec && target_has_async) |
| 556 | { |
| 557 | /* Simulate synchronous execution */ |
| 558 | sync_execution = 1; |
| 559 | } |
| 560 | |
| 561 | if (!arg) |
| 562 | error_no_arg ("starting address"); |
| 563 | |
| 564 | sals = decode_line_spec_1 (arg, 1); |
| 565 | if (sals.nelts != 1) |
| 566 | { |
| 567 | error ("Unreasonable jump request"); |
| 568 | } |
| 569 | |
| 570 | sal = sals.sals[0]; |
| 571 | free ((PTR) sals.sals); |
| 572 | |
| 573 | if (sal.symtab == 0 && sal.pc == 0) |
| 574 | error ("No source file has been specified."); |
| 575 | |
| 576 | resolve_sal_pc (&sal); /* May error out */ |
| 577 | |
| 578 | /* See if we are trying to jump to another function. */ |
| 579 | fn = get_frame_function (get_current_frame ()); |
| 580 | sfn = find_pc_function (sal.pc); |
| 581 | if (fn != NULL && sfn != fn) |
| 582 | { |
| 583 | if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, |
| 584 | SYMBOL_SOURCE_NAME (fn))) |
| 585 | { |
| 586 | error ("Not confirmed."); |
| 587 | /* NOTREACHED */ |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | if (sfn != NULL) |
| 592 | { |
| 593 | fixup_symbol_section (sfn, 0); |
| 594 | if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && |
| 595 | !section_is_mapped (SYMBOL_BFD_SECTION (sfn))) |
| 596 | { |
| 597 | if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")) |
| 598 | { |
| 599 | error ("Not confirmed."); |
| 600 | /* NOTREACHED */ |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | addr = sal.pc; |
| 606 | |
| 607 | if (from_tty) |
| 608 | { |
| 609 | printf_filtered ("Continuing at "); |
| 610 | print_address_numeric (addr, 1, gdb_stdout); |
| 611 | printf_filtered (".\n"); |
| 612 | } |
| 613 | |
| 614 | clear_proceed_status (); |
| 615 | proceed (addr, TARGET_SIGNAL_0, 0); |
| 616 | } |
| 617 | \f |
| 618 | |
| 619 | /* Go to line or address in current procedure */ |
| 620 | static void |
| 621 | go_command (line_no, from_tty) |
| 622 | char *line_no; |
| 623 | int from_tty; |
| 624 | { |
| 625 | if (line_no == (char *) NULL || !*line_no) |
| 626 | printf_filtered (GO_USAGE); |
| 627 | else |
| 628 | { |
| 629 | tbreak_command (line_no, from_tty); |
| 630 | jump_command (line_no, from_tty); |
| 631 | } |
| 632 | } |
| 633 | \f |
| 634 | |
| 635 | /* Continue program giving it specified signal. */ |
| 636 | |
| 637 | static void |
| 638 | signal_command (signum_exp, from_tty) |
| 639 | char *signum_exp; |
| 640 | int from_tty; |
| 641 | { |
| 642 | enum target_signal oursig; |
| 643 | |
| 644 | dont_repeat (); /* Too dangerous. */ |
| 645 | ERROR_NO_INFERIOR; |
| 646 | |
| 647 | if (!signum_exp) |
| 648 | error_no_arg ("signal number"); |
| 649 | |
| 650 | /* It would be even slicker to make signal names be valid expressions, |
| 651 | (the type could be "enum $signal" or some such), then the user could |
| 652 | assign them to convenience variables. */ |
| 653 | oursig = target_signal_from_name (signum_exp); |
| 654 | |
| 655 | if (oursig == TARGET_SIGNAL_UNKNOWN) |
| 656 | { |
| 657 | /* No, try numeric. */ |
| 658 | int num = parse_and_eval_address (signum_exp); |
| 659 | |
| 660 | if (num == 0) |
| 661 | oursig = TARGET_SIGNAL_0; |
| 662 | else |
| 663 | oursig = target_signal_from_command (num); |
| 664 | } |
| 665 | |
| 666 | if (from_tty) |
| 667 | { |
| 668 | if (oursig == TARGET_SIGNAL_0) |
| 669 | printf_filtered ("Continuing with no signal.\n"); |
| 670 | else |
| 671 | printf_filtered ("Continuing with signal %s.\n", |
| 672 | target_signal_to_name (oursig)); |
| 673 | } |
| 674 | |
| 675 | clear_proceed_status (); |
| 676 | /* "signal 0" should not get stuck if we are stopped at a breakpoint. |
| 677 | FIXME: Neither should "signal foo" but when I tried passing |
| 678 | (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't |
| 679 | tried to track down yet. */ |
| 680 | proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) - 1 : stop_pc, oursig, 0); |
| 681 | } |
| 682 | |
| 683 | /* Call breakpoint_auto_delete on the current contents of the bpstat |
| 684 | pointed to by arg (which is really a bpstat *). */ |
| 685 | |
| 686 | static void |
| 687 | breakpoint_auto_delete_contents (arg) |
| 688 | PTR arg; |
| 689 | { |
| 690 | breakpoint_auto_delete (*(bpstat *) arg); |
| 691 | } |
| 692 | |
| 693 | |
| 694 | /* Execute a "stack dummy", a piece of code stored in the stack |
| 695 | by the debugger to be executed in the inferior. |
| 696 | |
| 697 | To call: first, do PUSH_DUMMY_FRAME. |
| 698 | Then push the contents of the dummy. It should end with a breakpoint insn. |
| 699 | Then call here, passing address at which to start the dummy. |
| 700 | |
| 701 | The contents of all registers are saved before the dummy frame is popped |
| 702 | and copied into the buffer BUFFER. |
| 703 | |
| 704 | The dummy's frame is automatically popped whenever that break is hit. |
| 705 | If that is the first time the program stops, run_stack_dummy |
| 706 | returns to its caller with that frame already gone and returns 0. |
| 707 | Otherwise, run_stack-dummy returns 1 (the frame will eventually be popped |
| 708 | when we do hit that breakpoint). */ |
| 709 | |
| 710 | /* DEBUG HOOK: 4 => return instead of letting the stack dummy run. */ |
| 711 | |
| 712 | static int stack_dummy_testing = 0; |
| 713 | |
| 714 | int |
| 715 | run_stack_dummy (addr, buffer) |
| 716 | CORE_ADDR addr; |
| 717 | char *buffer; |
| 718 | { |
| 719 | struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0); |
| 720 | |
| 721 | /* Now proceed, having reached the desired place. */ |
| 722 | clear_proceed_status (); |
| 723 | if (stack_dummy_testing & 4) |
| 724 | { |
| 725 | POP_FRAME; |
| 726 | return (0); |
| 727 | } |
| 728 | if (CALL_DUMMY_BREAKPOINT_OFFSET_P) |
| 729 | { |
| 730 | struct breakpoint *bpt; |
| 731 | struct symtab_and_line sal; |
| 732 | |
| 733 | INIT_SAL (&sal); /* initialize to zeroes */ |
| 734 | if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) |
| 735 | { |
| 736 | sal.pc = CALL_DUMMY_ADDRESS (); |
| 737 | } |
| 738 | else |
| 739 | { |
| 740 | sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET; |
| 741 | } |
| 742 | sal.section = find_pc_overlay (sal.pc); |
| 743 | |
| 744 | /* Set up a FRAME for the dummy frame so we can pass it to |
| 745 | set_momentary_breakpoint. We need to give the breakpoint a |
| 746 | frame in case there is only one copy of the dummy (e.g. |
| 747 | CALL_DUMMY_LOCATION == AFTER_TEXT_END). */ |
| 748 | flush_cached_frames (); |
| 749 | set_current_frame (create_new_frame (read_fp (), sal.pc)); |
| 750 | |
| 751 | /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put |
| 752 | a breakpoint instruction. If not, the call dummy already has the |
| 753 | breakpoint instruction in it. |
| 754 | |
| 755 | addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET, |
| 756 | so we need to subtract the CALL_DUMMY_START_OFFSET. */ |
| 757 | bpt = set_momentary_breakpoint (sal, |
| 758 | get_current_frame (), |
| 759 | bp_call_dummy); |
| 760 | bpt->disposition = del; |
| 761 | |
| 762 | /* If all error()s out of proceed ended up calling normal_stop (and |
| 763 | perhaps they should; it already does in the special case of error |
| 764 | out of resume()), then we wouldn't need this. */ |
| 765 | make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat); |
| 766 | } |
| 767 | |
| 768 | disable_watchpoints_before_interactive_call_start (); |
| 769 | proceed_to_finish = 1; /* We want stop_registers, please... */ |
| 770 | proceed (addr, TARGET_SIGNAL_0, 0); |
| 771 | enable_watchpoints_after_interactive_call_stop (); |
| 772 | |
| 773 | discard_cleanups (old_cleanups); |
| 774 | |
| 775 | if (!stop_stack_dummy) |
| 776 | return 1; |
| 777 | |
| 778 | /* On return, the stack dummy has been popped already. */ |
| 779 | |
| 780 | memcpy (buffer, stop_registers, REGISTER_BYTES); |
| 781 | return 0; |
| 782 | } |
| 783 | \f |
| 784 | /* Proceed until we reach a different source line with pc greater than |
| 785 | our current one or exit the function. We skip calls in both cases. |
| 786 | |
| 787 | Note that eventually this command should probably be changed so |
| 788 | that only source lines are printed out when we hit the breakpoint |
| 789 | we set. This may involve changes to wait_for_inferior and the |
| 790 | proceed status code. */ |
| 791 | |
| 792 | /* ARGSUSED */ |
| 793 | static void |
| 794 | until_next_command (from_tty) |
| 795 | int from_tty; |
| 796 | { |
| 797 | struct frame_info *frame; |
| 798 | CORE_ADDR pc; |
| 799 | struct symbol *func; |
| 800 | struct symtab_and_line sal; |
| 801 | |
| 802 | clear_proceed_status (); |
| 803 | |
| 804 | frame = get_current_frame (); |
| 805 | |
| 806 | /* Step until either exited from this function or greater |
| 807 | than the current line (if in symbolic section) or pc (if |
| 808 | not). */ |
| 809 | |
| 810 | pc = read_pc (); |
| 811 | func = find_pc_function (pc); |
| 812 | |
| 813 | if (!func) |
| 814 | { |
| 815 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); |
| 816 | |
| 817 | if (msymbol == NULL) |
| 818 | error ("Execution is not within a known function."); |
| 819 | |
| 820 | step_range_start = SYMBOL_VALUE_ADDRESS (msymbol); |
| 821 | step_range_end = pc; |
| 822 | } |
| 823 | else |
| 824 | { |
| 825 | sal = find_pc_line (pc, 0); |
| 826 | |
| 827 | step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); |
| 828 | step_range_end = sal.end; |
| 829 | } |
| 830 | |
| 831 | step_over_calls = 1; |
| 832 | step_frame_address = FRAME_FP (frame); |
| 833 | step_sp = read_sp (); |
| 834 | |
| 835 | step_multi = 0; /* Only one call to proceed */ |
| 836 | |
| 837 | proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_DEFAULT, 1); |
| 838 | } |
| 839 | |
| 840 | static void |
| 841 | until_command (arg, from_tty) |
| 842 | char *arg; |
| 843 | int from_tty; |
| 844 | { |
| 845 | int async_exec = 0; |
| 846 | |
| 847 | if (!target_has_execution) |
| 848 | error ("The program is not running."); |
| 849 | |
| 850 | /* Find out whether we must run in the background. */ |
| 851 | if (arg != NULL) |
| 852 | async_exec = strip_bg_char (&arg); |
| 853 | |
| 854 | /* If we must run in the background, but the target can't do it, |
| 855 | error out. */ |
| 856 | if (async_p && async_exec && !target_has_async) |
| 857 | error ("Asynchronous execution not supported on this target."); |
| 858 | |
| 859 | /* If we are not asked to run in the bg, then prepare to run in the |
| 860 | foreground, synchronously. */ |
| 861 | if (async_p && !async_exec && target_has_async) |
| 862 | { |
| 863 | /* Simulate synchronous execution */ |
| 864 | sync_execution = 1; |
| 865 | } |
| 866 | |
| 867 | if (arg) |
| 868 | until_break_command (arg, from_tty); |
| 869 | else |
| 870 | until_next_command (from_tty); |
| 871 | } |
| 872 | \f |
| 873 | |
| 874 | /* Stuff that needs to be done by the finish command after the target |
| 875 | has stopped. In asynchronous mode, we wait for the target to stop in |
| 876 | the call to poll or select in the event loop, so it is impossible to |
| 877 | do all the stuff as part of the finish_command function itself. The |
| 878 | only chance we have to complete this command is in |
| 879 | fetch_inferior_event, which is called by the event loop as soon as it |
| 880 | detects that the target has stopped. This function is called via the |
| 881 | cmd_continaution pointer. */ |
| 882 | void |
| 883 | finish_command_continuation (arg) |
| 884 | struct continuation_arg *arg; |
| 885 | { |
| 886 | register struct symbol *function; |
| 887 | struct breakpoint *breakpoint; |
| 888 | |
| 889 | breakpoint = (struct breakpoint *) arg->data; |
| 890 | function = (struct symbol *) (arg->next)->data; |
| 891 | |
| 892 | if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL |
| 893 | && function != 0) |
| 894 | { |
| 895 | struct type *value_type; |
| 896 | register value_ptr val; |
| 897 | CORE_ADDR funcaddr; |
| 898 | int struct_return; |
| 899 | |
| 900 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); |
| 901 | if (!value_type) |
| 902 | fatal ("internal: finish_command: function has no target type"); |
| 903 | |
| 904 | if (TYPE_CODE (value_type) == TYPE_CODE_VOID) |
| 905 | { |
| 906 | do_exec_cleanups (ALL_CLEANUPS); |
| 907 | return; |
| 908 | } |
| 909 | |
| 910 | funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); |
| 911 | |
| 912 | struct_return = using_struct_return (value_of_variable (function, NULL), |
| 913 | |
| 914 | funcaddr, |
| 915 | check_typedef (value_type), |
| 916 | BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))); |
| 917 | |
| 918 | if (!struct_return) |
| 919 | { |
| 920 | val = value_being_returned (value_type, stop_registers, struct_return); |
| 921 | printf_filtered ("Value returned is $%d = ", record_latest_value (val)); |
| 922 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); |
| 923 | printf_filtered ("\n"); |
| 924 | } |
| 925 | else |
| 926 | { |
| 927 | /* We cannot determine the contents of the structure because |
| 928 | it is on the stack, and we don't know where, since we did not |
| 929 | initiate the call, as opposed to the call_function_by_hand case */ |
| 930 | #ifdef VALUE_RETURNED_FROM_STACK |
| 931 | val = 0; |
| 932 | printf_filtered ("Value returned has type: %s.", |
| 933 | TYPE_NAME (value_type)); |
| 934 | printf_filtered (" Cannot determine contents\n"); |
| 935 | #else |
| 936 | val = value_being_returned (value_type, stop_registers, |
| 937 | struct_return); |
| 938 | printf_filtered ("Value returned is $%d = ", |
| 939 | record_latest_value (val)); |
| 940 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); |
| 941 | printf_filtered ("\n"); |
| 942 | #endif |
| 943 | |
| 944 | } |
| 945 | } |
| 946 | do_exec_cleanups (ALL_CLEANUPS); |
| 947 | } |
| 948 | |
| 949 | /* "finish": Set a temporary breakpoint at the place |
| 950 | the selected frame will return to, then continue. */ |
| 951 | |
| 952 | static void |
| 953 | finish_command (arg, from_tty) |
| 954 | char *arg; |
| 955 | int from_tty; |
| 956 | { |
| 957 | struct symtab_and_line sal; |
| 958 | register struct frame_info *frame; |
| 959 | register struct symbol *function; |
| 960 | struct breakpoint *breakpoint; |
| 961 | struct cleanup *old_chain; |
| 962 | struct continuation_arg *arg1, *arg2; |
| 963 | |
| 964 | int async_exec = 0; |
| 965 | |
| 966 | /* Find out whether we must run in the background. */ |
| 967 | if (arg != NULL) |
| 968 | async_exec = strip_bg_char (&arg); |
| 969 | |
| 970 | /* If we must run in the background, but the target can't do it, |
| 971 | error out. */ |
| 972 | if (async_p && async_exec && !target_has_async) |
| 973 | error ("Asynchronous execution not supported on this target."); |
| 974 | |
| 975 | /* If we are not asked to run in the bg, then prepare to run in the |
| 976 | foreground, synchronously. */ |
| 977 | if (async_p && !async_exec && target_has_async) |
| 978 | { |
| 979 | /* Simulate synchronous execution */ |
| 980 | sync_execution = 1; |
| 981 | } |
| 982 | |
| 983 | if (arg) |
| 984 | error ("The \"finish\" command does not take any arguments."); |
| 985 | if (!target_has_execution) |
| 986 | error ("The program is not running."); |
| 987 | if (selected_frame == NULL) |
| 988 | error ("No selected frame."); |
| 989 | |
| 990 | frame = get_prev_frame (selected_frame); |
| 991 | if (frame == 0) |
| 992 | error ("\"finish\" not meaningful in the outermost frame."); |
| 993 | |
| 994 | clear_proceed_status (); |
| 995 | |
| 996 | sal = find_pc_line (frame->pc, 0); |
| 997 | sal.pc = frame->pc; |
| 998 | |
| 999 | breakpoint = set_momentary_breakpoint (sal, frame, bp_finish); |
| 1000 | |
| 1001 | if (!async_p || !target_has_async) |
| 1002 | old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); |
| 1003 | else |
| 1004 | make_exec_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); |
| 1005 | |
| 1006 | /* Find the function we will return from. */ |
| 1007 | |
| 1008 | function = find_pc_function (selected_frame->pc); |
| 1009 | |
| 1010 | /* Print info on the selected frame, including level number |
| 1011 | but not source. */ |
| 1012 | if (from_tty) |
| 1013 | { |
| 1014 | printf_filtered ("Run till exit from "); |
| 1015 | print_stack_frame (selected_frame, selected_frame_level, 0); |
| 1016 | } |
| 1017 | |
| 1018 | /* If running asynchronously and the target support asynchronous |
| 1019 | execution, set things up for the rest of the finish command to be |
| 1020 | completed later on, when gdb has detected that the target has |
| 1021 | stopped, in fetch_inferior_event. */ |
| 1022 | if (async_p && target_has_async) |
| 1023 | { |
| 1024 | arg1 = |
| 1025 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 1026 | arg2 = |
| 1027 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
| 1028 | arg1->next = arg2; |
| 1029 | arg2->next = NULL; |
| 1030 | arg1->data = (PTR) breakpoint; |
| 1031 | arg2->data = (PTR) function; |
| 1032 | add_continuation (finish_command_continuation, arg1); |
| 1033 | } |
| 1034 | |
| 1035 | proceed_to_finish = 1; /* We want stop_registers, please... */ |
| 1036 | proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_DEFAULT, 0); |
| 1037 | |
| 1038 | /* Do this only if not running asynchronously or if the target |
| 1039 | cannot do async execution. Otherwise, complete this command when |
| 1040 | the target actually stops, in fetch_inferior_event. */ |
| 1041 | if (!async_p || !target_has_async) |
| 1042 | { |
| 1043 | |
| 1044 | /* Did we stop at our breakpoint? */ |
| 1045 | if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL |
| 1046 | && function != 0) |
| 1047 | { |
| 1048 | struct type *value_type; |
| 1049 | register value_ptr val; |
| 1050 | CORE_ADDR funcaddr; |
| 1051 | int struct_return; |
| 1052 | |
| 1053 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); |
| 1054 | if (!value_type) |
| 1055 | fatal ("internal: finish_command: function has no target type"); |
| 1056 | |
| 1057 | /* FIXME: Shouldn't we do the cleanups before returning? */ |
| 1058 | if (TYPE_CODE (value_type) == TYPE_CODE_VOID) |
| 1059 | return; |
| 1060 | |
| 1061 | funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); |
| 1062 | |
| 1063 | struct_return = |
| 1064 | using_struct_return (value_of_variable (function, NULL), |
| 1065 | funcaddr, |
| 1066 | check_typedef (value_type), |
| 1067 | BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))); |
| 1068 | |
| 1069 | if (!struct_return) |
| 1070 | { |
| 1071 | val = |
| 1072 | value_being_returned (value_type, stop_registers, struct_return); |
| 1073 | printf_filtered ("Value returned is $%d = ", |
| 1074 | record_latest_value (val)); |
| 1075 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); |
| 1076 | printf_filtered ("\n"); |
| 1077 | } |
| 1078 | else |
| 1079 | { |
| 1080 | /* We cannot determine the contents of the structure |
| 1081 | because it is on the stack, and we don't know |
| 1082 | where, since we did not initiate the call, as |
| 1083 | opposed to the call_function_by_hand case */ |
| 1084 | #ifdef VALUE_RETURNED_FROM_STACK |
| 1085 | val = 0; |
| 1086 | printf_filtered ("Value returned has type: %s.", |
| 1087 | TYPE_NAME (value_type)); |
| 1088 | printf_filtered (" Cannot determine contents\n"); |
| 1089 | #else |
| 1090 | val = value_being_returned (value_type, stop_registers, |
| 1091 | struct_return); |
| 1092 | printf_filtered ("Value returned is $%d = ", |
| 1093 | record_latest_value (val)); |
| 1094 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); |
| 1095 | printf_filtered ("\n"); |
| 1096 | #endif |
| 1097 | } |
| 1098 | } |
| 1099 | do_cleanups (old_chain); |
| 1100 | } |
| 1101 | } |
| 1102 | \f |
| 1103 | /* ARGSUSED */ |
| 1104 | static void |
| 1105 | program_info (args, from_tty) |
| 1106 | char *args; |
| 1107 | int from_tty; |
| 1108 | { |
| 1109 | bpstat bs = stop_bpstat; |
| 1110 | int num = bpstat_num (&bs); |
| 1111 | |
| 1112 | if (!target_has_execution) |
| 1113 | { |
| 1114 | printf_filtered ("The program being debugged is not being run.\n"); |
| 1115 | return; |
| 1116 | } |
| 1117 | |
| 1118 | target_files_info (); |
| 1119 | printf_filtered ("Program stopped at %s.\n", |
| 1120 | local_hex_string ((unsigned long) stop_pc)); |
| 1121 | if (stop_step) |
| 1122 | printf_filtered ("It stopped after being stepped.\n"); |
| 1123 | else if (num != 0) |
| 1124 | { |
| 1125 | /* There may be several breakpoints in the same place, so this |
| 1126 | isn't as strange as it seems. */ |
| 1127 | while (num != 0) |
| 1128 | { |
| 1129 | if (num < 0) |
| 1130 | { |
| 1131 | printf_filtered ("It stopped at a breakpoint that has "); |
| 1132 | printf_filtered ("since been deleted.\n"); |
| 1133 | } |
| 1134 | else |
| 1135 | printf_filtered ("It stopped at breakpoint %d.\n", num); |
| 1136 | num = bpstat_num (&bs); |
| 1137 | } |
| 1138 | } |
| 1139 | else if (stop_signal != TARGET_SIGNAL_0) |
| 1140 | { |
| 1141 | printf_filtered ("It stopped with signal %s, %s.\n", |
| 1142 | target_signal_to_name (stop_signal), |
| 1143 | target_signal_to_string (stop_signal)); |
| 1144 | } |
| 1145 | |
| 1146 | if (!from_tty) |
| 1147 | { |
| 1148 | printf_filtered ("Type \"info stack\" or \"info registers\" "); |
| 1149 | printf_filtered ("for more information.\n"); |
| 1150 | } |
| 1151 | } |
| 1152 | \f |
| 1153 | static void |
| 1154 | environment_info (var, from_tty) |
| 1155 | char *var; |
| 1156 | int from_tty; |
| 1157 | { |
| 1158 | if (var) |
| 1159 | { |
| 1160 | register char *val = get_in_environ (inferior_environ, var); |
| 1161 | if (val) |
| 1162 | { |
| 1163 | puts_filtered (var); |
| 1164 | puts_filtered (" = "); |
| 1165 | puts_filtered (val); |
| 1166 | puts_filtered ("\n"); |
| 1167 | } |
| 1168 | else |
| 1169 | { |
| 1170 | puts_filtered ("Environment variable \""); |
| 1171 | puts_filtered (var); |
| 1172 | puts_filtered ("\" not defined.\n"); |
| 1173 | } |
| 1174 | } |
| 1175 | else |
| 1176 | { |
| 1177 | register char **vector = environ_vector (inferior_environ); |
| 1178 | while (*vector) |
| 1179 | { |
| 1180 | puts_filtered (*vector++); |
| 1181 | puts_filtered ("\n"); |
| 1182 | } |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | static void |
| 1187 | set_environment_command (arg, from_tty) |
| 1188 | char *arg; |
| 1189 | int from_tty; |
| 1190 | { |
| 1191 | register char *p, *val, *var; |
| 1192 | int nullset = 0; |
| 1193 | |
| 1194 | if (arg == 0) |
| 1195 | error_no_arg ("environment variable and value"); |
| 1196 | |
| 1197 | /* Find seperation between variable name and value */ |
| 1198 | p = (char *) strchr (arg, '='); |
| 1199 | val = (char *) strchr (arg, ' '); |
| 1200 | |
| 1201 | if (p != 0 && val != 0) |
| 1202 | { |
| 1203 | /* We have both a space and an equals. If the space is before the |
| 1204 | equals, walk forward over the spaces til we see a nonspace |
| 1205 | (possibly the equals). */ |
| 1206 | if (p > val) |
| 1207 | while (*val == ' ') |
| 1208 | val++; |
| 1209 | |
| 1210 | /* Now if the = is after the char following the spaces, |
| 1211 | take the char following the spaces. */ |
| 1212 | if (p > val) |
| 1213 | p = val - 1; |
| 1214 | } |
| 1215 | else if (val != 0 && p == 0) |
| 1216 | p = val; |
| 1217 | |
| 1218 | if (p == arg) |
| 1219 | error_no_arg ("environment variable to set"); |
| 1220 | |
| 1221 | if (p == 0 || p[1] == 0) |
| 1222 | { |
| 1223 | nullset = 1; |
| 1224 | if (p == 0) |
| 1225 | p = arg + strlen (arg); /* So that savestring below will work */ |
| 1226 | } |
| 1227 | else |
| 1228 | { |
| 1229 | /* Not setting variable value to null */ |
| 1230 | val = p + 1; |
| 1231 | while (*val == ' ' || *val == '\t') |
| 1232 | val++; |
| 1233 | } |
| 1234 | |
| 1235 | while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) |
| 1236 | p--; |
| 1237 | |
| 1238 | var = savestring (arg, p - arg); |
| 1239 | if (nullset) |
| 1240 | { |
| 1241 | printf_filtered ("Setting environment variable "); |
| 1242 | printf_filtered ("\"%s\" to null value.\n", var); |
| 1243 | set_in_environ (inferior_environ, var, ""); |
| 1244 | } |
| 1245 | else |
| 1246 | set_in_environ (inferior_environ, var, val); |
| 1247 | free (var); |
| 1248 | } |
| 1249 | |
| 1250 | static void |
| 1251 | unset_environment_command (var, from_tty) |
| 1252 | char *var; |
| 1253 | int from_tty; |
| 1254 | { |
| 1255 | if (var == 0) |
| 1256 | { |
| 1257 | /* If there is no argument, delete all environment variables. |
| 1258 | Ask for confirmation if reading from the terminal. */ |
| 1259 | if (!from_tty || query ("Delete all environment variables? ")) |
| 1260 | { |
| 1261 | free_environ (inferior_environ); |
| 1262 | inferior_environ = make_environ (); |
| 1263 | } |
| 1264 | } |
| 1265 | else |
| 1266 | unset_in_environ (inferior_environ, var); |
| 1267 | } |
| 1268 | |
| 1269 | /* Handle the execution path (PATH variable) */ |
| 1270 | |
| 1271 | static const char path_var_name[] = "PATH"; |
| 1272 | |
| 1273 | /* ARGSUSED */ |
| 1274 | static void |
| 1275 | path_info (args, from_tty) |
| 1276 | char *args; |
| 1277 | int from_tty; |
| 1278 | { |
| 1279 | puts_filtered ("Executable and object file path: "); |
| 1280 | puts_filtered (get_in_environ (inferior_environ, path_var_name)); |
| 1281 | puts_filtered ("\n"); |
| 1282 | } |
| 1283 | |
| 1284 | /* Add zero or more directories to the front of the execution path. */ |
| 1285 | |
| 1286 | static void |
| 1287 | path_command (dirname, from_tty) |
| 1288 | char *dirname; |
| 1289 | int from_tty; |
| 1290 | { |
| 1291 | char *exec_path; |
| 1292 | char *env; |
| 1293 | dont_repeat (); |
| 1294 | env = get_in_environ (inferior_environ, path_var_name); |
| 1295 | /* Can be null if path is not set */ |
| 1296 | if (!env) |
| 1297 | env = ""; |
| 1298 | exec_path = strsave (env); |
| 1299 | mod_path (dirname, &exec_path); |
| 1300 | set_in_environ (inferior_environ, path_var_name, exec_path); |
| 1301 | free (exec_path); |
| 1302 | if (from_tty) |
| 1303 | path_info ((char *) NULL, from_tty); |
| 1304 | } |
| 1305 | \f |
| 1306 | |
| 1307 | #ifdef REGISTER_NAMES |
| 1308 | char *gdb_register_names[] = REGISTER_NAMES; |
| 1309 | #endif |
| 1310 | /* Print out the machine register regnum. If regnum is -1, |
| 1311 | print all registers (fpregs == 1) or all non-float registers |
| 1312 | (fpregs == 0). |
| 1313 | |
| 1314 | For most machines, having all_registers_info() print the |
| 1315 | register(s) one per line is good enough. If a different format |
| 1316 | is required, (eg, for MIPS or Pyramid 90x, which both have |
| 1317 | lots of regs), or there is an existing convention for showing |
| 1318 | all the registers, define the macro DO_REGISTERS_INFO(regnum, fp) |
| 1319 | to provide that format. */ |
| 1320 | |
| 1321 | #if !defined (DO_REGISTERS_INFO) |
| 1322 | |
| 1323 | #define DO_REGISTERS_INFO(regnum, fp) do_registers_info(regnum, fp) |
| 1324 | |
| 1325 | static void |
| 1326 | do_registers_info (regnum, fpregs) |
| 1327 | int regnum; |
| 1328 | int fpregs; |
| 1329 | { |
| 1330 | register int i; |
| 1331 | int numregs = ARCH_NUM_REGS; |
| 1332 | |
| 1333 | for (i = 0; i < numregs; i++) |
| 1334 | { |
| 1335 | char raw_buffer[MAX_REGISTER_RAW_SIZE]; |
| 1336 | char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; |
| 1337 | |
| 1338 | /* Decide between printing all regs, nonfloat regs, or specific reg. */ |
| 1339 | if (regnum == -1) |
| 1340 | { |
| 1341 | if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs) |
| 1342 | continue; |
| 1343 | } |
| 1344 | else |
| 1345 | { |
| 1346 | if (i != regnum) |
| 1347 | continue; |
| 1348 | } |
| 1349 | |
| 1350 | /* If the register name is empty, it is undefined for this |
| 1351 | processor, so don't display anything. */ |
| 1352 | if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0') |
| 1353 | continue; |
| 1354 | |
| 1355 | fputs_filtered (REGISTER_NAME (i), gdb_stdout); |
| 1356 | print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout); |
| 1357 | |
| 1358 | /* Get the data in raw format. */ |
| 1359 | if (read_relative_register_raw_bytes (i, raw_buffer)) |
| 1360 | { |
| 1361 | printf_filtered ("*value not available*\n"); |
| 1362 | continue; |
| 1363 | } |
| 1364 | |
| 1365 | /* Convert raw data to virtual format if necessary. */ |
| 1366 | if (REGISTER_CONVERTIBLE (i)) |
| 1367 | { |
| 1368 | REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i), |
| 1369 | raw_buffer, virtual_buffer); |
| 1370 | } |
| 1371 | else |
| 1372 | { |
| 1373 | memcpy (virtual_buffer, raw_buffer, |
| 1374 | REGISTER_VIRTUAL_SIZE (i)); |
| 1375 | } |
| 1376 | |
| 1377 | /* If virtual format is floating, print it that way, and in raw hex. */ |
| 1378 | if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT) |
| 1379 | { |
| 1380 | register int j; |
| 1381 | |
| 1382 | #ifdef INVALID_FLOAT |
| 1383 | if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i))) |
| 1384 | printf_filtered ("<invalid float>"); |
| 1385 | else |
| 1386 | #endif |
| 1387 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, |
| 1388 | gdb_stdout, 0, 1, 0, Val_pretty_default); |
| 1389 | |
| 1390 | printf_filtered ("\t(raw 0x"); |
| 1391 | for (j = 0; j < REGISTER_RAW_SIZE (i); j++) |
| 1392 | { |
| 1393 | register int idx = TARGET_BYTE_ORDER == BIG_ENDIAN ? j |
| 1394 | : REGISTER_RAW_SIZE (i) - 1 - j; |
| 1395 | printf_filtered ("%02x", (unsigned char) raw_buffer[idx]); |
| 1396 | } |
| 1397 | printf_filtered (")"); |
| 1398 | } |
| 1399 | |
| 1400 | /* FIXME! val_print probably can handle all of these cases now... */ |
| 1401 | |
| 1402 | /* Else if virtual format is too long for printf, |
| 1403 | print in hex a byte at a time. */ |
| 1404 | else if (REGISTER_VIRTUAL_SIZE (i) > (int) sizeof (long)) |
| 1405 | { |
| 1406 | register int j; |
| 1407 | printf_filtered ("0x"); |
| 1408 | for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++) |
| 1409 | printf_filtered ("%02x", (unsigned char) virtual_buffer[j]); |
| 1410 | } |
| 1411 | /* Else print as integer in hex and in decimal. */ |
| 1412 | else |
| 1413 | { |
| 1414 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, |
| 1415 | gdb_stdout, 'x', 1, 0, Val_pretty_default); |
| 1416 | printf_filtered ("\t"); |
| 1417 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, |
| 1418 | gdb_stdout, 0, 1, 0, Val_pretty_default); |
| 1419 | } |
| 1420 | |
| 1421 | /* The SPARC wants to print even-numbered float regs as doubles |
| 1422 | in addition to printing them as floats. */ |
| 1423 | #ifdef PRINT_REGISTER_HOOK |
| 1424 | PRINT_REGISTER_HOOK (i); |
| 1425 | #endif |
| 1426 | |
| 1427 | printf_filtered ("\n"); |
| 1428 | } |
| 1429 | } |
| 1430 | #endif /* no DO_REGISTERS_INFO. */ |
| 1431 | |
| 1432 | void |
| 1433 | registers_info (addr_exp, fpregs) |
| 1434 | char *addr_exp; |
| 1435 | int fpregs; |
| 1436 | { |
| 1437 | int regnum, numregs; |
| 1438 | register char *end; |
| 1439 | |
| 1440 | if (!target_has_registers) |
| 1441 | error ("The program has no registers now."); |
| 1442 | if (selected_frame == NULL) |
| 1443 | error ("No selected frame."); |
| 1444 | |
| 1445 | if (!addr_exp) |
| 1446 | { |
| 1447 | DO_REGISTERS_INFO (-1, fpregs); |
| 1448 | return; |
| 1449 | } |
| 1450 | |
| 1451 | do |
| 1452 | { |
| 1453 | if (addr_exp[0] == '$') |
| 1454 | addr_exp++; |
| 1455 | end = addr_exp; |
| 1456 | while (*end != '\0' && *end != ' ' && *end != '\t') |
| 1457 | ++end; |
| 1458 | numregs = ARCH_NUM_REGS; |
| 1459 | |
| 1460 | regnum = target_map_name_to_register (addr_exp, end - addr_exp); |
| 1461 | if (regnum >= 0) |
| 1462 | goto found; |
| 1463 | |
| 1464 | regnum = numregs; |
| 1465 | |
| 1466 | if (*addr_exp >= '0' && *addr_exp <= '9') |
| 1467 | regnum = atoi (addr_exp); /* Take a number */ |
| 1468 | if (regnum >= numregs) /* Bad name, or bad number */ |
| 1469 | error ("%.*s: invalid register", end - addr_exp, addr_exp); |
| 1470 | |
| 1471 | found: |
| 1472 | DO_REGISTERS_INFO (regnum, fpregs); |
| 1473 | |
| 1474 | addr_exp = end; |
| 1475 | while (*addr_exp == ' ' || *addr_exp == '\t') |
| 1476 | ++addr_exp; |
| 1477 | } |
| 1478 | while (*addr_exp != '\0'); |
| 1479 | } |
| 1480 | |
| 1481 | void |
| 1482 | all_registers_info (addr_exp, from_tty) |
| 1483 | char *addr_exp; |
| 1484 | int from_tty; |
| 1485 | { |
| 1486 | registers_info (addr_exp, 1); |
| 1487 | } |
| 1488 | |
| 1489 | void |
| 1490 | nofp_registers_info (addr_exp, from_tty) |
| 1491 | char *addr_exp; |
| 1492 | int from_tty; |
| 1493 | { |
| 1494 | registers_info (addr_exp, 0); |
| 1495 | } |
| 1496 | \f |
| 1497 | |
| 1498 | /* |
| 1499 | * TODO: |
| 1500 | * Should save/restore the tty state since it might be that the |
| 1501 | * program to be debugged was started on this tty and it wants |
| 1502 | * the tty in some state other than what we want. If it's running |
| 1503 | * on another terminal or without a terminal, then saving and |
| 1504 | * restoring the tty state is a harmless no-op. |
| 1505 | * This only needs to be done if we are attaching to a process. |
| 1506 | */ |
| 1507 | |
| 1508 | /* |
| 1509 | attach_command -- |
| 1510 | takes a program started up outside of gdb and ``attaches'' to it. |
| 1511 | This stops it cold in its tracks and allows us to start debugging it. |
| 1512 | and wait for the trace-trap that results from attaching. */ |
| 1513 | |
| 1514 | void |
| 1515 | attach_command (args, from_tty) |
| 1516 | char *args; |
| 1517 | int from_tty; |
| 1518 | { |
| 1519 | #ifdef SOLIB_ADD |
| 1520 | extern int auto_solib_add; |
| 1521 | #endif |
| 1522 | |
| 1523 | char *exec_file; |
| 1524 | char *full_exec_path = NULL; |
| 1525 | |
| 1526 | dont_repeat (); /* Not for the faint of heart */ |
| 1527 | |
| 1528 | if (target_has_execution) |
| 1529 | { |
| 1530 | if (query ("A program is being debugged already. Kill it? ")) |
| 1531 | target_kill (); |
| 1532 | else |
| 1533 | error ("Not killed."); |
| 1534 | } |
| 1535 | |
| 1536 | target_attach (args, from_tty); |
| 1537 | |
| 1538 | /* Set up the "saved terminal modes" of the inferior |
| 1539 | based on what modes we are starting it with. */ |
| 1540 | target_terminal_init (); |
| 1541 | |
| 1542 | /* Install inferior's terminal modes. */ |
| 1543 | target_terminal_inferior (); |
| 1544 | |
| 1545 | /* Set up execution context to know that we should return from |
| 1546 | wait_for_inferior as soon as the target reports a stop. */ |
| 1547 | init_wait_for_inferior (); |
| 1548 | clear_proceed_status (); |
| 1549 | stop_soon_quietly = 1; |
| 1550 | |
| 1551 | /* No traps are generated when attaching to inferior under Mach 3 |
| 1552 | or GNU hurd. */ |
| 1553 | #ifndef ATTACH_NO_WAIT |
| 1554 | wait_for_inferior (); |
| 1555 | #endif |
| 1556 | |
| 1557 | /* |
| 1558 | * If no exec file is yet known, try to determine it from the |
| 1559 | * process itself. |
| 1560 | */ |
| 1561 | exec_file = (char *) get_exec_file (0); |
| 1562 | if (!exec_file) |
| 1563 | { |
| 1564 | exec_file = target_pid_to_exec_file (inferior_pid); |
| 1565 | if (exec_file) |
| 1566 | { |
| 1567 | /* It's possible we don't have a full path, but rather just a |
| 1568 | filename. Some targets, such as HP-UX, don't provide the |
| 1569 | full path, sigh. |
| 1570 | |
| 1571 | Attempt to qualify the filename against the source path. |
| 1572 | (If that fails, we'll just fall back on the original |
| 1573 | filename. Not much more we can do...) |
| 1574 | */ |
| 1575 | if (!source_full_path_of (exec_file, &full_exec_path)) |
| 1576 | full_exec_path = savestring (exec_file, strlen (exec_file)); |
| 1577 | |
| 1578 | exec_file_attach (full_exec_path, from_tty); |
| 1579 | symbol_file_command (full_exec_path, from_tty); |
| 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | #ifdef SOLIB_ADD |
| 1584 | if (auto_solib_add) |
| 1585 | { |
| 1586 | /* Add shared library symbols from the newly attached process, if any. */ |
| 1587 | SOLIB_ADD ((char *) 0, from_tty, ¤t_target); |
| 1588 | re_enable_breakpoints_in_shlibs (); |
| 1589 | } |
| 1590 | #endif |
| 1591 | |
| 1592 | /* Take any necessary post-attaching actions for this platform. |
| 1593 | */ |
| 1594 | target_post_attach (inferior_pid); |
| 1595 | |
| 1596 | normal_stop (); |
| 1597 | } |
| 1598 | |
| 1599 | /* |
| 1600 | * detach_command -- |
| 1601 | * takes a program previously attached to and detaches it. |
| 1602 | * The program resumes execution and will no longer stop |
| 1603 | * on signals, etc. We better not have left any breakpoints |
| 1604 | * in the program or it'll die when it hits one. For this |
| 1605 | * to work, it may be necessary for the process to have been |
| 1606 | * previously attached. It *might* work if the program was |
| 1607 | * started via the normal ptrace (PTRACE_TRACEME). |
| 1608 | */ |
| 1609 | |
| 1610 | static void |
| 1611 | detach_command (args, from_tty) |
| 1612 | char *args; |
| 1613 | int from_tty; |
| 1614 | { |
| 1615 | dont_repeat (); /* Not for the faint of heart */ |
| 1616 | target_detach (args, from_tty); |
| 1617 | #if defined(SOLIB_RESTART) |
| 1618 | SOLIB_RESTART (); |
| 1619 | #endif |
| 1620 | } |
| 1621 | |
| 1622 | /* Stop the execution of the target while running in async mode, in |
| 1623 | the backgound. */ |
| 1624 | static void |
| 1625 | interrupt_target_command (args, from_tty) |
| 1626 | char *args; |
| 1627 | int from_tty; |
| 1628 | { |
| 1629 | if (async_p && target_has_async) |
| 1630 | { |
| 1631 | dont_repeat (); /* Not for the faint of heart */ |
| 1632 | target_stop (); |
| 1633 | } |
| 1634 | } |
| 1635 | |
| 1636 | /* ARGSUSED */ |
| 1637 | static void |
| 1638 | float_info (addr_exp, from_tty) |
| 1639 | char *addr_exp; |
| 1640 | int from_tty; |
| 1641 | { |
| 1642 | #ifdef FLOAT_INFO |
| 1643 | FLOAT_INFO; |
| 1644 | #else |
| 1645 | printf_filtered ("No floating point info available for this processor.\n"); |
| 1646 | #endif |
| 1647 | } |
| 1648 | \f |
| 1649 | /* ARGSUSED */ |
| 1650 | static void |
| 1651 | unset_command (args, from_tty) |
| 1652 | char *args; |
| 1653 | int from_tty; |
| 1654 | { |
| 1655 | printf_filtered ("\"unset\" must be followed by the name of "); |
| 1656 | printf_filtered ("an unset subcommand.\n"); |
| 1657 | help_list (unsetlist, "unset ", -1, gdb_stdout); |
| 1658 | } |
| 1659 | |
| 1660 | void |
| 1661 | _initialize_infcmd () |
| 1662 | { |
| 1663 | struct cmd_list_element *c; |
| 1664 | |
| 1665 | add_com ("tty", class_run, tty_command, |
| 1666 | "Set terminal for future runs of program being debugged."); |
| 1667 | |
| 1668 | add_show_from_set |
| 1669 | (add_set_cmd ("args", class_run, var_string_noescape, |
| 1670 | (char *) &inferior_args, |
| 1671 | "Set argument list to give program being debugged when it is started.\n\ |
| 1672 | Follow this command with any number of args, to be passed to the program.", |
| 1673 | &setlist), |
| 1674 | &showlist); |
| 1675 | |
| 1676 | c = add_cmd |
| 1677 | ("environment", no_class, environment_info, |
| 1678 | "The environment to give the program, or one variable's value.\n\ |
| 1679 | With an argument VAR, prints the value of environment variable VAR to\n\ |
| 1680 | give the program being debugged. With no arguments, prints the entire\n\ |
| 1681 | environment to be given to the program.", &showlist); |
| 1682 | c->completer = noop_completer; |
| 1683 | |
| 1684 | add_prefix_cmd ("unset", no_class, unset_command, |
| 1685 | "Complement to certain \"set\" commands", |
| 1686 | &unsetlist, "unset ", 0, &cmdlist); |
| 1687 | |
| 1688 | c = add_cmd ("environment", class_run, unset_environment_command, |
| 1689 | "Cancel environment variable VAR for the program.\n\ |
| 1690 | This does not affect the program until the next \"run\" command.", |
| 1691 | &unsetlist); |
| 1692 | c->completer = noop_completer; |
| 1693 | |
| 1694 | c = add_cmd ("environment", class_run, set_environment_command, |
| 1695 | "Set environment variable value to give the program.\n\ |
| 1696 | Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ |
| 1697 | VALUES of environment variables are uninterpreted strings.\n\ |
| 1698 | This does not affect the program until the next \"run\" command.", |
| 1699 | &setlist); |
| 1700 | c->completer = noop_completer; |
| 1701 | |
| 1702 | add_com ("path", class_files, path_command, |
| 1703 | "Add directory DIR(s) to beginning of search path for object files.\n\ |
| 1704 | $cwd in the path means the current working directory.\n\ |
| 1705 | This path is equivalent to the $PATH shell variable. It is a list of\n\ |
| 1706 | directories, separated by colons. These directories are searched to find\n\ |
| 1707 | fully linked executable files and separately compiled object files as needed."); |
| 1708 | |
| 1709 | c = add_cmd ("paths", no_class, path_info, |
| 1710 | "Current search path for finding object files.\n\ |
| 1711 | $cwd in the path means the current working directory.\n\ |
| 1712 | This path is equivalent to the $PATH shell variable. It is a list of\n\ |
| 1713 | directories, separated by colons. These directories are searched to find\n\ |
| 1714 | fully linked executable files and separately compiled object files as needed.", |
| 1715 | &showlist); |
| 1716 | c->completer = noop_completer; |
| 1717 | |
| 1718 | add_com ("attach", class_run, attach_command, |
| 1719 | "Attach to a process or file outside of GDB.\n\ |
| 1720 | This command attaches to another target, of the same type as your last\n\ |
| 1721 | \"target\" command (\"info files\" will show your target stack).\n\ |
| 1722 | The command may take as argument a process id or a device file.\n\ |
| 1723 | For a process id, you must have permission to send the process a signal,\n\ |
| 1724 | and it must have the same effective uid as the debugger.\n\ |
| 1725 | When using \"attach\" with a process id, the debugger finds the\n\ |
| 1726 | program running in the process, looking first in the current working\n\ |
| 1727 | directory, or (if not found there) using the source file search path\n\ |
| 1728 | (see the \"directory\" command). You can also use the \"file\" command\n\ |
| 1729 | to specify the program, and to load its symbol table."); |
| 1730 | |
| 1731 | add_com ("detach", class_run, detach_command, |
| 1732 | "Detach a process or file previously attached.\n\ |
| 1733 | If a process, it is no longer traced, and it continues its execution. If\n\ |
| 1734 | you were debugging a file, the file is closed and gdb no longer accesses it."); |
| 1735 | |
| 1736 | add_com ("signal", class_run, signal_command, |
| 1737 | "Continue program giving it signal specified by the argument.\n\ |
| 1738 | An argument of \"0\" means continue program without giving it a signal."); |
| 1739 | |
| 1740 | add_com ("stepi", class_run, stepi_command, |
| 1741 | "Step one instruction exactly.\n\ |
| 1742 | Argument N means do this N times (or till program stops for another reason)."); |
| 1743 | add_com_alias ("si", "stepi", class_alias, 0); |
| 1744 | |
| 1745 | add_com ("nexti", class_run, nexti_command, |
| 1746 | "Step one instruction, but proceed through subroutine calls.\n\ |
| 1747 | Argument N means do this N times (or till program stops for another reason)."); |
| 1748 | add_com_alias ("ni", "nexti", class_alias, 0); |
| 1749 | |
| 1750 | add_com ("finish", class_run, finish_command, |
| 1751 | "Execute until selected stack frame returns.\n\ |
| 1752 | Upon return, the value returned is printed and put in the value history."); |
| 1753 | |
| 1754 | add_com ("next", class_run, next_command, |
| 1755 | "Step program, proceeding through subroutine calls.\n\ |
| 1756 | Like the \"step\" command as long as subroutine calls do not happen;\n\ |
| 1757 | when they do, the call is treated as one instruction.\n\ |
| 1758 | Argument N means do this N times (or till program stops for another reason)."); |
| 1759 | add_com_alias ("n", "next", class_run, 1); |
| 1760 | if (xdb_commands) |
| 1761 | add_com_alias ("S", "next", class_run, 1); |
| 1762 | |
| 1763 | add_com ("step", class_run, step_command, |
| 1764 | "Step program until it reaches a different source line.\n\ |
| 1765 | Argument N means do this N times (or till program stops for another reason)."); |
| 1766 | add_com_alias ("s", "step", class_run, 1); |
| 1767 | |
| 1768 | add_com ("until", class_run, until_command, |
| 1769 | "Execute until the program reaches a source line greater than the current\n\ |
| 1770 | or a specified line or address or function (same args as break command).\n\ |
| 1771 | Execution will also stop upon exit from the current stack frame."); |
| 1772 | add_com_alias ("u", "until", class_run, 1); |
| 1773 | |
| 1774 | add_com ("jump", class_run, jump_command, |
| 1775 | "Continue program being debugged at specified line or address.\n\ |
| 1776 | Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ |
| 1777 | for an address to start at."); |
| 1778 | |
| 1779 | if (xdb_commands) |
| 1780 | add_com ("go", class_run, go_command, |
| 1781 | "Usage: go <location>\n\ |
| 1782 | Continue program being debugged, stopping at specified line or \n\ |
| 1783 | address.\n\ |
| 1784 | Give as argument either LINENUM or *ADDR, where ADDR is an \n\ |
| 1785 | expression for an address to start at.\n\ |
| 1786 | This command is a combination of tbreak and jump."); |
| 1787 | |
| 1788 | if (xdb_commands) |
| 1789 | add_com_alias ("g", "go", class_run, 1); |
| 1790 | |
| 1791 | add_com ("continue", class_run, continue_command, |
| 1792 | "Continue program being debugged, after signal or breakpoint.\n\ |
| 1793 | If proceeding from breakpoint, a number N may be used as an argument,\n\ |
| 1794 | which means to set the ignore count of that breakpoint to N - 1 (so that\n\ |
| 1795 | the breakpoint won't break until the Nth time it is reached)."); |
| 1796 | add_com_alias ("c", "cont", class_run, 1); |
| 1797 | add_com_alias ("fg", "cont", class_run, 1); |
| 1798 | |
| 1799 | add_com ("run", class_run, run_command, |
| 1800 | "Start debugged program. You may specify arguments to give it.\n\ |
| 1801 | Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ |
| 1802 | Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\ |
| 1803 | With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\ |
| 1804 | To cancel previous arguments and run with no arguments,\n\ |
| 1805 | use \"set args\" without arguments."); |
| 1806 | add_com_alias ("r", "run", class_run, 1); |
| 1807 | if (xdb_commands) |
| 1808 | add_com ("R", class_run, run_no_args_command, |
| 1809 | "Start debugged program with no arguments."); |
| 1810 | |
| 1811 | add_com ("interrupt", class_run, interrupt_target_command, |
| 1812 | "Interrupt the execution of the debugged program."); |
| 1813 | |
| 1814 | add_info ("registers", nofp_registers_info, |
| 1815 | "List of integer registers and their contents, for selected stack frame.\n\ |
| 1816 | Register name as argument means describe only that register."); |
| 1817 | |
| 1818 | if (xdb_commands) |
| 1819 | add_com ("lr", class_info, nofp_registers_info, |
| 1820 | "List of integer registers and their contents, for selected stack frame.\n\ |
| 1821 | Register name as argument means describe only that register."); |
| 1822 | add_info ("all-registers", all_registers_info, |
| 1823 | "List of all registers and their contents, for selected stack frame.\n\ |
| 1824 | Register name as argument means describe only that register."); |
| 1825 | |
| 1826 | add_info ("program", program_info, |
| 1827 | "Execution status of the program."); |
| 1828 | |
| 1829 | add_info ("float", float_info, |
| 1830 | "Print the status of the floating point unit\n"); |
| 1831 | |
| 1832 | inferior_args = savestring ("", 1); /* Initially no args */ |
| 1833 | inferior_environ = make_environ (); |
| 1834 | init_environ (inferior_environ); |
| 1835 | } |