stack.c revision 194061
1/* Print and select stack frames for GDB, the GNU debugger. 2 3 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free 5 Software Foundation, Inc. 6 7 This file is part of GDB. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, 22 Boston, MA 02111-1307, USA. */ 23 24#include <ctype.h> 25#include "defs.h" 26#include "gdb_string.h" 27#include "value.h" 28#include "symtab.h" 29#include "gdbtypes.h" 30#include "expression.h" 31#include "language.h" 32#include "frame.h" 33#include "gdbcmd.h" 34#include "gdbcore.h" 35#include "target.h" 36#include "source.h" 37#include "breakpoint.h" 38#include "demangle.h" 39#include "inferior.h" 40#include "annotate.h" 41#include "ui-out.h" 42#include "block.h" 43#include "stack.h" 44#include "gdb_assert.h" 45#include "dictionary.h" 46#include "reggroups.h" 47#include "regcache.h" 48 49/* Prototypes for exported functions. */ 50 51void args_info (char *, int); 52 53void locals_info (char *, int); 54 55void (*selected_frame_level_changed_hook) (int); 56 57void _initialize_stack (void); 58 59/* Prototypes for local functions. */ 60 61static void down_command (char *, int); 62 63static void down_silently_base (char *); 64 65static void down_silently_command (char *, int); 66 67static void up_command (char *, int); 68 69static void up_silently_base (char *); 70 71static void up_silently_command (char *, int); 72 73void frame_command (char *, int); 74 75static void current_frame_command (char *, int); 76 77static void print_frame_arg_vars (struct frame_info *, struct ui_file *); 78 79static void catch_info (char *, int); 80 81static void args_plus_locals_info (char *, int); 82 83static void print_frame_label_vars (struct frame_info *, int, 84 struct ui_file *); 85 86static void print_frame_local_vars (struct frame_info *, int, 87 struct ui_file *); 88 89static int print_block_frame_labels (struct block *, int *, 90 struct ui_file *); 91 92static int print_block_frame_locals (struct block *, 93 struct frame_info *, 94 int, 95 struct ui_file *); 96 97static void print_frame (struct frame_info *fi, 98 int level, 99 int source, 100 int args, 101 struct symtab_and_line sal); 102 103static void backtrace_command (char *, int); 104 105struct frame_info *parse_frame_specification (char *); 106 107static void frame_info (char *, int); 108 109extern int addressprint; /* Print addresses, or stay symbolic only? */ 110 111/* Zero means do things normally; we are interacting directly with the 112 user. One means print the full filename and linenumber when a 113 frame is printed, and do so in a format emacs18/emacs19.22 can 114 parse. Two means print similar annotations, but in many more 115 cases and in a slightly different syntax. */ 116 117int annotation_level = 0; 118 119 120struct print_stack_frame_args 121 { 122 struct frame_info *fi; 123 int level; 124 int source; 125 int args; 126 }; 127 128/* Show or print the frame arguments. 129 Pass the args the way catch_errors wants them. */ 130static int print_stack_frame_stub (void *args); 131static int 132print_stack_frame_stub (void *args) 133{ 134 struct print_stack_frame_args *p = (struct print_stack_frame_args *) args; 135 136 print_frame_info (p->fi, p->level, p->source, p->args); 137 return 0; 138} 139 140/* Show or print a stack frame briefly. FRAME_INFI should be the frame info 141 and LEVEL should be its level in the stack (or -1 for level not defined). 142 This prints the level, the function executing, the arguments, 143 and the file name and line number. 144 If the pc is not at the beginning of the source line, 145 the actual pc is printed at the beginning. 146 147 If SOURCE is 1, print the source line as well. 148 If SOURCE is -1, print ONLY the source line. */ 149 150void 151print_stack_frame (struct frame_info *fi, int level, int source) 152{ 153 struct print_stack_frame_args args; 154 155 args.fi = fi; 156 args.level = level; 157 args.source = source; 158 args.args = 1; 159 160 catch_errors (print_stack_frame_stub, (char *) &args, "", RETURN_MASK_ALL); 161} 162 163struct print_args_args 164{ 165 struct symbol *func; 166 struct frame_info *fi; 167 struct ui_file *stream; 168}; 169 170static int print_args_stub (void *); 171 172/* Print nameless args on STREAM. 173 FI is the frameinfo for this frame, START is the offset 174 of the first nameless arg, and NUM is the number of nameless args to 175 print. FIRST is nonzero if this is the first argument (not just 176 the first nameless arg). */ 177 178static void 179print_frame_nameless_args (struct frame_info *fi, long start, int num, 180 int first, struct ui_file *stream) 181{ 182 int i; 183 CORE_ADDR argsaddr; 184 long arg_value; 185 186 for (i = 0; i < num; i++) 187 { 188 QUIT; 189 argsaddr = get_frame_args_address (fi); 190 if (!argsaddr) 191 return; 192 arg_value = read_memory_integer (argsaddr + start, sizeof (int)); 193 if (!first) 194 fprintf_filtered (stream, ", "); 195 fprintf_filtered (stream, "%ld", arg_value); 196 first = 0; 197 start += sizeof (int); 198 } 199} 200 201/* Print the arguments of a stack frame, given the function FUNC 202 running in that frame (as a symbol), the info on the frame, 203 and the number of args according to the stack frame (or -1 if unknown). */ 204 205/* References here and elsewhere to "number of args according to the 206 stack frame" appear in all cases to refer to "number of ints of args 207 according to the stack frame". At least for VAX, i386, isi. */ 208 209static void 210print_frame_args (struct symbol *func, struct frame_info *fi, int num, 211 struct ui_file *stream) 212{ 213 struct block *b = NULL; 214 int first = 1; 215 struct dict_iterator iter; 216 struct symbol *sym; 217 struct value *val; 218 /* Offset of next stack argument beyond the one we have seen that is 219 at the highest offset. 220 -1 if we haven't come to a stack argument yet. */ 221 long highest_offset = -1; 222 int arg_size; 223 /* Number of ints of arguments that we have printed so far. */ 224 int args_printed = 0; 225 struct cleanup *old_chain, *list_chain; 226 struct ui_stream *stb; 227 228 stb = ui_out_stream_new (uiout); 229 old_chain = make_cleanup_ui_out_stream_delete (stb); 230 231 if (func) 232 { 233 b = SYMBOL_BLOCK_VALUE (func); 234 235 ALL_BLOCK_SYMBOLS (b, iter, sym) 236 { 237 QUIT; 238 239 /* Keep track of the highest stack argument offset seen, and 240 skip over any kinds of symbols we don't care about. */ 241 242 switch (SYMBOL_CLASS (sym)) 243 { 244 case LOC_ARG: 245 case LOC_REF_ARG: 246 { 247 long current_offset = SYMBOL_VALUE (sym); 248 arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); 249 250 /* Compute address of next argument by adding the size of 251 this argument and rounding to an int boundary. */ 252 current_offset = 253 ((current_offset + arg_size + sizeof (int) - 1) 254 & ~(sizeof (int) - 1)); 255 256 /* If this is the highest offset seen yet, set highest_offset. */ 257 if (highest_offset == -1 258 || (current_offset > highest_offset)) 259 highest_offset = current_offset; 260 261 /* Add the number of ints we're about to print to args_printed. */ 262 args_printed += (arg_size + sizeof (int) - 1) / sizeof (int); 263 } 264 265 /* We care about types of symbols, but don't need to keep track of 266 stack offsets in them. */ 267 case LOC_REGPARM: 268 case LOC_REGPARM_ADDR: 269 case LOC_LOCAL_ARG: 270 case LOC_BASEREG_ARG: 271 case LOC_COMPUTED_ARG: 272 break; 273 274 /* Other types of symbols we just skip over. */ 275 default: 276 continue; 277 } 278 279 /* We have to look up the symbol because arguments can have 280 two entries (one a parameter, one a local) and the one we 281 want is the local, which lookup_symbol will find for us. 282 This includes gcc1 (not gcc2) on the sparc when passing a 283 small structure and gcc2 when the argument type is float 284 and it is passed as a double and converted to float by 285 the prologue (in the latter case the type of the LOC_ARG 286 symbol is double and the type of the LOC_LOCAL symbol is 287 float). */ 288 /* But if the parameter name is null, don't try it. 289 Null parameter names occur on the RS/6000, for traceback tables. 290 FIXME, should we even print them? */ 291 292 if (*DEPRECATED_SYMBOL_NAME (sym)) 293 { 294 struct symbol *nsym; 295 nsym = lookup_symbol 296 (DEPRECATED_SYMBOL_NAME (sym), 297 b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); 298 if (SYMBOL_CLASS (nsym) == LOC_REGISTER) 299 { 300 /* There is a LOC_ARG/LOC_REGISTER pair. This means that 301 it was passed on the stack and loaded into a register, 302 or passed in a register and stored in a stack slot. 303 GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER. 304 305 Reasons for using the LOC_ARG: 306 (1) because find_saved_registers may be slow for remote 307 debugging, 308 (2) because registers are often re-used and stack slots 309 rarely (never?) are. Therefore using the stack slot is 310 much less likely to print garbage. 311 312 Reasons why we might want to use the LOC_REGISTER: 313 (1) So that the backtrace prints the same value as 314 "print foo". I see no compelling reason why this needs 315 to be the case; having the backtrace print the value which 316 was passed in, and "print foo" print the value as modified 317 within the called function, makes perfect sense to me. 318 319 Additional note: It might be nice if "info args" displayed 320 both values. 321 One more note: There is a case with sparc structure passing 322 where we need to use the LOC_REGISTER, but this is dealt with 323 by creating a single LOC_REGPARM in symbol reading. */ 324 325 /* Leave sym (the LOC_ARG) alone. */ 326 ; 327 } 328 else 329 sym = nsym; 330 } 331 332 /* Print the current arg. */ 333 if (!first) 334 ui_out_text (uiout, ", "); 335 ui_out_wrap_hint (uiout, " "); 336 337 annotate_arg_begin (); 338 339 list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 340 fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym), 341 SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI); 342 ui_out_field_stream (uiout, "name", stb); 343 annotate_arg_name_end (); 344 ui_out_text (uiout, "="); 345 346 /* Avoid value_print because it will deref ref parameters. We just 347 want to print their addresses. Print ??? for args whose address 348 we do not know. We pass 2 as "recurse" to val_print because our 349 standard indentation here is 4 spaces, and val_print indents 350 2 for each recurse. */ 351 val = read_var_value (sym, fi); 352 353 annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val)); 354 355 if (val) 356 { 357 val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0, 358 VALUE_ADDRESS (val), 359 stb->stream, 0, 0, 2, Val_no_prettyprint); 360 ui_out_field_stream (uiout, "value", stb); 361 } 362 else 363 ui_out_text (uiout, "???"); 364 365 /* Invoke ui_out_tuple_end. */ 366 do_cleanups (list_chain); 367 368 annotate_arg_end (); 369 370 first = 0; 371 } 372 } 373 374 /* Don't print nameless args in situations where we don't know 375 enough about the stack to find them. */ 376 if (num != -1) 377 { 378 long start; 379 380 if (highest_offset == -1) 381 start = FRAME_ARGS_SKIP; 382 else 383 start = highest_offset; 384 385 print_frame_nameless_args (fi, start, num - args_printed, 386 first, stream); 387 } 388 do_cleanups (old_chain); 389} 390 391/* Pass the args the way catch_errors wants them. */ 392 393static int 394print_args_stub (void *args) 395{ 396 int numargs; 397 struct print_args_args *p = (struct print_args_args *) args; 398 399 if (FRAME_NUM_ARGS_P ()) 400 { 401 numargs = FRAME_NUM_ARGS (p->fi); 402 gdb_assert (numargs >= 0); 403 } 404 else 405 numargs = -1; 406 print_frame_args (p->func, p->fi, numargs, p->stream); 407 return 0; 408} 409 410/* Print information about a frame for frame "fi" at level "level". 411 Used in "where" output, also used to emit breakpoint or step 412 messages. 413 LEVEL is the level of the frame, or -1 if it is the 414 innermost frame but we don't want to print the level. 415 The meaning of the SOURCE argument is: 416 SRC_LINE: Print only source line 417 LOCATION: Print only location 418 LOC_AND_SRC: Print location and source line. */ 419 420void 421print_frame_info (struct frame_info *fi, int level, int source, int args) 422{ 423 struct symtab_and_line sal; 424 int source_print; 425 int location_print; 426 427 if (get_frame_type (fi) == DUMMY_FRAME 428 || get_frame_type (fi) == SIGTRAMP_FRAME) 429 { 430 struct cleanup *uiout_cleanup 431 = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); 432 433 annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi)); 434 435 /* Do this regardless of SOURCE because we don't have any source 436 to list for this frame. */ 437 if (level >= 0) 438 { 439 ui_out_text (uiout, "#"); 440 ui_out_field_fmt_int (uiout, 2, ui_left, "level", level); 441 } 442 if (ui_out_is_mi_like_p (uiout)) 443 { 444 annotate_frame_address (); 445 ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); 446 annotate_frame_address_end (); 447 } 448 449 if (get_frame_type (fi) == DUMMY_FRAME) 450 { 451 annotate_function_call (); 452 ui_out_field_string (uiout, "func", "<function called from gdb>"); 453 } 454 else if (get_frame_type (fi) == SIGTRAMP_FRAME) 455 { 456 annotate_signal_handler_caller (); 457 ui_out_field_string (uiout, "func", "<signal handler called>"); 458 } 459 ui_out_text (uiout, "\n"); 460 annotate_frame_end (); 461 462 do_cleanups (uiout_cleanup); 463 return; 464 } 465 466 /* If fi is not the innermost frame, that normally means that fi->pc 467 points to *after* the call instruction, and we want to get the 468 line containing the call, never the next line. But if the next 469 frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the next frame 470 was not entered as the result of a call, and we want to get the 471 line containing fi->pc. */ 472 find_frame_sal (fi, &sal); 473 474 location_print = (source == LOCATION 475 || source == LOC_AND_ADDRESS 476 || source == SRC_AND_LOC); 477 478 if (location_print || !sal.symtab) 479 print_frame (fi, level, source, args, sal); 480 481 source_print = (source == SRC_LINE || source == SRC_AND_LOC); 482 483 if (sal.symtab) 484 set_current_source_symtab_and_line (&sal); 485 486 if (source_print && sal.symtab) 487 { 488 struct symtab_and_line cursal; 489 int done = 0; 490 int mid_statement = (source == SRC_LINE) && (get_frame_pc (fi) != sal.pc); 491 492 if (annotation_level) 493 done = identify_source_line (sal.symtab, sal.line, mid_statement, 494 get_frame_pc (fi)); 495 if (!done) 496 { 497 if (print_frame_info_listing_hook) 498 print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0); 499 else 500 { 501 /* We used to do this earlier, but that is clearly 502 wrong. This function is used by many different 503 parts of gdb, including normal_stop in infrun.c, 504 which uses this to print out the current PC 505 when we stepi/nexti into the middle of a source 506 line. Only the command line really wants this 507 behavior. Other UIs probably would like the 508 ability to decide for themselves if it is desired. */ 509 if (addressprint && mid_statement) 510 { 511 ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); 512 ui_out_text (uiout, "\t"); 513 } 514 515 print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); 516 } 517 } 518 /* Make sure we have at least a default source file */ 519 set_default_source_symtab_and_line (); 520 cursal = get_current_source_symtab_and_line (); 521 cursal.line = max (sal.line - get_lines_to_list () / 2, 1); 522 set_current_source_symtab_and_line (&cursal); 523 } 524 525 if (source != 0) 526 set_default_breakpoint (1, get_frame_pc (fi), sal.symtab, sal.line); 527 528 annotate_frame_end (); 529 530 gdb_flush (gdb_stdout); 531} 532 533static void 534print_frame (struct frame_info *fi, 535 int level, 536 int source, 537 int args, 538 struct symtab_and_line sal) 539{ 540 struct symbol *func; 541 char *funname = 0; 542 enum language funlang = language_unknown; 543 struct ui_stream *stb; 544 struct cleanup *old_chain; 545 struct cleanup *list_chain; 546 547 stb = ui_out_stream_new (uiout); 548 old_chain = make_cleanup_ui_out_stream_delete (stb); 549 550 func = find_pc_function (get_frame_address_in_block (fi)); 551 if (func) 552 { 553 /* In certain pathological cases, the symtabs give the wrong 554 function (when we are in the first function in a file which 555 is compiled without debugging symbols, the previous function 556 is compiled with debugging symbols, and the "foo.o" symbol 557 that is supposed to tell us where the file with debugging symbols 558 ends has been truncated by ar because it is longer than 15 559 characters). This also occurs if the user uses asm() to create 560 a function but not stabs for it (in a file compiled -g). 561 562 So look in the minimal symbol tables as well, and if it comes 563 up with a larger address for the function use that instead. 564 I don't think this can ever cause any problems; there shouldn't 565 be any minimal symbols in the middle of a function; if this is 566 ever changed many parts of GDB will need to be changed (and we'll 567 create a find_pc_minimal_function or some such). */ 568 569 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_address_in_block (fi)); 570 if (msymbol != NULL 571 && (SYMBOL_VALUE_ADDRESS (msymbol) 572 > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) 573 { 574#if 0 575 /* There is no particular reason to think the line number 576 information is wrong. Someone might have just put in 577 a label with asm() but left the line numbers alone. */ 578 /* In this case we have no way of knowing the source file 579 and line number, so don't print them. */ 580 sal.symtab = 0; 581#endif 582 /* We also don't know anything about the function besides 583 its address and name. */ 584 func = 0; 585 funname = DEPRECATED_SYMBOL_NAME (msymbol); 586 funlang = SYMBOL_LANGUAGE (msymbol); 587 } 588 else 589 { 590 /* I'd like to use SYMBOL_PRINT_NAME() here, to display the 591 demangled name that we already have stored in the symbol 592 table, but we stored a version with DMGL_PARAMS turned 593 on, and here we don't want to display parameters. So call 594 the demangler again, with DMGL_ANSI only. (Yes, I know 595 that printf_symbol_filtered() will again try to demangle 596 the name on the fly, but the issue is that if 597 cplus_demangle() fails here, it'll fail there too. So we 598 want to catch the failure ("demangled==NULL" case below) 599 here, while we still have our hands on the function 600 symbol.) */ 601 char *demangled; 602 funname = DEPRECATED_SYMBOL_NAME (func); 603 funlang = SYMBOL_LANGUAGE (func); 604 if (funlang == language_cplus) 605 { 606 demangled = cplus_demangle (funname, DMGL_ANSI); 607 if (demangled == NULL) 608 /* If the demangler fails, try the demangled name from 609 the symbol table. This'll have parameters, but 610 that's preferable to diplaying a mangled name. */ 611 funname = SYMBOL_PRINT_NAME (func); 612 } 613 } 614 } 615 else 616 { 617 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_address_in_block (fi)); 618 if (msymbol != NULL) 619 { 620 funname = DEPRECATED_SYMBOL_NAME (msymbol); 621 funlang = SYMBOL_LANGUAGE (msymbol); 622 } 623 } 624 625 annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi)); 626 627 list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); 628 629 if (level >= 0) 630 { 631 ui_out_text (uiout, "#"); 632 ui_out_field_fmt_int (uiout, 2, ui_left, "level", level); 633 } 634 if (addressprint) 635 if (get_frame_pc (fi) != sal.pc 636 || !sal.symtab 637 || source == LOC_AND_ADDRESS) 638 { 639 annotate_frame_address (); 640 ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); 641 annotate_frame_address_end (); 642 ui_out_text (uiout, " in "); 643 } 644 annotate_frame_function_name (); 645 fprintf_symbol_filtered (stb->stream, funname ? funname : "??", funlang, 646 DMGL_ANSI); 647 ui_out_field_stream (uiout, "func", stb); 648 ui_out_wrap_hint (uiout, " "); 649 annotate_frame_args (); 650 651 ui_out_text (uiout, " ("); 652 if (args) 653 { 654 struct print_args_args args; 655 struct cleanup *args_list_chain; 656 args.fi = fi; 657 args.func = func; 658 args.stream = gdb_stdout; 659 args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args"); 660 catch_errors (print_args_stub, &args, "", RETURN_MASK_ALL); 661 /* FIXME: args must be a list. If one argument is a string it will 662 have " that will not be properly escaped. */ 663 /* Invoke ui_out_tuple_end. */ 664 do_cleanups (args_list_chain); 665 QUIT; 666 } 667 ui_out_text (uiout, ")"); 668 if (sal.symtab && sal.symtab->filename) 669 { 670 annotate_frame_source_begin (); 671 ui_out_wrap_hint (uiout, " "); 672 ui_out_text (uiout, " at "); 673 annotate_frame_source_file (); 674 ui_out_field_string (uiout, "file", sal.symtab->filename); 675 annotate_frame_source_file_end (); 676 ui_out_text (uiout, ":"); 677 annotate_frame_source_line (); 678 ui_out_field_int (uiout, "line", sal.line); 679 annotate_frame_source_end (); 680 } 681 682#ifdef PC_SOLIB 683 if (!funname || (!sal.symtab || !sal.symtab->filename)) 684 { 685 char *lib = PC_SOLIB (get_frame_pc (fi)); 686 if (lib) 687 { 688 annotate_frame_where (); 689 ui_out_wrap_hint (uiout, " "); 690 ui_out_text (uiout, " from "); 691 ui_out_field_string (uiout, "from", lib); 692 } 693 } 694#endif /* PC_SOLIB */ 695 696 /* do_cleanups will call ui_out_tuple_end() for us. */ 697 do_cleanups (list_chain); 698 ui_out_text (uiout, "\n"); 699 do_cleanups (old_chain); 700} 701 702/* Show the frame info. If this is the tui, it will be shown in 703 the source display otherwise, nothing is done */ 704void 705show_stack_frame (struct frame_info *fi) 706{ 707} 708 709 710/* Read a frame specification in whatever the appropriate format is. 711 Call error() if the specification is in any way invalid (i.e. 712 this function never returns NULL). */ 713 714struct frame_info * 715parse_frame_specification (char *frame_exp) 716{ 717 int numargs = 0; 718#define MAXARGS 4 719 CORE_ADDR args[MAXARGS]; 720 int level; 721 722 if (frame_exp) 723 { 724 char *addr_string, *p; 725 struct cleanup *tmp_cleanup; 726 727 while (*frame_exp == ' ') 728 frame_exp++; 729 730 while (*frame_exp) 731 { 732 if (numargs > MAXARGS) 733 error ("Too many args in frame specification"); 734 /* Parse an argument. */ 735 for (p = frame_exp; *p && *p != ' '; p++) 736 ; 737 addr_string = savestring (frame_exp, p - frame_exp); 738 739 { 740 struct value *vp; 741 742 tmp_cleanup = make_cleanup (xfree, addr_string); 743 744 /* NOTE: we call parse_and_eval and then both 745 value_as_long and value_as_address rather than calling 746 parse_and_eval_long and parse_and_eval_address because 747 of the issue of potential side effects from evaluating 748 the expression. */ 749 vp = parse_and_eval (addr_string); 750 if (numargs == 0) 751 level = value_as_long (vp); 752 753 args[numargs++] = value_as_address (vp); 754 do_cleanups (tmp_cleanup); 755 } 756 757 /* Skip spaces, move to possible next arg. */ 758 while (*p == ' ') 759 p++; 760 frame_exp = p; 761 } 762 } 763 764 switch (numargs) 765 { 766 case 0: 767 if (deprecated_selected_frame == NULL) 768 error ("No selected frame."); 769 return deprecated_selected_frame; 770 /* NOTREACHED */ 771 case 1: 772 { 773 struct frame_info *fid = 774 find_relative_frame (get_current_frame (), &level); 775 struct frame_info *tfid; 776 777 if (level == 0) 778 /* find_relative_frame was successful */ 779 return fid; 780 781 /* If SETUP_ARBITRARY_FRAME is defined, then frame specifications 782 take at least 2 addresses. It is important to detect this case 783 here so that "frame 100" does not give a confusing error message 784 like "frame specification requires two addresses". This of course 785 does not solve the "frame 100" problem for machines on which 786 a frame specification can be made with one address. To solve 787 that, we need a new syntax for a specifying a frame by address. 788 I think the cleanest syntax is $frame(0x45) ($frame(0x23,0x45) for 789 two args, etc.), but people might think that is too much typing, 790 so I guess *0x23,0x45 would be a possible alternative (commas 791 really should be used instead of spaces to delimit; using spaces 792 normally works in an expression). */ 793#ifdef SETUP_ARBITRARY_FRAME 794 error ("No frame %s", paddr_d (args[0])); 795#endif 796 797 /* If (s)he specifies the frame with an address, he deserves what 798 (s)he gets. Still, give the highest one that matches. */ 799 800 for (fid = get_current_frame (); 801 fid && get_frame_base (fid) != args[0]; 802 fid = get_prev_frame (fid)) 803 ; 804 805 if (fid) 806 while ((tfid = get_prev_frame (fid)) && 807 (get_frame_base (tfid) == args[0])) 808 fid = tfid; 809 810 /* We couldn't identify the frame as an existing frame, but 811 perhaps we can create one with a single argument. */ 812 } 813 814 default: 815#ifdef SETUP_ARBITRARY_FRAME 816 return SETUP_ARBITRARY_FRAME (numargs, args); 817#else 818 /* Usual case. Do it here rather than have everyone supply 819 a SETUP_ARBITRARY_FRAME that does this. */ 820 if (numargs == 1) 821 return create_new_frame (args[0], 0); 822 error ("Too many args in frame specification"); 823#endif 824 /* NOTREACHED */ 825 } 826 /* NOTREACHED */ 827} 828 829/* Print verbosely the selected frame or the frame at address ADDR. 830 This means absolutely all information in the frame is printed. */ 831 832static void 833frame_info (char *addr_exp, int from_tty) 834{ 835 struct frame_info *fi; 836 struct symtab_and_line sal; 837 struct symbol *func; 838 struct symtab *s; 839 struct frame_info *calling_frame_info; 840 int i, count, numregs; 841 char *funname = 0; 842 enum language funlang = language_unknown; 843 const char *pc_regname; 844 845 if (!target_has_stack) 846 error ("No stack."); 847 848 /* Name of the value returned by get_frame_pc(). Per comments, "pc" 849 is not a good name. */ 850 if (PC_REGNUM >= 0) 851 /* OK, this is weird. The PC_REGNUM hardware register's value can 852 easily not match that of the internal value returned by 853 get_frame_pc(). */ 854 pc_regname = REGISTER_NAME (PC_REGNUM); 855 else 856 /* But then, this is weird to. Even without PC_REGNUM, an 857 architectures will often have a hardware register called "pc", 858 and that register's value, again, can easily not match 859 get_frame_pc(). */ 860 pc_regname = "pc"; 861 862 fi = parse_frame_specification (addr_exp); 863 if (fi == NULL) 864 error ("Invalid frame specified."); 865 866 find_frame_sal (fi, &sal); 867 func = get_frame_function (fi); 868 /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain 869 the same value. */ 870 s = find_pc_symtab (get_frame_pc (fi)); 871 if (func) 872 { 873 /* I'd like to use SYMBOL_PRINT_NAME() here, to display 874 * the demangled name that we already have stored in 875 * the symbol table, but we stored a version with 876 * DMGL_PARAMS turned on, and here we don't want 877 * to display parameters. So call the demangler again, 878 * with DMGL_ANSI only. RT 879 * (Yes, I know that printf_symbol_filtered() will 880 * again try to demangle the name on the fly, but 881 * the issue is that if cplus_demangle() fails here, 882 * it'll fail there too. So we want to catch the failure 883 * ("demangled==NULL" case below) here, while we still 884 * have our hands on the function symbol.) 885 */ 886 char *demangled; 887 funname = DEPRECATED_SYMBOL_NAME (func); 888 funlang = SYMBOL_LANGUAGE (func); 889 if (funlang == language_cplus) 890 { 891 demangled = cplus_demangle (funname, DMGL_ANSI); 892 /* If the demangler fails, try the demangled name 893 * from the symbol table. This'll have parameters, 894 * but that's preferable to diplaying a mangled name. 895 */ 896 if (demangled == NULL) 897 funname = SYMBOL_PRINT_NAME (func); 898 } 899 } 900 else 901 { 902 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi)); 903 if (msymbol != NULL) 904 { 905 funname = DEPRECATED_SYMBOL_NAME (msymbol); 906 funlang = SYMBOL_LANGUAGE (msymbol); 907 } 908 } 909 calling_frame_info = get_prev_frame (fi); 910 911 if (!addr_exp && frame_relative_level (deprecated_selected_frame) >= 0) 912 { 913 printf_filtered ("Stack level %d, frame at ", 914 frame_relative_level (deprecated_selected_frame)); 915 print_address_numeric (get_frame_base (fi), 1, gdb_stdout); 916 printf_filtered (":\n"); 917 } 918 else 919 { 920 printf_filtered ("Stack frame at "); 921 print_address_numeric (get_frame_base (fi), 1, gdb_stdout); 922 printf_filtered (":\n"); 923 } 924 printf_filtered (" %s = ", pc_regname); 925 print_address_numeric (get_frame_pc (fi), 1, gdb_stdout); 926 927 wrap_here (" "); 928 if (funname) 929 { 930 printf_filtered (" in "); 931 fprintf_symbol_filtered (gdb_stdout, funname, funlang, 932 DMGL_ANSI | DMGL_PARAMS); 933 } 934 wrap_here (" "); 935 if (sal.symtab) 936 printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line); 937 puts_filtered ("; "); 938 wrap_here (" "); 939 printf_filtered ("saved %s ", pc_regname); 940 print_address_numeric (frame_pc_unwind (fi), 1, gdb_stdout); 941 printf_filtered ("\n"); 942 943 { 944 int frameless; 945 frameless = (DEPRECATED_FRAMELESS_FUNCTION_INVOCATION_P () 946 && DEPRECATED_FRAMELESS_FUNCTION_INVOCATION (fi)); 947 if (frameless) 948 printf_filtered (" (FRAMELESS),"); 949 } 950 951 if (calling_frame_info) 952 { 953 printf_filtered (" called by frame at "); 954 print_address_numeric (get_frame_base (calling_frame_info), 955 1, gdb_stdout); 956 } 957 if (get_next_frame (fi) && calling_frame_info) 958 puts_filtered (","); 959 wrap_here (" "); 960 if (get_next_frame (fi)) 961 { 962 printf_filtered (" caller of frame at "); 963 print_address_numeric (get_frame_base (get_next_frame (fi)), 1, 964 gdb_stdout); 965 } 966 if (get_next_frame (fi) || calling_frame_info) 967 puts_filtered ("\n"); 968 if (s) 969 printf_filtered (" source language %s.\n", 970 language_str (s->language)); 971 972 { 973 /* Address of the argument list for this frame, or 0. */ 974 CORE_ADDR arg_list = get_frame_args_address (fi); 975 /* Number of args for this frame, or -1 if unknown. */ 976 int numargs; 977 978 if (arg_list == 0) 979 printf_filtered (" Arglist at unknown address.\n"); 980 else 981 { 982 printf_filtered (" Arglist at "); 983 print_address_numeric (arg_list, 1, gdb_stdout); 984 printf_filtered (","); 985 986 if (!FRAME_NUM_ARGS_P ()) 987 { 988 numargs = -1; 989 puts_filtered (" args: "); 990 } 991 else 992 { 993 numargs = FRAME_NUM_ARGS (fi); 994 gdb_assert (numargs >= 0); 995 if (numargs == 0) 996 puts_filtered (" no args."); 997 else if (numargs == 1) 998 puts_filtered (" 1 arg: "); 999 else 1000 printf_filtered (" %d args: ", numargs); 1001 } 1002 print_frame_args (func, fi, numargs, gdb_stdout); 1003 puts_filtered ("\n"); 1004 } 1005 } 1006 { 1007 /* Address of the local variables for this frame, or 0. */ 1008 CORE_ADDR arg_list = get_frame_locals_address (fi); 1009 1010 if (arg_list == 0) 1011 printf_filtered (" Locals at unknown address,"); 1012 else 1013 { 1014 printf_filtered (" Locals at "); 1015 print_address_numeric (arg_list, 1, gdb_stdout); 1016 printf_filtered (","); 1017 } 1018 } 1019 1020 if (DEPRECATED_FRAME_INIT_SAVED_REGS_P () 1021 && deprecated_get_frame_saved_regs (fi) == NULL) 1022 DEPRECATED_FRAME_INIT_SAVED_REGS (fi); 1023 /* Print as much information as possible on the location of all the 1024 registers. */ 1025 { 1026 enum lval_type lval; 1027 int optimized; 1028 CORE_ADDR addr; 1029 int realnum; 1030 int count; 1031 int i; 1032 int need_nl = 1; 1033 1034 /* The sp is special; what's displayed isn't the save address, but 1035 the value of the previous frame's sp. This is a legacy thing, 1036 at one stage the frame cached the previous frame's SP instead 1037 of its address, hence it was easiest to just display the cached 1038 value. */ 1039 if (SP_REGNUM >= 0) 1040 { 1041 /* Find out the location of the saved stack pointer with out 1042 actually evaluating it. */ 1043 frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, 1044 &realnum, NULL); 1045 if (!optimized && lval == not_lval) 1046 { 1047 char value[MAX_REGISTER_SIZE]; 1048 CORE_ADDR sp; 1049 frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, 1050 &realnum, value); 1051 /* NOTE: cagney/2003-05-22: This is assuming that the 1052 stack pointer was packed as an unsigned integer. That 1053 may or may not be valid. */ 1054 sp = extract_unsigned_integer (value, DEPRECATED_REGISTER_RAW_SIZE (SP_REGNUM)); 1055 printf_filtered (" Previous frame's sp is "); 1056 print_address_numeric (sp, 1, gdb_stdout); 1057 printf_filtered ("\n"); 1058 need_nl = 0; 1059 } 1060 else if (!optimized && lval == lval_memory) 1061 { 1062 printf_filtered (" Previous frame's sp at "); 1063 print_address_numeric (addr, 1, gdb_stdout); 1064 printf_filtered ("\n"); 1065 need_nl = 0; 1066 } 1067 else if (!optimized && lval == lval_register) 1068 { 1069 printf_filtered (" Previous frame's sp in %s\n", 1070 REGISTER_NAME (realnum)); 1071 need_nl = 0; 1072 } 1073 /* else keep quiet. */ 1074 } 1075 1076 count = 0; 1077 numregs = NUM_REGS + NUM_PSEUDO_REGS; 1078 for (i = 0; i < numregs; i++) 1079 if (i != SP_REGNUM 1080 && gdbarch_register_reggroup_p (current_gdbarch, i, all_reggroup)) 1081 { 1082 /* Find out the location of the saved register without 1083 fetching the corresponding value. */ 1084 frame_register_unwind (fi, i, &optimized, &lval, &addr, &realnum, 1085 NULL); 1086 /* For moment, only display registers that were saved on the 1087 stack. */ 1088 if (!optimized && lval == lval_memory) 1089 { 1090 if (count == 0) 1091 puts_filtered (" Saved registers:\n "); 1092 else 1093 puts_filtered (","); 1094 wrap_here (" "); 1095 printf_filtered (" %s at ", REGISTER_NAME (i)); 1096 print_address_numeric (addr, 1, gdb_stdout); 1097 count++; 1098 } 1099 } 1100 if (count || need_nl) 1101 puts_filtered ("\n"); 1102 } 1103} 1104 1105#if 0 1106/* Set a limit on the number of frames printed by default in a 1107 backtrace. */ 1108 1109static int backtrace_limit; 1110 1111static void 1112set_backtrace_limit_command (char *count_exp, int from_tty) 1113{ 1114 int count = parse_and_eval_long (count_exp); 1115 1116 if (count < 0) 1117 error ("Negative argument not meaningful as backtrace limit."); 1118 1119 backtrace_limit = count; 1120} 1121 1122static void 1123backtrace_limit_info (char *arg, int from_tty) 1124{ 1125 if (arg) 1126 error ("\"Info backtrace-limit\" takes no arguments."); 1127 1128 printf_unfiltered ("Backtrace limit: %d.\n", backtrace_limit); 1129} 1130#endif 1131 1132/* Print briefly all stack frames or just the innermost COUNT frames. */ 1133 1134static void backtrace_command_1 (char *count_exp, int show_locals, 1135 int from_tty); 1136static void 1137backtrace_command_1 (char *count_exp, int show_locals, int from_tty) 1138{ 1139 struct frame_info *fi; 1140 int count; 1141 int i; 1142 struct frame_info *trailing; 1143 int trailing_level; 1144 1145 if (!target_has_stack) 1146 error ("No stack."); 1147 1148 /* The following code must do two things. First, it must 1149 set the variable TRAILING to the frame from which we should start 1150 printing. Second, it must set the variable count to the number 1151 of frames which we should print, or -1 if all of them. */ 1152 trailing = get_current_frame (); 1153 1154 /* The target can be in a state where there is no valid frames 1155 (e.g., just connected). */ 1156 if (trailing == NULL) 1157 error ("No stack."); 1158 1159 trailing_level = 0; 1160 if (count_exp) 1161 { 1162 count = parse_and_eval_long (count_exp); 1163 if (count < 0) 1164 { 1165 struct frame_info *current; 1166 1167 count = -count; 1168 1169 current = trailing; 1170 while (current && count--) 1171 { 1172 QUIT; 1173 current = get_prev_frame (current); 1174 } 1175 1176 /* Will stop when CURRENT reaches the top of the stack. TRAILING 1177 will be COUNT below it. */ 1178 while (current) 1179 { 1180 QUIT; 1181 trailing = get_prev_frame (trailing); 1182 current = get_prev_frame (current); 1183 trailing_level++; 1184 } 1185 1186 count = -1; 1187 } 1188 } 1189 else 1190 count = -1; 1191 1192 if (info_verbose) 1193 { 1194 struct partial_symtab *ps; 1195 1196 /* Read in symbols for all of the frames. Need to do this in 1197 a separate pass so that "Reading in symbols for xxx" messages 1198 don't screw up the appearance of the backtrace. Also 1199 if people have strong opinions against reading symbols for 1200 backtrace this may have to be an option. */ 1201 i = count; 1202 for (fi = trailing; 1203 fi != NULL && i--; 1204 fi = get_prev_frame (fi)) 1205 { 1206 QUIT; 1207 ps = find_pc_psymtab (get_frame_address_in_block (fi)); 1208 if (ps) 1209 PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */ 1210 } 1211 } 1212 1213 for (i = 0, fi = trailing; 1214 fi && count--; 1215 i++, fi = get_prev_frame (fi)) 1216 { 1217 QUIT; 1218 1219 /* Don't use print_stack_frame; if an error() occurs it probably 1220 means further attempts to backtrace would fail (on the other 1221 hand, perhaps the code does or could be fixed to make sure 1222 the frame->prev field gets set to NULL in that case). */ 1223 print_frame_info (fi, trailing_level + i, 0, 1); 1224 if (show_locals) 1225 print_frame_local_vars (fi, 1, gdb_stdout); 1226 } 1227 1228 /* If we've stopped before the end, mention that. */ 1229 if (fi && from_tty) 1230 printf_filtered ("(More stack frames follow...)\n"); 1231} 1232 1233struct backtrace_command_args 1234 { 1235 char *count_exp; 1236 int show_locals; 1237 int from_tty; 1238 }; 1239 1240/* Stub to call backtrace_command_1 by way of an error catcher. */ 1241static int 1242backtrace_command_stub (void *data) 1243{ 1244 struct backtrace_command_args *args = (struct backtrace_command_args *)data; 1245 backtrace_command_1 (args->count_exp, args->show_locals, args->from_tty); 1246 return 0; 1247} 1248 1249static void 1250backtrace_command (char *arg, int from_tty) 1251{ 1252 struct cleanup *old_chain = (struct cleanup *) NULL; 1253 char **argv = (char **) NULL; 1254 int argIndicatingFullTrace = (-1), totArgLen = 0, argc = 0; 1255 char *argPtr = arg; 1256 struct backtrace_command_args btargs; 1257 1258 if (arg != (char *) NULL) 1259 { 1260 int i; 1261 1262 argv = buildargv (arg); 1263 old_chain = make_cleanup_freeargv (argv); 1264 argc = 0; 1265 for (i = 0; (argv[i] != (char *) NULL); i++) 1266 { 1267 unsigned int j; 1268 1269 for (j = 0; (j < strlen (argv[i])); j++) 1270 argv[i][j] = tolower (argv[i][j]); 1271 1272 if (argIndicatingFullTrace < 0 && subset_compare (argv[i], "full")) 1273 argIndicatingFullTrace = argc; 1274 else 1275 { 1276 argc++; 1277 totArgLen += strlen (argv[i]); 1278 } 1279 } 1280 totArgLen += argc; 1281 if (argIndicatingFullTrace >= 0) 1282 { 1283 if (totArgLen > 0) 1284 { 1285 argPtr = (char *) xmalloc (totArgLen + 1); 1286 if (!argPtr) 1287 nomem (0); 1288 else 1289 { 1290 memset (argPtr, 0, totArgLen + 1); 1291 for (i = 0; (i < (argc + 1)); i++) 1292 { 1293 if (i != argIndicatingFullTrace) 1294 { 1295 strcat (argPtr, argv[i]); 1296 strcat (argPtr, " "); 1297 } 1298 } 1299 } 1300 } 1301 else 1302 argPtr = (char *) NULL; 1303 } 1304 } 1305 1306 btargs.count_exp = argPtr; 1307 btargs.show_locals = (argIndicatingFullTrace >= 0); 1308 btargs.from_tty = from_tty; 1309 catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR); 1310 1311 if (argIndicatingFullTrace >= 0 && totArgLen > 0) 1312 xfree (argPtr); 1313 1314 if (old_chain) 1315 do_cleanups (old_chain); 1316} 1317 1318static void backtrace_full_command (char *arg, int from_tty); 1319static void 1320backtrace_full_command (char *arg, int from_tty) 1321{ 1322 struct backtrace_command_args btargs; 1323 btargs.count_exp = arg; 1324 btargs.show_locals = 1; 1325 btargs.from_tty = from_tty; 1326 catch_errors (backtrace_command_stub, (char *)&btargs, "", RETURN_MASK_ERROR); 1327} 1328 1329 1330/* Print the local variables of a block B active in FRAME. 1331 Return 1 if any variables were printed; 0 otherwise. */ 1332 1333static int 1334print_block_frame_locals (struct block *b, struct frame_info *fi, 1335 int num_tabs, struct ui_file *stream) 1336{ 1337 struct dict_iterator iter; 1338 int j; 1339 struct symbol *sym; 1340 int values_printed = 0; 1341 1342 ALL_BLOCK_SYMBOLS (b, iter, sym) 1343 { 1344 switch (SYMBOL_CLASS (sym)) 1345 { 1346 case LOC_LOCAL: 1347 case LOC_REGISTER: 1348 case LOC_STATIC: 1349 case LOC_BASEREG: 1350 case LOC_COMPUTED: 1351 values_printed = 1; 1352 for (j = 0; j < num_tabs; j++) 1353 fputs_filtered ("\t", stream); 1354 fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); 1355 fputs_filtered (" = ", stream); 1356 print_variable_value (sym, fi, stream); 1357 fprintf_filtered (stream, "\n"); 1358 break; 1359 1360 default: 1361 /* Ignore symbols which are not locals. */ 1362 break; 1363 } 1364 } 1365 return values_printed; 1366} 1367 1368/* Same, but print labels. */ 1369 1370static int 1371print_block_frame_labels (struct block *b, int *have_default, 1372 struct ui_file *stream) 1373{ 1374 struct dict_iterator iter; 1375 struct symbol *sym; 1376 int values_printed = 0; 1377 1378 ALL_BLOCK_SYMBOLS (b, iter, sym) 1379 { 1380 if (DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (sym), "default")) 1381 { 1382 if (*have_default) 1383 continue; 1384 *have_default = 1; 1385 } 1386 if (SYMBOL_CLASS (sym) == LOC_LABEL) 1387 { 1388 struct symtab_and_line sal; 1389 sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); 1390 values_printed = 1; 1391 fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); 1392 if (addressprint) 1393 { 1394 fprintf_filtered (stream, " "); 1395 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, stream); 1396 } 1397 fprintf_filtered (stream, " in file %s, line %d\n", 1398 sal.symtab->filename, sal.line); 1399 } 1400 } 1401 return values_printed; 1402} 1403 1404/* Print on STREAM all the local variables in frame FRAME, 1405 including all the blocks active in that frame 1406 at its current pc. 1407 1408 Returns 1 if the job was done, 1409 or 0 if nothing was printed because we have no info 1410 on the function running in FRAME. */ 1411 1412static void 1413print_frame_local_vars (struct frame_info *fi, int num_tabs, 1414 struct ui_file *stream) 1415{ 1416 struct block *block = get_frame_block (fi, 0); 1417 int values_printed = 0; 1418 1419 if (block == 0) 1420 { 1421 fprintf_filtered (stream, "No symbol table info available.\n"); 1422 return; 1423 } 1424 1425 while (block != 0) 1426 { 1427 if (print_block_frame_locals (block, fi, num_tabs, stream)) 1428 values_printed = 1; 1429 /* After handling the function's top-level block, stop. 1430 Don't continue to its superblock, the block of 1431 per-file symbols. */ 1432 if (BLOCK_FUNCTION (block)) 1433 break; 1434 block = BLOCK_SUPERBLOCK (block); 1435 } 1436 1437 if (!values_printed) 1438 { 1439 fprintf_filtered (stream, "No locals.\n"); 1440 } 1441} 1442 1443/* Same, but print labels. */ 1444 1445static void 1446print_frame_label_vars (struct frame_info *fi, int this_level_only, 1447 struct ui_file *stream) 1448{ 1449 struct blockvector *bl; 1450 struct block *block = get_frame_block (fi, 0); 1451 int values_printed = 0; 1452 int index, have_default = 0; 1453 char *blocks_printed; 1454 CORE_ADDR pc = get_frame_pc (fi); 1455 1456 if (block == 0) 1457 { 1458 fprintf_filtered (stream, "No symbol table info available.\n"); 1459 return; 1460 } 1461 1462 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); 1463 blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); 1464 memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); 1465 1466 while (block != 0) 1467 { 1468 CORE_ADDR end = BLOCK_END (block) - 4; 1469 int last_index; 1470 1471 if (bl != blockvector_for_pc (end, &index)) 1472 error ("blockvector blotch"); 1473 if (BLOCKVECTOR_BLOCK (bl, index) != block) 1474 error ("blockvector botch"); 1475 last_index = BLOCKVECTOR_NBLOCKS (bl); 1476 index += 1; 1477 1478 /* Don't print out blocks that have gone by. */ 1479 while (index < last_index 1480 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc) 1481 index++; 1482 1483 while (index < last_index 1484 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end) 1485 { 1486 if (blocks_printed[index] == 0) 1487 { 1488 if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream)) 1489 values_printed = 1; 1490 blocks_printed[index] = 1; 1491 } 1492 index++; 1493 } 1494 if (have_default) 1495 return; 1496 if (values_printed && this_level_only) 1497 return; 1498 1499 /* After handling the function's top-level block, stop. 1500 Don't continue to its superblock, the block of 1501 per-file symbols. */ 1502 if (BLOCK_FUNCTION (block)) 1503 break; 1504 block = BLOCK_SUPERBLOCK (block); 1505 } 1506 1507 if (!values_printed && !this_level_only) 1508 { 1509 fprintf_filtered (stream, "No catches.\n"); 1510 } 1511} 1512 1513void 1514locals_info (char *args, int from_tty) 1515{ 1516 if (!deprecated_selected_frame) 1517 error ("No frame selected."); 1518 print_frame_local_vars (deprecated_selected_frame, 0, gdb_stdout); 1519} 1520 1521static void 1522catch_info (char *ignore, int from_tty) 1523{ 1524 struct symtab_and_line *sal; 1525 1526 /* Check for target support for exception handling */ 1527 sal = target_enable_exception_callback (EX_EVENT_CATCH, 1); 1528 if (sal) 1529 { 1530 /* Currently not handling this */ 1531 /* Ideally, here we should interact with the C++ runtime 1532 system to find the list of active handlers, etc. */ 1533 fprintf_filtered (gdb_stdout, "Info catch not supported with this target/compiler combination.\n"); 1534#if 0 1535 if (!deprecated_selected_frame) 1536 error ("No frame selected."); 1537#endif 1538 } 1539 else 1540 { 1541 /* Assume g++ compiled code -- old v 4.16 behaviour */ 1542 if (!deprecated_selected_frame) 1543 error ("No frame selected."); 1544 1545 print_frame_label_vars (deprecated_selected_frame, 0, gdb_stdout); 1546 } 1547} 1548 1549static void 1550print_frame_arg_vars (struct frame_info *fi, 1551 struct ui_file *stream) 1552{ 1553 struct symbol *func = get_frame_function (fi); 1554 struct block *b; 1555 struct dict_iterator iter; 1556 struct symbol *sym, *sym2; 1557 int values_printed = 0; 1558 1559 if (func == 0) 1560 { 1561 fprintf_filtered (stream, "No symbol table info available.\n"); 1562 return; 1563 } 1564 1565 b = SYMBOL_BLOCK_VALUE (func); 1566 ALL_BLOCK_SYMBOLS (b, iter, sym) 1567 { 1568 switch (SYMBOL_CLASS (sym)) 1569 { 1570 case LOC_ARG: 1571 case LOC_LOCAL_ARG: 1572 case LOC_REF_ARG: 1573 case LOC_REGPARM: 1574 case LOC_REGPARM_ADDR: 1575 case LOC_BASEREG_ARG: 1576 case LOC_COMPUTED_ARG: 1577 values_printed = 1; 1578 fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); 1579 fputs_filtered (" = ", stream); 1580 1581 /* We have to look up the symbol because arguments can have 1582 two entries (one a parameter, one a local) and the one we 1583 want is the local, which lookup_symbol will find for us. 1584 This includes gcc1 (not gcc2) on the sparc when passing a 1585 small structure and gcc2 when the argument type is float 1586 and it is passed as a double and converted to float by 1587 the prologue (in the latter case the type of the LOC_ARG 1588 symbol is double and the type of the LOC_LOCAL symbol is 1589 float). There are also LOC_ARG/LOC_REGISTER pairs which 1590 are not combined in symbol-reading. */ 1591 1592 sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym), 1593 b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); 1594 print_variable_value (sym2, fi, stream); 1595 fprintf_filtered (stream, "\n"); 1596 break; 1597 1598 default: 1599 /* Don't worry about things which aren't arguments. */ 1600 break; 1601 } 1602 } 1603 if (!values_printed) 1604 { 1605 fprintf_filtered (stream, "No arguments.\n"); 1606 } 1607} 1608 1609void 1610args_info (char *ignore, int from_tty) 1611{ 1612 if (!deprecated_selected_frame) 1613 error ("No frame selected."); 1614 print_frame_arg_vars (deprecated_selected_frame, gdb_stdout); 1615} 1616 1617 1618static void 1619args_plus_locals_info (char *ignore, int from_tty) 1620{ 1621 args_info (ignore, from_tty); 1622 locals_info (ignore, from_tty); 1623} 1624 1625 1626/* Select frame FI. Also print the stack frame and show the source if 1627 this is the tui version. */ 1628static void 1629select_and_print_frame (struct frame_info *fi) 1630{ 1631 select_frame (fi); 1632 if (fi) 1633 { 1634 print_stack_frame (fi, frame_relative_level (fi), 1); 1635 } 1636} 1637 1638/* Return the symbol-block in which the selected frame is executing. 1639 Can return zero under various legitimate circumstances. 1640 1641 If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant 1642 code address within the block returned. We use this to decide 1643 which macros are in scope. */ 1644 1645struct block * 1646get_selected_block (CORE_ADDR *addr_in_block) 1647{ 1648 if (!target_has_stack) 1649 return 0; 1650 1651 /* NOTE: cagney/2002-11-28: Why go to all this effort to not create 1652 a selected/current frame? Perhaphs this function is called, 1653 indirectly, by WFI in "infrun.c" where avoiding the creation of 1654 an inner most frame is very important (it slows down single 1655 step). I suspect, though that this was true in the deep dark 1656 past but is no longer the case. A mindless look at all the 1657 callers tends to support this theory. I think we should be able 1658 to assume that there is always a selcted frame. */ 1659 /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel 1660 lucky? */ 1661 if (!deprecated_selected_frame) 1662 { 1663 CORE_ADDR pc = read_pc (); 1664 if (addr_in_block != NULL) 1665 *addr_in_block = pc; 1666 return block_for_pc (pc); 1667 } 1668 return get_frame_block (deprecated_selected_frame, addr_in_block); 1669} 1670 1671/* Find a frame a certain number of levels away from FRAME. 1672 LEVEL_OFFSET_PTR points to an int containing the number of levels. 1673 Positive means go to earlier frames (up); negative, the reverse. 1674 The int that contains the number of levels is counted toward 1675 zero as the frames for those levels are found. 1676 If the top or bottom frame is reached, that frame is returned, 1677 but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates 1678 how much farther the original request asked to go. */ 1679 1680struct frame_info * 1681find_relative_frame (struct frame_info *frame, 1682 int *level_offset_ptr) 1683{ 1684 struct frame_info *prev; 1685 struct frame_info *frame1; 1686 1687 /* Going up is simple: just do get_prev_frame enough times 1688 or until initial frame is reached. */ 1689 while (*level_offset_ptr > 0) 1690 { 1691 prev = get_prev_frame (frame); 1692 if (prev == 0) 1693 break; 1694 (*level_offset_ptr)--; 1695 frame = prev; 1696 } 1697 /* Going down is just as simple. */ 1698 if (*level_offset_ptr < 0) 1699 { 1700 while (*level_offset_ptr < 0) 1701 { 1702 frame1 = get_next_frame (frame); 1703 if (!frame1) 1704 break; 1705 frame = frame1; 1706 (*level_offset_ptr)++; 1707 } 1708 } 1709 return frame; 1710} 1711 1712/* The "select_frame" command. With no arg, NOP. 1713 With arg LEVEL_EXP, select the frame at level LEVEL if it is a 1714 valid level. Otherwise, treat level_exp as an address expression 1715 and select it. See parse_frame_specification for more info on proper 1716 frame expressions. */ 1717 1718void 1719select_frame_command (char *level_exp, int from_tty) 1720{ 1721 struct frame_info *frame; 1722 int level = frame_relative_level (deprecated_selected_frame); 1723 1724 if (!target_has_stack) 1725 error ("No stack."); 1726 1727 frame = parse_frame_specification (level_exp); 1728 1729 select_frame (frame); 1730 if (level != frame_relative_level (deprecated_selected_frame)) 1731 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame)); 1732} 1733 1734/* The "frame" command. With no arg, print selected frame briefly. 1735 With arg, behaves like select_frame and then prints the selected 1736 frame. */ 1737 1738void 1739frame_command (char *level_exp, int from_tty) 1740{ 1741 select_frame_command (level_exp, from_tty); 1742 print_stack_frame (deprecated_selected_frame, 1743 frame_relative_level (deprecated_selected_frame), 1); 1744} 1745 1746/* The XDB Compatibility command to print the current frame. */ 1747 1748static void 1749current_frame_command (char *level_exp, int from_tty) 1750{ 1751 if (target_has_stack == 0 || deprecated_selected_frame == 0) 1752 error ("No stack."); 1753 print_stack_frame (deprecated_selected_frame, 1754 frame_relative_level (deprecated_selected_frame), 1); 1755} 1756 1757/* Select the frame up one or COUNT stack levels 1758 from the previously selected frame, and print it briefly. */ 1759 1760static void 1761up_silently_base (char *count_exp) 1762{ 1763 struct frame_info *fi; 1764 int count = 1, count1; 1765 if (count_exp) 1766 count = parse_and_eval_long (count_exp); 1767 count1 = count; 1768 1769 if (target_has_stack == 0 || deprecated_selected_frame == 0) 1770 error ("No stack."); 1771 1772 fi = find_relative_frame (deprecated_selected_frame, &count1); 1773 if (count1 != 0 && count_exp == 0) 1774 error ("Initial frame selected; you cannot go up."); 1775 select_frame (fi); 1776 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame)); 1777} 1778 1779static void 1780up_silently_command (char *count_exp, int from_tty) 1781{ 1782 up_silently_base (count_exp); 1783} 1784 1785static void 1786up_command (char *count_exp, int from_tty) 1787{ 1788 up_silently_base (count_exp); 1789 print_stack_frame (deprecated_selected_frame, 1790 frame_relative_level (deprecated_selected_frame), 1); 1791} 1792 1793/* Select the frame down one or COUNT stack levels 1794 from the previously selected frame, and print it briefly. */ 1795 1796static void 1797down_silently_base (char *count_exp) 1798{ 1799 struct frame_info *frame; 1800 int count = -1, count1; 1801 if (count_exp) 1802 count = -parse_and_eval_long (count_exp); 1803 count1 = count; 1804 1805 if (target_has_stack == 0 || deprecated_selected_frame == 0) 1806 error ("No stack."); 1807 1808 frame = find_relative_frame (deprecated_selected_frame, &count1); 1809 if (count1 != 0 && count_exp == 0) 1810 { 1811 1812 /* We only do this if count_exp is not specified. That way "down" 1813 means to really go down (and let me know if that is 1814 impossible), but "down 9999" can be used to mean go all the way 1815 down without getting an error. */ 1816 1817 error ("Bottom (i.e., innermost) frame selected; you cannot go down."); 1818 } 1819 1820 select_frame (frame); 1821 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame)); 1822} 1823 1824static void 1825down_silently_command (char *count_exp, int from_tty) 1826{ 1827 down_silently_base (count_exp); 1828} 1829 1830static void 1831down_command (char *count_exp, int from_tty) 1832{ 1833 down_silently_base (count_exp); 1834 print_stack_frame (deprecated_selected_frame, 1835 frame_relative_level (deprecated_selected_frame), 1); 1836} 1837 1838void 1839return_command (char *retval_exp, int from_tty) 1840{ 1841 struct symbol *thisfun; 1842 struct value *return_value = NULL; 1843 const char *query_prefix = ""; 1844 1845 /* FIXME: cagney/2003-10-20: Perform a minimal existance test on the 1846 target. If that fails, error out. For the moment don't rely on 1847 get_selected_frame as it's error message is the the singularly 1848 obscure "No registers". */ 1849 if (!target_has_registers) 1850 error ("No selected frame."); 1851 thisfun = get_frame_function (get_selected_frame ()); 1852 1853 /* Compute the return value. If the computation triggers an error, 1854 let it bail. If the return type can't be handled, set 1855 RETURN_VALUE to NULL, and QUERY_PREFIX to an informational 1856 message. */ 1857 if (retval_exp) 1858 { 1859 struct type *return_type = NULL; 1860 1861 /* Compute the return value. Should the computation fail, this 1862 call throws an error. */ 1863 return_value = parse_and_eval (retval_exp); 1864 1865 /* Cast return value to the return type of the function. Should 1866 the cast fail, this call throws an error. */ 1867 if (thisfun != NULL) 1868 return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun)); 1869 if (return_type == NULL) 1870 return_type = builtin_type_int; 1871 return_value = value_cast (return_type, return_value); 1872 1873 /* Make sure the value is fully evaluated. It may live in the 1874 stack frame we're about to pop. */ 1875 if (VALUE_LAZY (return_value)) 1876 value_fetch_lazy (return_value); 1877 1878 if (TYPE_CODE (return_type) == TYPE_CODE_VOID) 1879 /* If the return-type is "void", don't try to find the 1880 return-value's location. However, do still evaluate the 1881 return expression so that, even when the expression result 1882 is discarded, side effects such as "return i++" still 1883 occure. */ 1884 return_value = NULL; 1885 /* FIXME: cagney/2004-01-17: If the architecture implements both 1886 return_value and extract_returned_value_address, should allow 1887 "return" to work - don't set return_value to NULL. */ 1888 else if (!gdbarch_return_value_p (current_gdbarch) 1889 && (TYPE_CODE (return_type) == TYPE_CODE_STRUCT 1890 || TYPE_CODE (return_type) == TYPE_CODE_UNION)) 1891 { 1892 /* NOTE: cagney/2003-10-20: Compatibility hack for legacy 1893 code. Old architectures don't expect STORE_RETURN_VALUE 1894 to be called with with a small struct that needs to be 1895 stored in registers. Don't start doing it now. */ 1896 query_prefix = "\ 1897A structure or union return type is not supported by this architecture.\n\ 1898If you continue, the return value that you specified will be ignored.\n"; 1899 return_value = NULL; 1900 } 1901 else if (using_struct_return (return_type, 0)) 1902 { 1903 query_prefix = "\ 1904The location at which to store the function's return value is unknown.\n\ 1905If you continue, the return value that you specified will be ignored.\n"; 1906 return_value = NULL; 1907 } 1908 } 1909 1910 /* Does an interactive user really want to do this? Include 1911 information, such as how well GDB can handle the return value, in 1912 the query message. */ 1913 if (from_tty) 1914 { 1915 int confirmed; 1916 if (thisfun == NULL) 1917 confirmed = query ("%sMake selected stack frame return now? ", 1918 query_prefix); 1919 else 1920 confirmed = query ("%sMake %s return now? ", query_prefix, 1921 SYMBOL_PRINT_NAME (thisfun)); 1922 if (!confirmed) 1923 error ("Not confirmed"); 1924 } 1925 1926 /* NOTE: cagney/2003-01-18: Is this silly? Rather than pop each 1927 frame in turn, should this code just go straight to the relevant 1928 frame and pop that? */ 1929 1930 /* First discard all frames inner-to the selected frame (making the 1931 selected frame current). */ 1932 { 1933 struct frame_id selected_id = get_frame_id (get_selected_frame ()); 1934 while (!frame_id_eq (selected_id, get_frame_id (get_current_frame ()))) 1935 { 1936 if (frame_id_inner (selected_id, get_frame_id (get_current_frame ()))) 1937 /* Caught in the safety net, oops! We've gone way past the 1938 selected frame. */ 1939 error ("Problem while popping stack frames (corrupt stack?)"); 1940 frame_pop (get_current_frame ()); 1941 } 1942 } 1943 1944 /* Second discard the selected frame (which is now also the current 1945 frame). */ 1946 frame_pop (get_current_frame ()); 1947 1948 /* Store RETURN_VAUE in the just-returned register set. */ 1949 if (return_value != NULL) 1950 { 1951 struct type *return_type = VALUE_TYPE (return_value); 1952 if (!gdbarch_return_value_p (current_gdbarch)) 1953 { 1954 STORE_RETURN_VALUE (return_type, current_regcache, 1955 VALUE_CONTENTS (return_value)); 1956 } 1957 /* FIXME: cagney/2004-01-17: If extract_returned_value_address 1958 is available and the function is using 1959 RETURN_VALUE_STRUCT_CONVENTION, should use it to find the 1960 address of the returned value so that it can be assigned. */ 1961 else 1962 { 1963 gdb_assert (gdbarch_return_value (current_gdbarch, return_type, 1964 NULL, NULL, NULL) 1965 == RETURN_VALUE_REGISTER_CONVENTION); 1966 gdbarch_return_value (current_gdbarch, return_type, 1967 current_regcache, NULL /*read*/, 1968 VALUE_CONTENTS (return_value) /*write*/); 1969 } 1970 } 1971 1972 /* If we are at the end of a call dummy now, pop the dummy frame 1973 too. */ 1974 /* NOTE: cagney/2003-01-18: Is this silly? Instead of popping all 1975 the frames in sequence, should this code just pop the dummy frame 1976 directly? */ 1977#ifdef DEPRECATED_CALL_DUMMY_HAS_COMPLETED 1978 /* Since all up-to-date architectures return direct to the dummy 1979 breakpoint address, a dummy frame has, by definition, always 1980 completed. Hence this method is no longer needed. */ 1981 if (DEPRECATED_CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (), 1982 get_frame_base (get_current_frame ()))) 1983 frame_pop (get_current_frame ()); 1984#else 1985 if (get_frame_type (get_current_frame ()) == DUMMY_FRAME) 1986 frame_pop (get_current_frame ()); 1987#endif 1988 1989 /* If interactive, print the frame that is now current. */ 1990 if (from_tty) 1991 frame_command ("0", 1); 1992 else 1993 select_frame_command ("0", 0); 1994} 1995 1996/* Sets the scope to input function name, provided that the 1997 function is within the current stack frame */ 1998 1999struct function_bounds 2000{ 2001 CORE_ADDR low, high; 2002}; 2003 2004static void func_command (char *arg, int from_tty); 2005static void 2006func_command (char *arg, int from_tty) 2007{ 2008 struct frame_info *fp; 2009 int found = 0; 2010 struct symtabs_and_lines sals; 2011 int i; 2012 int level = 1; 2013 struct function_bounds *func_bounds = (struct function_bounds *) NULL; 2014 2015 if (arg != (char *) NULL) 2016 return; 2017 2018 fp = parse_frame_specification ("0"); 2019 sals = decode_line_spec (arg, 1); 2020 func_bounds = (struct function_bounds *) xmalloc ( 2021 sizeof (struct function_bounds) * sals.nelts); 2022 for (i = 0; (i < sals.nelts && !found); i++) 2023 { 2024 if (sals.sals[i].pc == (CORE_ADDR) 0 || 2025 find_pc_partial_function (sals.sals[i].pc, 2026 (char **) NULL, 2027 &func_bounds[i].low, 2028 &func_bounds[i].high) == 0) 2029 { 2030 func_bounds[i].low = 2031 func_bounds[i].high = (CORE_ADDR) NULL; 2032 } 2033 } 2034 2035 do 2036 { 2037 for (i = 0; (i < sals.nelts && !found); i++) 2038 found = (get_frame_pc (fp) >= func_bounds[i].low && 2039 get_frame_pc (fp) < func_bounds[i].high); 2040 if (!found) 2041 { 2042 level = 1; 2043 fp = find_relative_frame (fp, &level); 2044 } 2045 } 2046 while (!found && level == 0); 2047 2048 if (func_bounds) 2049 xfree (func_bounds); 2050 2051 if (!found) 2052 printf_filtered ("'%s' not within current stack frame.\n", arg); 2053 else if (fp != deprecated_selected_frame) 2054 select_and_print_frame (fp); 2055} 2056 2057/* Gets the language of the current frame. */ 2058 2059enum language 2060get_frame_language (void) 2061{ 2062 struct symtab *s; 2063 enum language flang; /* The language of the current frame */ 2064 2065 if (deprecated_selected_frame) 2066 { 2067 /* We determine the current frame language by looking up its 2068 associated symtab. To retrieve this symtab, we use the frame PC. 2069 However we cannot use the frame pc as is, because it usually points 2070 to the instruction following the "call", which is sometimes the first 2071 instruction of another function. So we rely on 2072 get_frame_address_in_block(), it provides us with a PC which is 2073 guaranteed to be inside the frame's code block. */ 2074 s = find_pc_symtab (get_frame_address_in_block (deprecated_selected_frame)); 2075 if (s) 2076 flang = s->language; 2077 else 2078 flang = language_unknown; 2079 } 2080 else 2081 flang = language_unknown; 2082 2083 return flang; 2084} 2085 2086void 2087_initialize_stack (void) 2088{ 2089#if 0 2090 backtrace_limit = 30; 2091#endif 2092 2093 add_com ("return", class_stack, return_command, 2094 "Make selected stack frame return to its caller.\n\ 2095Control remains in the debugger, but when you continue\n\ 2096execution will resume in the frame above the one now selected.\n\ 2097If an argument is given, it is an expression for the value to return."); 2098 2099 add_com ("up", class_stack, up_command, 2100 "Select and print stack frame that called this one.\n\ 2101An argument says how many frames up to go."); 2102 add_com ("up-silently", class_support, up_silently_command, 2103 "Same as the `up' command, but does not print anything.\n\ 2104This is useful in command scripts."); 2105 2106 add_com ("down", class_stack, down_command, 2107 "Select and print stack frame called by this one.\n\ 2108An argument says how many frames down to go."); 2109 add_com_alias ("do", "down", class_stack, 1); 2110 add_com_alias ("dow", "down", class_stack, 1); 2111 add_com ("down-silently", class_support, down_silently_command, 2112 "Same as the `down' command, but does not print anything.\n\ 2113This is useful in command scripts."); 2114 2115 add_com ("frame", class_stack, frame_command, 2116 "Select and print a stack frame.\n\ 2117With no argument, print the selected stack frame. (See also \"info frame\").\n\ 2118An argument specifies the frame to select.\n\ 2119It can be a stack frame number or the address of the frame.\n\ 2120With argument, nothing is printed if input is coming from\n\ 2121a command file or a user-defined command."); 2122 2123 add_com_alias ("f", "frame", class_stack, 1); 2124 2125 if (xdb_commands) 2126 { 2127 add_com ("L", class_stack, current_frame_command, 2128 "Print the current stack frame.\n"); 2129 add_com_alias ("V", "frame", class_stack, 1); 2130 } 2131 add_com ("select-frame", class_stack, select_frame_command, 2132 "Select a stack frame without printing anything.\n\ 2133An argument specifies the frame to select.\n\ 2134It can be a stack frame number or the address of the frame.\n"); 2135 2136 add_com ("backtrace", class_stack, backtrace_command, 2137 "Print backtrace of all stack frames, or innermost COUNT frames.\n\ 2138With a negative argument, print outermost -COUNT frames.\n\ 2139Use of the 'full' qualifier also prints the values of the local variables.\n"); 2140 add_com_alias ("bt", "backtrace", class_stack, 0); 2141 if (xdb_commands) 2142 { 2143 add_com_alias ("t", "backtrace", class_stack, 0); 2144 add_com ("T", class_stack, backtrace_full_command, 2145 "Print backtrace of all stack frames, or innermost COUNT frames \n\ 2146and the values of the local variables.\n\ 2147With a negative argument, print outermost -COUNT frames.\n\ 2148Usage: T <count>\n"); 2149 } 2150 2151 add_com_alias ("where", "backtrace", class_alias, 0); 2152 add_info ("stack", backtrace_command, 2153 "Backtrace of the stack, or innermost COUNT frames."); 2154 add_info_alias ("s", "stack", 1); 2155 add_info ("frame", frame_info, 2156 "All about selected stack frame, or frame at ADDR."); 2157 add_info_alias ("f", "frame", 1); 2158 add_info ("locals", locals_info, 2159 "Local variables of current stack frame."); 2160 add_info ("args", args_info, 2161 "Argument variables of current stack frame."); 2162 if (xdb_commands) 2163 add_com ("l", class_info, args_plus_locals_info, 2164 "Argument and local variables of current stack frame."); 2165 2166 if (dbx_commands) 2167 add_com ("func", class_stack, func_command, 2168 "Select the stack frame that contains <func>.\nUsage: func <name>\n"); 2169 2170 add_info ("catch", catch_info, 2171 "Exceptions that can be caught in the current stack frame."); 2172 2173#if 0 2174 add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, 2175 "Specify maximum number of frames for \"backtrace\" to print by default.", 2176 &setlist); 2177 add_info ("backtrace-limit", backtrace_limit_info, 2178 "The maximum number of frames for \"backtrace\" to print by default."); 2179#endif 2180} 2181