15796c8dcSSimon Schubert /* Print and select stack frames for GDB, the GNU debugger. 25796c8dcSSimon Schubert 35796c8dcSSimon Schubert Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 45796c8dcSSimon Schubert 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 5*cf7f2e2dSJohn Marino 2009, 2010 Free Software Foundation, Inc. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This file is part of GDB. 85796c8dcSSimon Schubert 95796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 105796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 115796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 125796c8dcSSimon Schubert (at your option) any later version. 135796c8dcSSimon Schubert 145796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 155796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 165796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175796c8dcSSimon Schubert GNU General Public License for more details. 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 205796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 215796c8dcSSimon Schubert 225796c8dcSSimon Schubert #include "defs.h" 235796c8dcSSimon Schubert #include "value.h" 245796c8dcSSimon Schubert #include "symtab.h" 255796c8dcSSimon Schubert #include "gdbtypes.h" 265796c8dcSSimon Schubert #include "expression.h" 275796c8dcSSimon Schubert #include "language.h" 285796c8dcSSimon Schubert #include "frame.h" 295796c8dcSSimon Schubert #include "gdbcmd.h" 305796c8dcSSimon Schubert #include "gdbcore.h" 315796c8dcSSimon Schubert #include "target.h" 325796c8dcSSimon Schubert #include "source.h" 335796c8dcSSimon Schubert #include "breakpoint.h" 345796c8dcSSimon Schubert #include "demangle.h" 355796c8dcSSimon Schubert #include "inferior.h" 365796c8dcSSimon Schubert #include "annotate.h" 375796c8dcSSimon Schubert #include "ui-out.h" 385796c8dcSSimon Schubert #include "block.h" 395796c8dcSSimon Schubert #include "stack.h" 405796c8dcSSimon Schubert #include "dictionary.h" 415796c8dcSSimon Schubert #include "exceptions.h" 425796c8dcSSimon Schubert #include "reggroups.h" 435796c8dcSSimon Schubert #include "regcache.h" 445796c8dcSSimon Schubert #include "solib.h" 455796c8dcSSimon Schubert #include "valprint.h" 465796c8dcSSimon Schubert #include "gdbthread.h" 475796c8dcSSimon Schubert #include "cp-support.h" 485796c8dcSSimon Schubert #include "disasm.h" 495796c8dcSSimon Schubert #include "inline-frame.h" 505796c8dcSSimon Schubert 515796c8dcSSimon Schubert #include "gdb_assert.h" 525796c8dcSSimon Schubert #include <ctype.h> 535796c8dcSSimon Schubert #include "gdb_string.h" 545796c8dcSSimon Schubert 55*cf7f2e2dSJohn Marino #include "psymtab.h" 56*cf7f2e2dSJohn Marino #include "symfile.h" 57*cf7f2e2dSJohn Marino 585796c8dcSSimon Schubert void (*deprecated_selected_frame_level_changed_hook) (int); 595796c8dcSSimon Schubert 605796c8dcSSimon Schubert /* The possible choices of "set print frame-arguments, and the value 615796c8dcSSimon Schubert of this setting. */ 625796c8dcSSimon Schubert 635796c8dcSSimon Schubert static const char *print_frame_arguments_choices[] = 645796c8dcSSimon Schubert {"all", "scalars", "none", NULL}; 655796c8dcSSimon Schubert static const char *print_frame_arguments = "scalars"; 665796c8dcSSimon Schubert 675796c8dcSSimon Schubert /* Prototypes for local functions. */ 685796c8dcSSimon Schubert 695796c8dcSSimon Schubert static void print_frame_local_vars (struct frame_info *, int, 705796c8dcSSimon Schubert struct ui_file *); 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert static void print_frame (struct frame_info *frame, int print_level, 735796c8dcSSimon Schubert enum print_what print_what, int print_args, 745796c8dcSSimon Schubert struct symtab_and_line sal); 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert /* Zero means do things normally; we are interacting directly with the 775796c8dcSSimon Schubert user. One means print the full filename and linenumber when a 785796c8dcSSimon Schubert frame is printed, and do so in a format emacs18/emacs19.22 can 795796c8dcSSimon Schubert parse. Two means print similar annotations, but in many more 805796c8dcSSimon Schubert cases and in a slightly different syntax. */ 815796c8dcSSimon Schubert 825796c8dcSSimon Schubert int annotation_level = 0; 835796c8dcSSimon Schubert 845796c8dcSSimon Schubert 855796c8dcSSimon Schubert struct print_stack_frame_args 865796c8dcSSimon Schubert { 875796c8dcSSimon Schubert struct frame_info *frame; 885796c8dcSSimon Schubert int print_level; 895796c8dcSSimon Schubert enum print_what print_what; 905796c8dcSSimon Schubert int print_args; 915796c8dcSSimon Schubert }; 925796c8dcSSimon Schubert 935796c8dcSSimon Schubert /* Show or print the frame arguments; stub for catch_errors. */ 945796c8dcSSimon Schubert 955796c8dcSSimon Schubert static int 965796c8dcSSimon Schubert print_stack_frame_stub (void *args) 975796c8dcSSimon Schubert { 985796c8dcSSimon Schubert struct print_stack_frame_args *p = args; 995796c8dcSSimon Schubert int center = (p->print_what == SRC_LINE || p->print_what == SRC_AND_LOC); 1005796c8dcSSimon Schubert 1015796c8dcSSimon Schubert print_frame_info (p->frame, p->print_level, p->print_what, p->print_args); 1025796c8dcSSimon Schubert set_current_sal_from_frame (p->frame, center); 1035796c8dcSSimon Schubert return 0; 1045796c8dcSSimon Schubert } 1055796c8dcSSimon Schubert 1065796c8dcSSimon Schubert /* Return 1 if we should display the address in addition to the location, 1075796c8dcSSimon Schubert because we are in the middle of a statement. */ 1085796c8dcSSimon Schubert 1095796c8dcSSimon Schubert static int 1105796c8dcSSimon Schubert frame_show_address (struct frame_info *frame, 1115796c8dcSSimon Schubert struct symtab_and_line sal) 1125796c8dcSSimon Schubert { 1135796c8dcSSimon Schubert /* If there is a line number, but no PC, then there is no location 1145796c8dcSSimon Schubert information associated with this sal. The only way that should 1155796c8dcSSimon Schubert happen is for the call sites of inlined functions (SAL comes from 1165796c8dcSSimon Schubert find_frame_sal). Otherwise, we would have some PC range if the 1175796c8dcSSimon Schubert SAL came from a line table. */ 1185796c8dcSSimon Schubert if (sal.line != 0 && sal.pc == 0 && sal.end == 0) 1195796c8dcSSimon Schubert { 1205796c8dcSSimon Schubert if (get_next_frame (frame) == NULL) 1215796c8dcSSimon Schubert gdb_assert (inline_skipped_frames (inferior_ptid) > 0); 1225796c8dcSSimon Schubert else 1235796c8dcSSimon Schubert gdb_assert (get_frame_type (get_next_frame (frame)) == INLINE_FRAME); 1245796c8dcSSimon Schubert return 0; 1255796c8dcSSimon Schubert } 1265796c8dcSSimon Schubert 1275796c8dcSSimon Schubert return get_frame_pc (frame) != sal.pc; 1285796c8dcSSimon Schubert } 1295796c8dcSSimon Schubert 1305796c8dcSSimon Schubert /* Show or print a stack frame FRAME briefly. The output is format 1315796c8dcSSimon Schubert according to PRINT_LEVEL and PRINT_WHAT printing the frame's 1325796c8dcSSimon Schubert relative level, function name, argument list, and file name and 1335796c8dcSSimon Schubert line number. If the frame's PC is not at the beginning of the 1345796c8dcSSimon Schubert source line, the actual PC is printed at the beginning. */ 1355796c8dcSSimon Schubert 1365796c8dcSSimon Schubert void 1375796c8dcSSimon Schubert print_stack_frame (struct frame_info *frame, int print_level, 1385796c8dcSSimon Schubert enum print_what print_what) 1395796c8dcSSimon Schubert { 1405796c8dcSSimon Schubert struct print_stack_frame_args args; 1415796c8dcSSimon Schubert 1425796c8dcSSimon Schubert args.frame = frame; 1435796c8dcSSimon Schubert args.print_level = print_level; 1445796c8dcSSimon Schubert args.print_what = print_what; 1455796c8dcSSimon Schubert /* For mi, alway print location and address. */ 1465796c8dcSSimon Schubert args.print_what = ui_out_is_mi_like_p (uiout) ? LOC_AND_ADDRESS : print_what; 1475796c8dcSSimon Schubert args.print_args = 1; 1485796c8dcSSimon Schubert 1495796c8dcSSimon Schubert catch_errors (print_stack_frame_stub, &args, "", RETURN_MASK_ERROR); 1505796c8dcSSimon Schubert } 1515796c8dcSSimon Schubert 1525796c8dcSSimon Schubert struct print_args_args 1535796c8dcSSimon Schubert { 1545796c8dcSSimon Schubert struct symbol *func; 1555796c8dcSSimon Schubert struct frame_info *frame; 1565796c8dcSSimon Schubert struct ui_file *stream; 1575796c8dcSSimon Schubert }; 1585796c8dcSSimon Schubert 1595796c8dcSSimon Schubert static int print_args_stub (void *args); 1605796c8dcSSimon Schubert 1615796c8dcSSimon Schubert /* Print nameless arguments of frame FRAME on STREAM, where START is 1625796c8dcSSimon Schubert the offset of the first nameless argument, and NUM is the number of 1635796c8dcSSimon Schubert nameless arguments to print. FIRST is nonzero if this is the first 1645796c8dcSSimon Schubert argument (not just the first nameless argument). */ 1655796c8dcSSimon Schubert 1665796c8dcSSimon Schubert static void 1675796c8dcSSimon Schubert print_frame_nameless_args (struct frame_info *frame, long start, int num, 1685796c8dcSSimon Schubert int first, struct ui_file *stream) 1695796c8dcSSimon Schubert { 1705796c8dcSSimon Schubert struct gdbarch *gdbarch = get_frame_arch (frame); 1715796c8dcSSimon Schubert enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 1725796c8dcSSimon Schubert int i; 1735796c8dcSSimon Schubert CORE_ADDR argsaddr; 1745796c8dcSSimon Schubert long arg_value; 1755796c8dcSSimon Schubert 1765796c8dcSSimon Schubert for (i = 0; i < num; i++) 1775796c8dcSSimon Schubert { 1785796c8dcSSimon Schubert QUIT; 1795796c8dcSSimon Schubert argsaddr = get_frame_args_address (frame); 1805796c8dcSSimon Schubert if (!argsaddr) 1815796c8dcSSimon Schubert return; 1825796c8dcSSimon Schubert arg_value = read_memory_integer (argsaddr + start, 1835796c8dcSSimon Schubert sizeof (int), byte_order); 1845796c8dcSSimon Schubert if (!first) 1855796c8dcSSimon Schubert fprintf_filtered (stream, ", "); 1865796c8dcSSimon Schubert fprintf_filtered (stream, "%ld", arg_value); 1875796c8dcSSimon Schubert first = 0; 1885796c8dcSSimon Schubert start += sizeof (int); 1895796c8dcSSimon Schubert } 1905796c8dcSSimon Schubert } 1915796c8dcSSimon Schubert 1925796c8dcSSimon Schubert /* Print the arguments of frame FRAME on STREAM, given the function 1935796c8dcSSimon Schubert FUNC running in that frame (as a symbol), where NUM is the number 1945796c8dcSSimon Schubert of arguments according to the stack frame (or -1 if the number of 1955796c8dcSSimon Schubert arguments is unknown). */ 1965796c8dcSSimon Schubert 1975796c8dcSSimon Schubert /* Note that currently the "number of arguments according to the 1985796c8dcSSimon Schubert stack frame" is only known on VAX where i refers to the "number of 1995796c8dcSSimon Schubert ints of arguments according to the stack frame". */ 2005796c8dcSSimon Schubert 2015796c8dcSSimon Schubert static void 2025796c8dcSSimon Schubert print_frame_args (struct symbol *func, struct frame_info *frame, 2035796c8dcSSimon Schubert int num, struct ui_file *stream) 2045796c8dcSSimon Schubert { 2055796c8dcSSimon Schubert int first = 1; 2065796c8dcSSimon Schubert /* Offset of next stack argument beyond the one we have seen that is 2075796c8dcSSimon Schubert at the highest offset, or -1 if we haven't come to a stack 2085796c8dcSSimon Schubert argument yet. */ 2095796c8dcSSimon Schubert long highest_offset = -1; 2105796c8dcSSimon Schubert /* Number of ints of arguments that we have printed so far. */ 2115796c8dcSSimon Schubert int args_printed = 0; 2125796c8dcSSimon Schubert struct cleanup *old_chain, *list_chain; 2135796c8dcSSimon Schubert struct ui_stream *stb; 2145796c8dcSSimon Schubert /* True if we should print arguments, false otherwise. */ 2155796c8dcSSimon Schubert int print_args = strcmp (print_frame_arguments, "none"); 2165796c8dcSSimon Schubert /* True in "summary" mode, false otherwise. */ 2175796c8dcSSimon Schubert int summary = !strcmp (print_frame_arguments, "scalars"); 2185796c8dcSSimon Schubert 2195796c8dcSSimon Schubert stb = ui_out_stream_new (uiout); 2205796c8dcSSimon Schubert old_chain = make_cleanup_ui_out_stream_delete (stb); 2215796c8dcSSimon Schubert 2225796c8dcSSimon Schubert if (func) 2235796c8dcSSimon Schubert { 2245796c8dcSSimon Schubert struct block *b = SYMBOL_BLOCK_VALUE (func); 2255796c8dcSSimon Schubert struct dict_iterator iter; 2265796c8dcSSimon Schubert struct symbol *sym; 2275796c8dcSSimon Schubert struct value *val; 2285796c8dcSSimon Schubert 2295796c8dcSSimon Schubert ALL_BLOCK_SYMBOLS (b, iter, sym) 2305796c8dcSSimon Schubert { 2315796c8dcSSimon Schubert QUIT; 2325796c8dcSSimon Schubert 2335796c8dcSSimon Schubert /* Keep track of the highest stack argument offset seen, and 2345796c8dcSSimon Schubert skip over any kinds of symbols we don't care about. */ 2355796c8dcSSimon Schubert 2365796c8dcSSimon Schubert if (!SYMBOL_IS_ARGUMENT (sym)) 2375796c8dcSSimon Schubert continue; 2385796c8dcSSimon Schubert 2395796c8dcSSimon Schubert switch (SYMBOL_CLASS (sym)) 2405796c8dcSSimon Schubert { 2415796c8dcSSimon Schubert case LOC_ARG: 2425796c8dcSSimon Schubert case LOC_REF_ARG: 2435796c8dcSSimon Schubert { 2445796c8dcSSimon Schubert long current_offset = SYMBOL_VALUE (sym); 2455796c8dcSSimon Schubert int arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); 2465796c8dcSSimon Schubert 2475796c8dcSSimon Schubert /* Compute address of next argument by adding the size of 2485796c8dcSSimon Schubert this argument and rounding to an int boundary. */ 2495796c8dcSSimon Schubert current_offset = 2505796c8dcSSimon Schubert ((current_offset + arg_size + sizeof (int) - 1) 2515796c8dcSSimon Schubert & ~(sizeof (int) - 1)); 2525796c8dcSSimon Schubert 2535796c8dcSSimon Schubert /* If this is the highest offset seen yet, set 2545796c8dcSSimon Schubert highest_offset. */ 2555796c8dcSSimon Schubert if (highest_offset == -1 2565796c8dcSSimon Schubert || (current_offset > highest_offset)) 2575796c8dcSSimon Schubert highest_offset = current_offset; 2585796c8dcSSimon Schubert 2595796c8dcSSimon Schubert /* Add the number of ints we're about to print to 2605796c8dcSSimon Schubert args_printed. */ 2615796c8dcSSimon Schubert args_printed += (arg_size + sizeof (int) - 1) / sizeof (int); 2625796c8dcSSimon Schubert } 2635796c8dcSSimon Schubert 2645796c8dcSSimon Schubert /* We care about types of symbols, but don't need to 2655796c8dcSSimon Schubert keep track of stack offsets in them. */ 2665796c8dcSSimon Schubert case LOC_REGISTER: 2675796c8dcSSimon Schubert case LOC_REGPARM_ADDR: 2685796c8dcSSimon Schubert case LOC_COMPUTED: 2695796c8dcSSimon Schubert case LOC_OPTIMIZED_OUT: 2705796c8dcSSimon Schubert default: 2715796c8dcSSimon Schubert break; 2725796c8dcSSimon Schubert } 2735796c8dcSSimon Schubert 2745796c8dcSSimon Schubert /* We have to look up the symbol because arguments can have 2755796c8dcSSimon Schubert two entries (one a parameter, one a local) and the one we 2765796c8dcSSimon Schubert want is the local, which lookup_symbol will find for us. 2775796c8dcSSimon Schubert This includes gcc1 (not gcc2) on SPARC when passing a 2785796c8dcSSimon Schubert small structure and gcc2 when the argument type is float 2795796c8dcSSimon Schubert and it is passed as a double and converted to float by 2805796c8dcSSimon Schubert the prologue (in the latter case the type of the LOC_ARG 2815796c8dcSSimon Schubert symbol is double and the type of the LOC_LOCAL symbol is 2825796c8dcSSimon Schubert float). */ 2835796c8dcSSimon Schubert /* But if the parameter name is null, don't try it. Null 2845796c8dcSSimon Schubert parameter names occur on the RS/6000, for traceback 2855796c8dcSSimon Schubert tables. FIXME, should we even print them? */ 2865796c8dcSSimon Schubert 2875796c8dcSSimon Schubert if (*SYMBOL_LINKAGE_NAME (sym)) 2885796c8dcSSimon Schubert { 2895796c8dcSSimon Schubert struct symbol *nsym; 290*cf7f2e2dSJohn Marino 2915796c8dcSSimon Schubert nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), 2925796c8dcSSimon Schubert b, VAR_DOMAIN, NULL); 2935796c8dcSSimon Schubert gdb_assert (nsym != NULL); 2945796c8dcSSimon Schubert if (SYMBOL_CLASS (nsym) == LOC_REGISTER 2955796c8dcSSimon Schubert && !SYMBOL_IS_ARGUMENT (nsym)) 2965796c8dcSSimon Schubert { 2975796c8dcSSimon Schubert /* There is a LOC_ARG/LOC_REGISTER pair. This means 2985796c8dcSSimon Schubert that it was passed on the stack and loaded into a 2995796c8dcSSimon Schubert register, or passed in a register and stored in a 3005796c8dcSSimon Schubert stack slot. GDB 3.x used the LOC_ARG; GDB 3015796c8dcSSimon Schubert 4.0-4.11 used the LOC_REGISTER. 3025796c8dcSSimon Schubert 3035796c8dcSSimon Schubert Reasons for using the LOC_ARG: 3045796c8dcSSimon Schubert 3055796c8dcSSimon Schubert (1) Because find_saved_registers may be slow for 3065796c8dcSSimon Schubert remote debugging. 3075796c8dcSSimon Schubert 3085796c8dcSSimon Schubert (2) Because registers are often re-used and stack 3095796c8dcSSimon Schubert slots rarely (never?) are. Therefore using 3105796c8dcSSimon Schubert the stack slot is much less likely to print 3115796c8dcSSimon Schubert garbage. 3125796c8dcSSimon Schubert 3135796c8dcSSimon Schubert Reasons why we might want to use the LOC_REGISTER: 3145796c8dcSSimon Schubert 3155796c8dcSSimon Schubert (1) So that the backtrace prints the same value 3165796c8dcSSimon Schubert as "print foo". I see no compelling reason 3175796c8dcSSimon Schubert why this needs to be the case; having the 3185796c8dcSSimon Schubert backtrace print the value which was passed 3195796c8dcSSimon Schubert in, and "print foo" print the value as 3205796c8dcSSimon Schubert modified within the called function, makes 3215796c8dcSSimon Schubert perfect sense to me. 3225796c8dcSSimon Schubert 3235796c8dcSSimon Schubert Additional note: It might be nice if "info args" 3245796c8dcSSimon Schubert displayed both values. 3255796c8dcSSimon Schubert 3265796c8dcSSimon Schubert One more note: There is a case with SPARC 3275796c8dcSSimon Schubert structure passing where we need to use the 3285796c8dcSSimon Schubert LOC_REGISTER, but this is dealt with by creating 3295796c8dcSSimon Schubert a single LOC_REGPARM in symbol reading. */ 3305796c8dcSSimon Schubert 3315796c8dcSSimon Schubert /* Leave sym (the LOC_ARG) alone. */ 3325796c8dcSSimon Schubert ; 3335796c8dcSSimon Schubert } 3345796c8dcSSimon Schubert else 3355796c8dcSSimon Schubert sym = nsym; 3365796c8dcSSimon Schubert } 3375796c8dcSSimon Schubert 3385796c8dcSSimon Schubert /* Print the current arg. */ 3395796c8dcSSimon Schubert if (!first) 3405796c8dcSSimon Schubert ui_out_text (uiout, ", "); 3415796c8dcSSimon Schubert ui_out_wrap_hint (uiout, " "); 3425796c8dcSSimon Schubert 3435796c8dcSSimon Schubert annotate_arg_begin (); 3445796c8dcSSimon Schubert 3455796c8dcSSimon Schubert list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); 3465796c8dcSSimon Schubert fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym), 3475796c8dcSSimon Schubert SYMBOL_LANGUAGE (sym), 3485796c8dcSSimon Schubert DMGL_PARAMS | DMGL_ANSI); 3495796c8dcSSimon Schubert ui_out_field_stream (uiout, "name", stb); 3505796c8dcSSimon Schubert annotate_arg_name_end (); 3515796c8dcSSimon Schubert ui_out_text (uiout, "="); 3525796c8dcSSimon Schubert 3535796c8dcSSimon Schubert if (print_args) 3545796c8dcSSimon Schubert { 3555796c8dcSSimon Schubert /* Avoid value_print because it will deref ref parameters. 3565796c8dcSSimon Schubert We just want to print their addresses. Print ??? for 3575796c8dcSSimon Schubert args whose address we do not know. We pass 2 as 3585796c8dcSSimon Schubert "recurse" to val_print because our standard indentation 3595796c8dcSSimon Schubert here is 4 spaces, and val_print indents 2 for each 3605796c8dcSSimon Schubert recurse. */ 3615796c8dcSSimon Schubert val = read_var_value (sym, frame); 3625796c8dcSSimon Schubert 3635796c8dcSSimon Schubert annotate_arg_value (val == NULL ? NULL : value_type (val)); 3645796c8dcSSimon Schubert 3655796c8dcSSimon Schubert if (val) 3665796c8dcSSimon Schubert { 3675796c8dcSSimon Schubert const struct language_defn *language; 3685796c8dcSSimon Schubert struct value_print_options opts; 3695796c8dcSSimon Schubert 3705796c8dcSSimon Schubert /* Use the appropriate language to display our symbol, 3715796c8dcSSimon Schubert unless the user forced the language to a specific 3725796c8dcSSimon Schubert language. */ 3735796c8dcSSimon Schubert if (language_mode == language_mode_auto) 3745796c8dcSSimon Schubert language = language_def (SYMBOL_LANGUAGE (sym)); 3755796c8dcSSimon Schubert else 3765796c8dcSSimon Schubert language = current_language; 3775796c8dcSSimon Schubert 3785796c8dcSSimon Schubert get_raw_print_options (&opts); 3795796c8dcSSimon Schubert opts.deref_ref = 0; 3805796c8dcSSimon Schubert opts.summary = summary; 3815796c8dcSSimon Schubert common_val_print (val, stb->stream, 2, &opts, language); 3825796c8dcSSimon Schubert ui_out_field_stream (uiout, "value", stb); 3835796c8dcSSimon Schubert } 3845796c8dcSSimon Schubert else 3855796c8dcSSimon Schubert ui_out_text (uiout, "???"); 3865796c8dcSSimon Schubert } 3875796c8dcSSimon Schubert else 3885796c8dcSSimon Schubert ui_out_text (uiout, "..."); 3895796c8dcSSimon Schubert 3905796c8dcSSimon Schubert 3915796c8dcSSimon Schubert /* Invoke ui_out_tuple_end. */ 3925796c8dcSSimon Schubert do_cleanups (list_chain); 3935796c8dcSSimon Schubert 3945796c8dcSSimon Schubert annotate_arg_end (); 3955796c8dcSSimon Schubert 3965796c8dcSSimon Schubert first = 0; 3975796c8dcSSimon Schubert } 3985796c8dcSSimon Schubert } 3995796c8dcSSimon Schubert 4005796c8dcSSimon Schubert /* Don't print nameless args in situations where we don't know 4015796c8dcSSimon Schubert enough about the stack to find them. */ 4025796c8dcSSimon Schubert if (num != -1) 4035796c8dcSSimon Schubert { 4045796c8dcSSimon Schubert long start; 4055796c8dcSSimon Schubert 4065796c8dcSSimon Schubert if (highest_offset == -1) 4075796c8dcSSimon Schubert start = gdbarch_frame_args_skip (get_frame_arch (frame)); 4085796c8dcSSimon Schubert else 4095796c8dcSSimon Schubert start = highest_offset; 4105796c8dcSSimon Schubert 4115796c8dcSSimon Schubert print_frame_nameless_args (frame, start, num - args_printed, 4125796c8dcSSimon Schubert first, stream); 4135796c8dcSSimon Schubert } 4145796c8dcSSimon Schubert 4155796c8dcSSimon Schubert do_cleanups (old_chain); 4165796c8dcSSimon Schubert } 4175796c8dcSSimon Schubert 4185796c8dcSSimon Schubert /* Stub for catch_errors. */ 4195796c8dcSSimon Schubert 4205796c8dcSSimon Schubert static int 4215796c8dcSSimon Schubert print_args_stub (void *args) 4225796c8dcSSimon Schubert { 4235796c8dcSSimon Schubert struct print_args_args *p = args; 4245796c8dcSSimon Schubert struct gdbarch *gdbarch = get_frame_arch (p->frame); 4255796c8dcSSimon Schubert int numargs; 4265796c8dcSSimon Schubert 4275796c8dcSSimon Schubert if (gdbarch_frame_num_args_p (gdbarch)) 4285796c8dcSSimon Schubert { 4295796c8dcSSimon Schubert numargs = gdbarch_frame_num_args (gdbarch, p->frame); 4305796c8dcSSimon Schubert gdb_assert (numargs >= 0); 4315796c8dcSSimon Schubert } 4325796c8dcSSimon Schubert else 4335796c8dcSSimon Schubert numargs = -1; 4345796c8dcSSimon Schubert print_frame_args (p->func, p->frame, numargs, p->stream); 4355796c8dcSSimon Schubert return 0; 4365796c8dcSSimon Schubert } 4375796c8dcSSimon Schubert 4385796c8dcSSimon Schubert /* Set the current source and line to the location given by frame 4395796c8dcSSimon Schubert FRAME, if possible. When CENTER is true, adjust so the relevant 4405796c8dcSSimon Schubert line is in the center of the next 'list'. */ 4415796c8dcSSimon Schubert 4425796c8dcSSimon Schubert void 4435796c8dcSSimon Schubert set_current_sal_from_frame (struct frame_info *frame, int center) 4445796c8dcSSimon Schubert { 4455796c8dcSSimon Schubert struct symtab_and_line sal; 4465796c8dcSSimon Schubert 4475796c8dcSSimon Schubert find_frame_sal (frame, &sal); 4485796c8dcSSimon Schubert if (sal.symtab) 4495796c8dcSSimon Schubert { 4505796c8dcSSimon Schubert if (center) 4515796c8dcSSimon Schubert sal.line = max (sal.line - get_lines_to_list () / 2, 1); 4525796c8dcSSimon Schubert set_current_source_symtab_and_line (&sal); 4535796c8dcSSimon Schubert } 4545796c8dcSSimon Schubert } 4555796c8dcSSimon Schubert 4565796c8dcSSimon Schubert /* If ON, GDB will display disassembly of the next source line when 4575796c8dcSSimon Schubert execution of the program being debugged stops. 4585796c8dcSSimon Schubert If AUTO (which is the default), or there's no line info to determine 4595796c8dcSSimon Schubert the source line of the next instruction, display disassembly of next 4605796c8dcSSimon Schubert instruction instead. */ 4615796c8dcSSimon Schubert 4625796c8dcSSimon Schubert static enum auto_boolean disassemble_next_line; 4635796c8dcSSimon Schubert 4645796c8dcSSimon Schubert static void 4655796c8dcSSimon Schubert show_disassemble_next_line (struct ui_file *file, int from_tty, 4665796c8dcSSimon Schubert struct cmd_list_element *c, 4675796c8dcSSimon Schubert const char *value) 4685796c8dcSSimon Schubert { 4695796c8dcSSimon Schubert fprintf_filtered (file, _("\ 4705796c8dcSSimon Schubert Debugger's willingness to use disassemble-next-line is %s.\n"), 4715796c8dcSSimon Schubert value); 4725796c8dcSSimon Schubert } 4735796c8dcSSimon Schubert 4745796c8dcSSimon Schubert /* Show assembly codes; stub for catch_errors. */ 4755796c8dcSSimon Schubert 4765796c8dcSSimon Schubert struct gdb_disassembly_stub_args 4775796c8dcSSimon Schubert { 4785796c8dcSSimon Schubert struct gdbarch *gdbarch; 4795796c8dcSSimon Schubert int how_many; 4805796c8dcSSimon Schubert CORE_ADDR low; 4815796c8dcSSimon Schubert CORE_ADDR high; 4825796c8dcSSimon Schubert }; 4835796c8dcSSimon Schubert 4845796c8dcSSimon Schubert static void 4855796c8dcSSimon Schubert gdb_disassembly_stub (void *args) 4865796c8dcSSimon Schubert { 4875796c8dcSSimon Schubert struct gdb_disassembly_stub_args *p = args; 488*cf7f2e2dSJohn Marino 4895796c8dcSSimon Schubert gdb_disassembly (p->gdbarch, uiout, 0, 4905796c8dcSSimon Schubert DISASSEMBLY_RAW_INSN, p->how_many, 4915796c8dcSSimon Schubert p->low, p->high); 4925796c8dcSSimon Schubert } 4935796c8dcSSimon Schubert 4945796c8dcSSimon Schubert /* Use TRY_CATCH to catch the exception from the gdb_disassembly 4955796c8dcSSimon Schubert because it will be broken by filter sometime. */ 4965796c8dcSSimon Schubert 4975796c8dcSSimon Schubert static void 4985796c8dcSSimon Schubert do_gdb_disassembly (struct gdbarch *gdbarch, 4995796c8dcSSimon Schubert int how_many, CORE_ADDR low, CORE_ADDR high) 5005796c8dcSSimon Schubert { 5015796c8dcSSimon Schubert volatile struct gdb_exception exception; 5025796c8dcSSimon Schubert struct gdb_disassembly_stub_args args; 5035796c8dcSSimon Schubert 5045796c8dcSSimon Schubert args.gdbarch = gdbarch; 5055796c8dcSSimon Schubert args.how_many = how_many; 5065796c8dcSSimon Schubert args.low = low; 5075796c8dcSSimon Schubert args.high = high; 5085796c8dcSSimon Schubert TRY_CATCH (exception, RETURN_MASK_ALL) 5095796c8dcSSimon Schubert { 5105796c8dcSSimon Schubert gdb_disassembly_stub (&args); 5115796c8dcSSimon Schubert } 5125796c8dcSSimon Schubert /* If an exception was thrown while doing the disassembly, print 5135796c8dcSSimon Schubert the error message, to give the user a clue of what happened. */ 5145796c8dcSSimon Schubert if (exception.reason == RETURN_ERROR) 5155796c8dcSSimon Schubert exception_print (gdb_stderr, exception); 5165796c8dcSSimon Schubert } 5175796c8dcSSimon Schubert 5185796c8dcSSimon Schubert /* Print information about frame FRAME. The output is format according 5195796c8dcSSimon Schubert to PRINT_LEVEL and PRINT_WHAT and PRINT ARGS. The meaning of 5205796c8dcSSimon Schubert PRINT_WHAT is: 5215796c8dcSSimon Schubert 5225796c8dcSSimon Schubert SRC_LINE: Print only source line. 5235796c8dcSSimon Schubert LOCATION: Print only location. 5245796c8dcSSimon Schubert LOC_AND_SRC: Print location and source line. 5255796c8dcSSimon Schubert 5265796c8dcSSimon Schubert Used in "where" output, and to emit breakpoint or step 5275796c8dcSSimon Schubert messages. */ 5285796c8dcSSimon Schubert 5295796c8dcSSimon Schubert void 5305796c8dcSSimon Schubert print_frame_info (struct frame_info *frame, int print_level, 5315796c8dcSSimon Schubert enum print_what print_what, int print_args) 5325796c8dcSSimon Schubert { 5335796c8dcSSimon Schubert struct gdbarch *gdbarch = get_frame_arch (frame); 5345796c8dcSSimon Schubert struct symtab_and_line sal; 5355796c8dcSSimon Schubert int source_print; 5365796c8dcSSimon Schubert int location_print; 5375796c8dcSSimon Schubert 5385796c8dcSSimon Schubert if (get_frame_type (frame) == DUMMY_FRAME 5395796c8dcSSimon Schubert || get_frame_type (frame) == SIGTRAMP_FRAME 5405796c8dcSSimon Schubert || get_frame_type (frame) == ARCH_FRAME) 5415796c8dcSSimon Schubert { 5425796c8dcSSimon Schubert struct cleanup *uiout_cleanup 5435796c8dcSSimon Schubert = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); 5445796c8dcSSimon Schubert 5455796c8dcSSimon Schubert annotate_frame_begin (print_level ? frame_relative_level (frame) : 0, 5465796c8dcSSimon Schubert gdbarch, get_frame_pc (frame)); 5475796c8dcSSimon Schubert 5485796c8dcSSimon Schubert /* Do this regardless of SOURCE because we don't have any source 5495796c8dcSSimon Schubert to list for this frame. */ 5505796c8dcSSimon Schubert if (print_level) 5515796c8dcSSimon Schubert { 5525796c8dcSSimon Schubert ui_out_text (uiout, "#"); 5535796c8dcSSimon Schubert ui_out_field_fmt_int (uiout, 2, ui_left, "level", 5545796c8dcSSimon Schubert frame_relative_level (frame)); 5555796c8dcSSimon Schubert } 5565796c8dcSSimon Schubert if (ui_out_is_mi_like_p (uiout)) 5575796c8dcSSimon Schubert { 5585796c8dcSSimon Schubert annotate_frame_address (); 5595796c8dcSSimon Schubert ui_out_field_core_addr (uiout, "addr", 5605796c8dcSSimon Schubert gdbarch, get_frame_pc (frame)); 5615796c8dcSSimon Schubert annotate_frame_address_end (); 5625796c8dcSSimon Schubert } 5635796c8dcSSimon Schubert 5645796c8dcSSimon Schubert if (get_frame_type (frame) == DUMMY_FRAME) 5655796c8dcSSimon Schubert { 5665796c8dcSSimon Schubert annotate_function_call (); 5675796c8dcSSimon Schubert ui_out_field_string (uiout, "func", "<function called from gdb>"); 5685796c8dcSSimon Schubert } 5695796c8dcSSimon Schubert else if (get_frame_type (frame) == SIGTRAMP_FRAME) 5705796c8dcSSimon Schubert { 5715796c8dcSSimon Schubert annotate_signal_handler_caller (); 5725796c8dcSSimon Schubert ui_out_field_string (uiout, "func", "<signal handler called>"); 5735796c8dcSSimon Schubert } 5745796c8dcSSimon Schubert else if (get_frame_type (frame) == ARCH_FRAME) 5755796c8dcSSimon Schubert { 5765796c8dcSSimon Schubert ui_out_field_string (uiout, "func", "<cross-architecture call>"); 5775796c8dcSSimon Schubert } 5785796c8dcSSimon Schubert ui_out_text (uiout, "\n"); 5795796c8dcSSimon Schubert annotate_frame_end (); 5805796c8dcSSimon Schubert 5815796c8dcSSimon Schubert do_cleanups (uiout_cleanup); 5825796c8dcSSimon Schubert return; 5835796c8dcSSimon Schubert } 5845796c8dcSSimon Schubert 5855796c8dcSSimon Schubert /* If FRAME is not the innermost frame, that normally means that 5865796c8dcSSimon Schubert FRAME->pc points to *after* the call instruction, and we want to 5875796c8dcSSimon Schubert get the line containing the call, never the next line. But if 5885796c8dcSSimon Schubert the next frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the 5895796c8dcSSimon Schubert next frame was not entered as the result of a call, and we want 5905796c8dcSSimon Schubert to get the line containing FRAME->pc. */ 5915796c8dcSSimon Schubert find_frame_sal (frame, &sal); 5925796c8dcSSimon Schubert 5935796c8dcSSimon Schubert location_print = (print_what == LOCATION 5945796c8dcSSimon Schubert || print_what == LOC_AND_ADDRESS 5955796c8dcSSimon Schubert || print_what == SRC_AND_LOC); 5965796c8dcSSimon Schubert 5975796c8dcSSimon Schubert if (location_print || !sal.symtab) 5985796c8dcSSimon Schubert print_frame (frame, print_level, print_what, print_args, sal); 5995796c8dcSSimon Schubert 6005796c8dcSSimon Schubert source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC); 6015796c8dcSSimon Schubert 6025796c8dcSSimon Schubert /* If disassemble-next-line is set to auto or on and doesn't have 6035796c8dcSSimon Schubert the line debug messages for $pc, output the next instruction. */ 6045796c8dcSSimon Schubert if ((disassemble_next_line == AUTO_BOOLEAN_AUTO 6055796c8dcSSimon Schubert || disassemble_next_line == AUTO_BOOLEAN_TRUE) 6065796c8dcSSimon Schubert && source_print && !sal.symtab) 6075796c8dcSSimon Schubert do_gdb_disassembly (get_frame_arch (frame), 1, 6085796c8dcSSimon Schubert get_frame_pc (frame), get_frame_pc (frame) + 1); 6095796c8dcSSimon Schubert 6105796c8dcSSimon Schubert if (source_print && sal.symtab) 6115796c8dcSSimon Schubert { 6125796c8dcSSimon Schubert int done = 0; 6135796c8dcSSimon Schubert int mid_statement = ((print_what == SRC_LINE) 6145796c8dcSSimon Schubert && frame_show_address (frame, sal)); 6155796c8dcSSimon Schubert 6165796c8dcSSimon Schubert if (annotation_level) 6175796c8dcSSimon Schubert done = identify_source_line (sal.symtab, sal.line, mid_statement, 6185796c8dcSSimon Schubert get_frame_pc (frame)); 6195796c8dcSSimon Schubert if (!done) 6205796c8dcSSimon Schubert { 6215796c8dcSSimon Schubert if (deprecated_print_frame_info_listing_hook) 6225796c8dcSSimon Schubert deprecated_print_frame_info_listing_hook (sal.symtab, 6235796c8dcSSimon Schubert sal.line, 6245796c8dcSSimon Schubert sal.line + 1, 0); 6255796c8dcSSimon Schubert else 6265796c8dcSSimon Schubert { 6275796c8dcSSimon Schubert struct value_print_options opts; 628*cf7f2e2dSJohn Marino 6295796c8dcSSimon Schubert get_user_print_options (&opts); 6305796c8dcSSimon Schubert /* We used to do this earlier, but that is clearly 6315796c8dcSSimon Schubert wrong. This function is used by many different 6325796c8dcSSimon Schubert parts of gdb, including normal_stop in infrun.c, 6335796c8dcSSimon Schubert which uses this to print out the current PC 6345796c8dcSSimon Schubert when we stepi/nexti into the middle of a source 6355796c8dcSSimon Schubert line. Only the command line really wants this 6365796c8dcSSimon Schubert behavior. Other UIs probably would like the 6375796c8dcSSimon Schubert ability to decide for themselves if it is desired. */ 6385796c8dcSSimon Schubert if (opts.addressprint && mid_statement) 6395796c8dcSSimon Schubert { 6405796c8dcSSimon Schubert ui_out_field_core_addr (uiout, "addr", 6415796c8dcSSimon Schubert gdbarch, get_frame_pc (frame)); 6425796c8dcSSimon Schubert ui_out_text (uiout, "\t"); 6435796c8dcSSimon Schubert } 6445796c8dcSSimon Schubert 6455796c8dcSSimon Schubert print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); 6465796c8dcSSimon Schubert } 6475796c8dcSSimon Schubert } 6485796c8dcSSimon Schubert 6495796c8dcSSimon Schubert /* If disassemble-next-line is set to on and there is line debug 6505796c8dcSSimon Schubert messages, output assembly codes for next line. */ 6515796c8dcSSimon Schubert if (disassemble_next_line == AUTO_BOOLEAN_TRUE) 652*cf7f2e2dSJohn Marino do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end); 6535796c8dcSSimon Schubert } 6545796c8dcSSimon Schubert 6555796c8dcSSimon Schubert if (print_what != LOCATION) 656*cf7f2e2dSJohn Marino set_default_breakpoint (1, sal.pspace, 657*cf7f2e2dSJohn Marino get_frame_pc (frame), sal.symtab, sal.line); 6585796c8dcSSimon Schubert 6595796c8dcSSimon Schubert annotate_frame_end (); 6605796c8dcSSimon Schubert 6615796c8dcSSimon Schubert gdb_flush (gdb_stdout); 6625796c8dcSSimon Schubert } 6635796c8dcSSimon Schubert 6645796c8dcSSimon Schubert /* Attempt to obtain the FUNNAME and FUNLANG of the function corresponding 6655796c8dcSSimon Schubert to FRAME. */ 6665796c8dcSSimon Schubert void 6675796c8dcSSimon Schubert find_frame_funname (struct frame_info *frame, char **funname, 6685796c8dcSSimon Schubert enum language *funlang) 6695796c8dcSSimon Schubert { 6705796c8dcSSimon Schubert struct symbol *func; 6715796c8dcSSimon Schubert 6725796c8dcSSimon Schubert *funname = NULL; 6735796c8dcSSimon Schubert *funlang = language_unknown; 6745796c8dcSSimon Schubert 6755796c8dcSSimon Schubert func = get_frame_function (frame); 6765796c8dcSSimon Schubert if (func) 6775796c8dcSSimon Schubert { 6785796c8dcSSimon Schubert /* In certain pathological cases, the symtabs give the wrong 6795796c8dcSSimon Schubert function (when we are in the first function in a file which 6805796c8dcSSimon Schubert is compiled without debugging symbols, the previous function 6815796c8dcSSimon Schubert is compiled with debugging symbols, and the "foo.o" symbol 6825796c8dcSSimon Schubert that is supposed to tell us where the file with debugging 6835796c8dcSSimon Schubert symbols ends has been truncated by ar because it is longer 6845796c8dcSSimon Schubert than 15 characters). This also occurs if the user uses asm() 6855796c8dcSSimon Schubert to create a function but not stabs for it (in a file compiled 6865796c8dcSSimon Schubert with -g). 6875796c8dcSSimon Schubert 6885796c8dcSSimon Schubert So look in the minimal symbol tables as well, and if it comes 6895796c8dcSSimon Schubert up with a larger address for the function use that instead. 6905796c8dcSSimon Schubert I don't think this can ever cause any problems; there 6915796c8dcSSimon Schubert shouldn't be any minimal symbols in the middle of a function; 6925796c8dcSSimon Schubert if this is ever changed many parts of GDB will need to be 6935796c8dcSSimon Schubert changed (and we'll create a find_pc_minimal_function or some 6945796c8dcSSimon Schubert such). */ 6955796c8dcSSimon Schubert 6965796c8dcSSimon Schubert struct minimal_symbol *msymbol = NULL; 6975796c8dcSSimon Schubert 6985796c8dcSSimon Schubert /* Don't attempt to do this for inlined functions, which do not 6995796c8dcSSimon Schubert have a corresponding minimal symbol. */ 7005796c8dcSSimon Schubert if (!block_inlined_p (SYMBOL_BLOCK_VALUE (func))) 7015796c8dcSSimon Schubert msymbol 7025796c8dcSSimon Schubert = lookup_minimal_symbol_by_pc (get_frame_address_in_block (frame)); 7035796c8dcSSimon Schubert 7045796c8dcSSimon Schubert if (msymbol != NULL 7055796c8dcSSimon Schubert && (SYMBOL_VALUE_ADDRESS (msymbol) 7065796c8dcSSimon Schubert > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) 7075796c8dcSSimon Schubert { 7085796c8dcSSimon Schubert /* We also don't know anything about the function besides 7095796c8dcSSimon Schubert its address and name. */ 7105796c8dcSSimon Schubert func = 0; 7115796c8dcSSimon Schubert *funname = SYMBOL_PRINT_NAME (msymbol); 7125796c8dcSSimon Schubert *funlang = SYMBOL_LANGUAGE (msymbol); 7135796c8dcSSimon Schubert } 7145796c8dcSSimon Schubert else 7155796c8dcSSimon Schubert { 7165796c8dcSSimon Schubert *funname = SYMBOL_PRINT_NAME (func); 7175796c8dcSSimon Schubert *funlang = SYMBOL_LANGUAGE (func); 7185796c8dcSSimon Schubert if (*funlang == language_cplus) 7195796c8dcSSimon Schubert { 7205796c8dcSSimon Schubert /* It seems appropriate to use SYMBOL_PRINT_NAME() here, 7215796c8dcSSimon Schubert to display the demangled name that we already have 7225796c8dcSSimon Schubert stored in the symbol table, but we stored a version 7235796c8dcSSimon Schubert with DMGL_PARAMS turned on, and here we don't want to 7245796c8dcSSimon Schubert display parameters. So remove the parameters. */ 7255796c8dcSSimon Schubert char *func_only = cp_remove_params (*funname); 726*cf7f2e2dSJohn Marino 7275796c8dcSSimon Schubert if (func_only) 7285796c8dcSSimon Schubert { 7295796c8dcSSimon Schubert *funname = func_only; 7305796c8dcSSimon Schubert make_cleanup (xfree, func_only); 7315796c8dcSSimon Schubert } 7325796c8dcSSimon Schubert } 7335796c8dcSSimon Schubert } 7345796c8dcSSimon Schubert } 7355796c8dcSSimon Schubert else 7365796c8dcSSimon Schubert { 7375796c8dcSSimon Schubert struct minimal_symbol *msymbol = 7385796c8dcSSimon Schubert lookup_minimal_symbol_by_pc (get_frame_address_in_block (frame)); 7395796c8dcSSimon Schubert 7405796c8dcSSimon Schubert if (msymbol != NULL) 7415796c8dcSSimon Schubert { 7425796c8dcSSimon Schubert *funname = SYMBOL_PRINT_NAME (msymbol); 7435796c8dcSSimon Schubert *funlang = SYMBOL_LANGUAGE (msymbol); 7445796c8dcSSimon Schubert } 7455796c8dcSSimon Schubert } 7465796c8dcSSimon Schubert } 7475796c8dcSSimon Schubert 7485796c8dcSSimon Schubert static void 7495796c8dcSSimon Schubert print_frame (struct frame_info *frame, int print_level, 7505796c8dcSSimon Schubert enum print_what print_what, int print_args, 7515796c8dcSSimon Schubert struct symtab_and_line sal) 7525796c8dcSSimon Schubert { 7535796c8dcSSimon Schubert struct gdbarch *gdbarch = get_frame_arch (frame); 7545796c8dcSSimon Schubert char *funname = NULL; 7555796c8dcSSimon Schubert enum language funlang = language_unknown; 7565796c8dcSSimon Schubert struct ui_stream *stb; 7575796c8dcSSimon Schubert struct cleanup *old_chain, *list_chain; 7585796c8dcSSimon Schubert struct value_print_options opts; 7595796c8dcSSimon Schubert 7605796c8dcSSimon Schubert stb = ui_out_stream_new (uiout); 7615796c8dcSSimon Schubert old_chain = make_cleanup_ui_out_stream_delete (stb); 7625796c8dcSSimon Schubert 7635796c8dcSSimon Schubert find_frame_funname (frame, &funname, &funlang); 7645796c8dcSSimon Schubert 7655796c8dcSSimon Schubert annotate_frame_begin (print_level ? frame_relative_level (frame) : 0, 7665796c8dcSSimon Schubert gdbarch, get_frame_pc (frame)); 7675796c8dcSSimon Schubert 7685796c8dcSSimon Schubert list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); 7695796c8dcSSimon Schubert 7705796c8dcSSimon Schubert if (print_level) 7715796c8dcSSimon Schubert { 7725796c8dcSSimon Schubert ui_out_text (uiout, "#"); 7735796c8dcSSimon Schubert ui_out_field_fmt_int (uiout, 2, ui_left, "level", 7745796c8dcSSimon Schubert frame_relative_level (frame)); 7755796c8dcSSimon Schubert } 7765796c8dcSSimon Schubert get_user_print_options (&opts); 7775796c8dcSSimon Schubert if (opts.addressprint) 7785796c8dcSSimon Schubert if (frame_show_address (frame, sal) || !sal.symtab 7795796c8dcSSimon Schubert || print_what == LOC_AND_ADDRESS) 7805796c8dcSSimon Schubert { 7815796c8dcSSimon Schubert annotate_frame_address (); 7825796c8dcSSimon Schubert ui_out_field_core_addr (uiout, "addr", gdbarch, get_frame_pc (frame)); 7835796c8dcSSimon Schubert annotate_frame_address_end (); 7845796c8dcSSimon Schubert ui_out_text (uiout, " in "); 7855796c8dcSSimon Schubert } 7865796c8dcSSimon Schubert annotate_frame_function_name (); 7875796c8dcSSimon Schubert fprintf_symbol_filtered (stb->stream, funname ? funname : "??", 7885796c8dcSSimon Schubert funlang, DMGL_ANSI); 7895796c8dcSSimon Schubert ui_out_field_stream (uiout, "func", stb); 7905796c8dcSSimon Schubert ui_out_wrap_hint (uiout, " "); 7915796c8dcSSimon Schubert annotate_frame_args (); 7925796c8dcSSimon Schubert 7935796c8dcSSimon Schubert ui_out_text (uiout, " ("); 7945796c8dcSSimon Schubert if (print_args) 7955796c8dcSSimon Schubert { 7965796c8dcSSimon Schubert struct print_args_args args; 7975796c8dcSSimon Schubert struct cleanup *args_list_chain; 798*cf7f2e2dSJohn Marino 7995796c8dcSSimon Schubert args.frame = frame; 8005796c8dcSSimon Schubert args.func = find_pc_function (get_frame_address_in_block (frame)); 8015796c8dcSSimon Schubert args.stream = gdb_stdout; 8025796c8dcSSimon Schubert args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args"); 8035796c8dcSSimon Schubert catch_errors (print_args_stub, &args, "", RETURN_MASK_ERROR); 8045796c8dcSSimon Schubert /* FIXME: ARGS must be a list. If one argument is a string it 8055796c8dcSSimon Schubert will have " that will not be properly escaped. */ 8065796c8dcSSimon Schubert /* Invoke ui_out_tuple_end. */ 8075796c8dcSSimon Schubert do_cleanups (args_list_chain); 8085796c8dcSSimon Schubert QUIT; 8095796c8dcSSimon Schubert } 8105796c8dcSSimon Schubert ui_out_text (uiout, ")"); 8115796c8dcSSimon Schubert if (sal.symtab && sal.symtab->filename) 8125796c8dcSSimon Schubert { 8135796c8dcSSimon Schubert annotate_frame_source_begin (); 8145796c8dcSSimon Schubert ui_out_wrap_hint (uiout, " "); 8155796c8dcSSimon Schubert ui_out_text (uiout, " at "); 8165796c8dcSSimon Schubert annotate_frame_source_file (); 8175796c8dcSSimon Schubert ui_out_field_string (uiout, "file", sal.symtab->filename); 8185796c8dcSSimon Schubert if (ui_out_is_mi_like_p (uiout)) 8195796c8dcSSimon Schubert { 8205796c8dcSSimon Schubert const char *fullname = symtab_to_fullname (sal.symtab); 821*cf7f2e2dSJohn Marino 8225796c8dcSSimon Schubert if (fullname != NULL) 8235796c8dcSSimon Schubert ui_out_field_string (uiout, "fullname", fullname); 8245796c8dcSSimon Schubert } 8255796c8dcSSimon Schubert annotate_frame_source_file_end (); 8265796c8dcSSimon Schubert ui_out_text (uiout, ":"); 8275796c8dcSSimon Schubert annotate_frame_source_line (); 8285796c8dcSSimon Schubert ui_out_field_int (uiout, "line", sal.line); 8295796c8dcSSimon Schubert annotate_frame_source_end (); 8305796c8dcSSimon Schubert } 8315796c8dcSSimon Schubert 8325796c8dcSSimon Schubert if (!funname || (!sal.symtab || !sal.symtab->filename)) 8335796c8dcSSimon Schubert { 8345796c8dcSSimon Schubert #ifdef PC_SOLIB 8355796c8dcSSimon Schubert char *lib = PC_SOLIB (get_frame_pc (frame)); 8365796c8dcSSimon Schubert #else 837*cf7f2e2dSJohn Marino char *lib = solib_name_from_address (get_frame_program_space (frame), 838*cf7f2e2dSJohn Marino get_frame_pc (frame)); 8395796c8dcSSimon Schubert #endif 8405796c8dcSSimon Schubert if (lib) 8415796c8dcSSimon Schubert { 8425796c8dcSSimon Schubert annotate_frame_where (); 8435796c8dcSSimon Schubert ui_out_wrap_hint (uiout, " "); 8445796c8dcSSimon Schubert ui_out_text (uiout, " from "); 8455796c8dcSSimon Schubert ui_out_field_string (uiout, "from", lib); 8465796c8dcSSimon Schubert } 8475796c8dcSSimon Schubert } 8485796c8dcSSimon Schubert 8495796c8dcSSimon Schubert /* do_cleanups will call ui_out_tuple_end() for us. */ 8505796c8dcSSimon Schubert do_cleanups (list_chain); 8515796c8dcSSimon Schubert ui_out_text (uiout, "\n"); 8525796c8dcSSimon Schubert do_cleanups (old_chain); 8535796c8dcSSimon Schubert } 8545796c8dcSSimon Schubert 8555796c8dcSSimon Schubert 8565796c8dcSSimon Schubert /* Read a frame specification in whatever the appropriate format is 8575796c8dcSSimon Schubert from FRAME_EXP. Call error(), printing MESSAGE, if the 8585796c8dcSSimon Schubert specification is in any way invalid (so this function never returns 8595796c8dcSSimon Schubert NULL). When SEPECTED_P is non-NULL set its target to indicate that 8605796c8dcSSimon Schubert the default selected frame was used. */ 8615796c8dcSSimon Schubert 8625796c8dcSSimon Schubert static struct frame_info * 8635796c8dcSSimon Schubert parse_frame_specification_1 (const char *frame_exp, const char *message, 8645796c8dcSSimon Schubert int *selected_frame_p) 8655796c8dcSSimon Schubert { 8665796c8dcSSimon Schubert int numargs; 8675796c8dcSSimon Schubert struct value *args[4]; 8685796c8dcSSimon Schubert CORE_ADDR addrs[ARRAY_SIZE (args)]; 8695796c8dcSSimon Schubert 8705796c8dcSSimon Schubert if (frame_exp == NULL) 8715796c8dcSSimon Schubert numargs = 0; 8725796c8dcSSimon Schubert else 8735796c8dcSSimon Schubert { 8745796c8dcSSimon Schubert numargs = 0; 8755796c8dcSSimon Schubert while (1) 8765796c8dcSSimon Schubert { 8775796c8dcSSimon Schubert char *addr_string; 8785796c8dcSSimon Schubert struct cleanup *cleanup; 8795796c8dcSSimon Schubert const char *p; 8805796c8dcSSimon Schubert 8815796c8dcSSimon Schubert /* Skip leading white space, bail of EOL. */ 8825796c8dcSSimon Schubert while (isspace (*frame_exp)) 8835796c8dcSSimon Schubert frame_exp++; 8845796c8dcSSimon Schubert if (!*frame_exp) 8855796c8dcSSimon Schubert break; 8865796c8dcSSimon Schubert 8875796c8dcSSimon Schubert /* Parse the argument, extract it, save it. */ 8885796c8dcSSimon Schubert for (p = frame_exp; 8895796c8dcSSimon Schubert *p && !isspace (*p); 8905796c8dcSSimon Schubert p++); 8915796c8dcSSimon Schubert addr_string = savestring (frame_exp, p - frame_exp); 8925796c8dcSSimon Schubert frame_exp = p; 8935796c8dcSSimon Schubert cleanup = make_cleanup (xfree, addr_string); 8945796c8dcSSimon Schubert 8955796c8dcSSimon Schubert /* NOTE: Parse and evaluate expression, but do not use 8965796c8dcSSimon Schubert functions such as parse_and_eval_long or 8975796c8dcSSimon Schubert parse_and_eval_address to also extract the value. 8985796c8dcSSimon Schubert Instead value_as_long and value_as_address are used. 8995796c8dcSSimon Schubert This avoids problems with expressions that contain 9005796c8dcSSimon Schubert side-effects. */ 9015796c8dcSSimon Schubert if (numargs >= ARRAY_SIZE (args)) 9025796c8dcSSimon Schubert error (_("Too many args in frame specification")); 9035796c8dcSSimon Schubert args[numargs++] = parse_and_eval (addr_string); 9045796c8dcSSimon Schubert 9055796c8dcSSimon Schubert do_cleanups (cleanup); 9065796c8dcSSimon Schubert } 9075796c8dcSSimon Schubert } 9085796c8dcSSimon Schubert 9095796c8dcSSimon Schubert /* If no args, default to the selected frame. */ 9105796c8dcSSimon Schubert if (numargs == 0) 9115796c8dcSSimon Schubert { 9125796c8dcSSimon Schubert if (selected_frame_p != NULL) 9135796c8dcSSimon Schubert (*selected_frame_p) = 1; 9145796c8dcSSimon Schubert return get_selected_frame (message); 9155796c8dcSSimon Schubert } 9165796c8dcSSimon Schubert 9175796c8dcSSimon Schubert /* None of the remaining use the selected frame. */ 9185796c8dcSSimon Schubert if (selected_frame_p != NULL) 9195796c8dcSSimon Schubert (*selected_frame_p) = 0; 9205796c8dcSSimon Schubert 9215796c8dcSSimon Schubert /* Assume the single arg[0] is an integer, and try using that to 9225796c8dcSSimon Schubert select a frame relative to current. */ 9235796c8dcSSimon Schubert if (numargs == 1) 9245796c8dcSSimon Schubert { 9255796c8dcSSimon Schubert struct frame_info *fid; 9265796c8dcSSimon Schubert int level = value_as_long (args[0]); 927*cf7f2e2dSJohn Marino 9285796c8dcSSimon Schubert fid = find_relative_frame (get_current_frame (), &level); 9295796c8dcSSimon Schubert if (level == 0) 9305796c8dcSSimon Schubert /* find_relative_frame was successful */ 9315796c8dcSSimon Schubert return fid; 9325796c8dcSSimon Schubert } 9335796c8dcSSimon Schubert 9345796c8dcSSimon Schubert /* Convert each value into a corresponding address. */ 9355796c8dcSSimon Schubert { 9365796c8dcSSimon Schubert int i; 937*cf7f2e2dSJohn Marino 9385796c8dcSSimon Schubert for (i = 0; i < numargs; i++) 9395796c8dcSSimon Schubert addrs[i] = value_as_address (args[i]); 9405796c8dcSSimon Schubert } 9415796c8dcSSimon Schubert 9425796c8dcSSimon Schubert /* Assume that the single arg[0] is an address, use that to identify 9435796c8dcSSimon Schubert a frame with a matching ID. Should this also accept stack/pc or 9445796c8dcSSimon Schubert stack/pc/special. */ 9455796c8dcSSimon Schubert if (numargs == 1) 9465796c8dcSSimon Schubert { 9475796c8dcSSimon Schubert struct frame_id id = frame_id_build_wild (addrs[0]); 9485796c8dcSSimon Schubert struct frame_info *fid; 9495796c8dcSSimon Schubert 9505796c8dcSSimon Schubert /* If (s)he specifies the frame with an address, he deserves 9515796c8dcSSimon Schubert what (s)he gets. Still, give the highest one that matches. 9525796c8dcSSimon Schubert (NOTE: cagney/2004-10-29: Why highest, or outer-most, I don't 9535796c8dcSSimon Schubert know). */ 9545796c8dcSSimon Schubert for (fid = get_current_frame (); 9555796c8dcSSimon Schubert fid != NULL; 9565796c8dcSSimon Schubert fid = get_prev_frame (fid)) 9575796c8dcSSimon Schubert { 9585796c8dcSSimon Schubert if (frame_id_eq (id, get_frame_id (fid))) 9595796c8dcSSimon Schubert { 9605796c8dcSSimon Schubert struct frame_info *prev_frame; 9615796c8dcSSimon Schubert 9625796c8dcSSimon Schubert while (1) 9635796c8dcSSimon Schubert { 9645796c8dcSSimon Schubert prev_frame = get_prev_frame (fid); 9655796c8dcSSimon Schubert if (!prev_frame 9665796c8dcSSimon Schubert || !frame_id_eq (id, get_frame_id (prev_frame))) 9675796c8dcSSimon Schubert break; 9685796c8dcSSimon Schubert fid = prev_frame; 9695796c8dcSSimon Schubert } 9705796c8dcSSimon Schubert return fid; 9715796c8dcSSimon Schubert } 9725796c8dcSSimon Schubert } 9735796c8dcSSimon Schubert } 9745796c8dcSSimon Schubert 9755796c8dcSSimon Schubert /* We couldn't identify the frame as an existing frame, but 9765796c8dcSSimon Schubert perhaps we can create one with a single argument. */ 9775796c8dcSSimon Schubert if (numargs == 1) 9785796c8dcSSimon Schubert return create_new_frame (addrs[0], 0); 9795796c8dcSSimon Schubert else if (numargs == 2) 9805796c8dcSSimon Schubert return create_new_frame (addrs[0], addrs[1]); 9815796c8dcSSimon Schubert else 9825796c8dcSSimon Schubert error (_("Too many args in frame specification")); 9835796c8dcSSimon Schubert } 9845796c8dcSSimon Schubert 9855796c8dcSSimon Schubert static struct frame_info * 9865796c8dcSSimon Schubert parse_frame_specification (char *frame_exp) 9875796c8dcSSimon Schubert { 9885796c8dcSSimon Schubert return parse_frame_specification_1 (frame_exp, NULL, NULL); 9895796c8dcSSimon Schubert } 9905796c8dcSSimon Schubert 9915796c8dcSSimon Schubert /* Print verbosely the selected frame or the frame at address 9925796c8dcSSimon Schubert ADDR_EXP. Absolutely all information in the frame is printed. */ 9935796c8dcSSimon Schubert 9945796c8dcSSimon Schubert static void 9955796c8dcSSimon Schubert frame_info (char *addr_exp, int from_tty) 9965796c8dcSSimon Schubert { 9975796c8dcSSimon Schubert struct frame_info *fi; 9985796c8dcSSimon Schubert struct symtab_and_line sal; 9995796c8dcSSimon Schubert struct symbol *func; 10005796c8dcSSimon Schubert struct symtab *s; 10015796c8dcSSimon Schubert struct frame_info *calling_frame_info; 1002*cf7f2e2dSJohn Marino int numregs; 10035796c8dcSSimon Schubert char *funname = 0; 10045796c8dcSSimon Schubert enum language funlang = language_unknown; 10055796c8dcSSimon Schubert const char *pc_regname; 10065796c8dcSSimon Schubert int selected_frame_p; 10075796c8dcSSimon Schubert struct gdbarch *gdbarch; 10085796c8dcSSimon Schubert struct cleanup *back_to = make_cleanup (null_cleanup, NULL); 10095796c8dcSSimon Schubert 10105796c8dcSSimon Schubert fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p); 10115796c8dcSSimon Schubert gdbarch = get_frame_arch (fi); 10125796c8dcSSimon Schubert 10135796c8dcSSimon Schubert /* Name of the value returned by get_frame_pc(). Per comments, "pc" 10145796c8dcSSimon Schubert is not a good name. */ 10155796c8dcSSimon Schubert if (gdbarch_pc_regnum (gdbarch) >= 0) 10165796c8dcSSimon Schubert /* OK, this is weird. The gdbarch_pc_regnum hardware register's value can 10175796c8dcSSimon Schubert easily not match that of the internal value returned by 10185796c8dcSSimon Schubert get_frame_pc(). */ 10195796c8dcSSimon Schubert pc_regname = gdbarch_register_name (gdbarch, gdbarch_pc_regnum (gdbarch)); 10205796c8dcSSimon Schubert else 10215796c8dcSSimon Schubert /* But then, this is weird to. Even without gdbarch_pc_regnum, an 10225796c8dcSSimon Schubert architectures will often have a hardware register called "pc", 10235796c8dcSSimon Schubert and that register's value, again, can easily not match 10245796c8dcSSimon Schubert get_frame_pc(). */ 10255796c8dcSSimon Schubert pc_regname = "pc"; 10265796c8dcSSimon Schubert 10275796c8dcSSimon Schubert find_frame_sal (fi, &sal); 10285796c8dcSSimon Schubert func = get_frame_function (fi); 10295796c8dcSSimon Schubert /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain 10305796c8dcSSimon Schubert the same value? */ 10315796c8dcSSimon Schubert s = find_pc_symtab (get_frame_pc (fi)); 10325796c8dcSSimon Schubert if (func) 10335796c8dcSSimon Schubert { 10345796c8dcSSimon Schubert funname = SYMBOL_PRINT_NAME (func); 10355796c8dcSSimon Schubert funlang = SYMBOL_LANGUAGE (func); 10365796c8dcSSimon Schubert if (funlang == language_cplus) 10375796c8dcSSimon Schubert { 10385796c8dcSSimon Schubert /* It seems appropriate to use SYMBOL_PRINT_NAME() here, 10395796c8dcSSimon Schubert to display the demangled name that we already have 10405796c8dcSSimon Schubert stored in the symbol table, but we stored a version 10415796c8dcSSimon Schubert with DMGL_PARAMS turned on, and here we don't want to 10425796c8dcSSimon Schubert display parameters. So remove the parameters. */ 10435796c8dcSSimon Schubert char *func_only = cp_remove_params (funname); 1044*cf7f2e2dSJohn Marino 10455796c8dcSSimon Schubert if (func_only) 10465796c8dcSSimon Schubert { 10475796c8dcSSimon Schubert funname = func_only; 10485796c8dcSSimon Schubert make_cleanup (xfree, func_only); 10495796c8dcSSimon Schubert } 10505796c8dcSSimon Schubert } 10515796c8dcSSimon Schubert } 10525796c8dcSSimon Schubert else 10535796c8dcSSimon Schubert { 10545796c8dcSSimon Schubert struct minimal_symbol *msymbol; 10555796c8dcSSimon Schubert 10565796c8dcSSimon Schubert msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi)); 10575796c8dcSSimon Schubert if (msymbol != NULL) 10585796c8dcSSimon Schubert { 10595796c8dcSSimon Schubert funname = SYMBOL_PRINT_NAME (msymbol); 10605796c8dcSSimon Schubert funlang = SYMBOL_LANGUAGE (msymbol); 10615796c8dcSSimon Schubert } 10625796c8dcSSimon Schubert } 10635796c8dcSSimon Schubert calling_frame_info = get_prev_frame (fi); 10645796c8dcSSimon Schubert 10655796c8dcSSimon Schubert if (selected_frame_p && frame_relative_level (fi) >= 0) 10665796c8dcSSimon Schubert { 10675796c8dcSSimon Schubert printf_filtered (_("Stack level %d, frame at "), 10685796c8dcSSimon Schubert frame_relative_level (fi)); 10695796c8dcSSimon Schubert } 10705796c8dcSSimon Schubert else 10715796c8dcSSimon Schubert { 10725796c8dcSSimon Schubert printf_filtered (_("Stack frame at ")); 10735796c8dcSSimon Schubert } 10745796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, get_frame_base (fi)), gdb_stdout); 10755796c8dcSSimon Schubert printf_filtered (":\n"); 10765796c8dcSSimon Schubert printf_filtered (" %s = ", pc_regname); 10775796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout); 10785796c8dcSSimon Schubert 10795796c8dcSSimon Schubert wrap_here (" "); 10805796c8dcSSimon Schubert if (funname) 10815796c8dcSSimon Schubert { 10825796c8dcSSimon Schubert printf_filtered (" in "); 10835796c8dcSSimon Schubert fprintf_symbol_filtered (gdb_stdout, funname, funlang, 10845796c8dcSSimon Schubert DMGL_ANSI | DMGL_PARAMS); 10855796c8dcSSimon Schubert } 10865796c8dcSSimon Schubert wrap_here (" "); 10875796c8dcSSimon Schubert if (sal.symtab) 10885796c8dcSSimon Schubert printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line); 10895796c8dcSSimon Schubert puts_filtered ("; "); 10905796c8dcSSimon Schubert wrap_here (" "); 10915796c8dcSSimon Schubert printf_filtered ("saved %s ", pc_regname); 10925796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, frame_unwind_caller_pc (fi)), gdb_stdout); 10935796c8dcSSimon Schubert printf_filtered ("\n"); 10945796c8dcSSimon Schubert 10955796c8dcSSimon Schubert if (calling_frame_info == NULL) 10965796c8dcSSimon Schubert { 10975796c8dcSSimon Schubert enum unwind_stop_reason reason; 10985796c8dcSSimon Schubert 10995796c8dcSSimon Schubert reason = get_frame_unwind_stop_reason (fi); 11005796c8dcSSimon Schubert if (reason != UNWIND_NO_REASON) 11015796c8dcSSimon Schubert printf_filtered (_(" Outermost frame: %s\n"), 11025796c8dcSSimon Schubert frame_stop_reason_string (reason)); 11035796c8dcSSimon Schubert } 11045796c8dcSSimon Schubert else if (get_frame_type (fi) == INLINE_FRAME) 11055796c8dcSSimon Schubert printf_filtered (" inlined into frame %d", 11065796c8dcSSimon Schubert frame_relative_level (get_prev_frame (fi))); 11075796c8dcSSimon Schubert else 11085796c8dcSSimon Schubert { 11095796c8dcSSimon Schubert printf_filtered (" called by frame at "); 11105796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, get_frame_base (calling_frame_info)), 11115796c8dcSSimon Schubert gdb_stdout); 11125796c8dcSSimon Schubert } 11135796c8dcSSimon Schubert if (get_next_frame (fi) && calling_frame_info) 11145796c8dcSSimon Schubert puts_filtered (","); 11155796c8dcSSimon Schubert wrap_here (" "); 11165796c8dcSSimon Schubert if (get_next_frame (fi)) 11175796c8dcSSimon Schubert { 11185796c8dcSSimon Schubert printf_filtered (" caller of frame at "); 11195796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, get_frame_base (get_next_frame (fi))), 11205796c8dcSSimon Schubert gdb_stdout); 11215796c8dcSSimon Schubert } 11225796c8dcSSimon Schubert if (get_next_frame (fi) || calling_frame_info) 11235796c8dcSSimon Schubert puts_filtered ("\n"); 11245796c8dcSSimon Schubert 11255796c8dcSSimon Schubert if (s) 11265796c8dcSSimon Schubert printf_filtered (" source language %s.\n", 11275796c8dcSSimon Schubert language_str (s->language)); 11285796c8dcSSimon Schubert 11295796c8dcSSimon Schubert { 11305796c8dcSSimon Schubert /* Address of the argument list for this frame, or 0. */ 11315796c8dcSSimon Schubert CORE_ADDR arg_list = get_frame_args_address (fi); 11325796c8dcSSimon Schubert /* Number of args for this frame, or -1 if unknown. */ 11335796c8dcSSimon Schubert int numargs; 11345796c8dcSSimon Schubert 11355796c8dcSSimon Schubert if (arg_list == 0) 11365796c8dcSSimon Schubert printf_filtered (" Arglist at unknown address.\n"); 11375796c8dcSSimon Schubert else 11385796c8dcSSimon Schubert { 11395796c8dcSSimon Schubert printf_filtered (" Arglist at "); 11405796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, arg_list), gdb_stdout); 11415796c8dcSSimon Schubert printf_filtered (","); 11425796c8dcSSimon Schubert 11435796c8dcSSimon Schubert if (!gdbarch_frame_num_args_p (gdbarch)) 11445796c8dcSSimon Schubert { 11455796c8dcSSimon Schubert numargs = -1; 11465796c8dcSSimon Schubert puts_filtered (" args: "); 11475796c8dcSSimon Schubert } 11485796c8dcSSimon Schubert else 11495796c8dcSSimon Schubert { 11505796c8dcSSimon Schubert numargs = gdbarch_frame_num_args (gdbarch, fi); 11515796c8dcSSimon Schubert gdb_assert (numargs >= 0); 11525796c8dcSSimon Schubert if (numargs == 0) 11535796c8dcSSimon Schubert puts_filtered (" no args."); 11545796c8dcSSimon Schubert else if (numargs == 1) 11555796c8dcSSimon Schubert puts_filtered (" 1 arg: "); 11565796c8dcSSimon Schubert else 11575796c8dcSSimon Schubert printf_filtered (" %d args: ", numargs); 11585796c8dcSSimon Schubert } 11595796c8dcSSimon Schubert print_frame_args (func, fi, numargs, gdb_stdout); 11605796c8dcSSimon Schubert puts_filtered ("\n"); 11615796c8dcSSimon Schubert } 11625796c8dcSSimon Schubert } 11635796c8dcSSimon Schubert { 11645796c8dcSSimon Schubert /* Address of the local variables for this frame, or 0. */ 11655796c8dcSSimon Schubert CORE_ADDR arg_list = get_frame_locals_address (fi); 11665796c8dcSSimon Schubert 11675796c8dcSSimon Schubert if (arg_list == 0) 11685796c8dcSSimon Schubert printf_filtered (" Locals at unknown address,"); 11695796c8dcSSimon Schubert else 11705796c8dcSSimon Schubert { 11715796c8dcSSimon Schubert printf_filtered (" Locals at "); 11725796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, arg_list), gdb_stdout); 11735796c8dcSSimon Schubert printf_filtered (","); 11745796c8dcSSimon Schubert } 11755796c8dcSSimon Schubert } 11765796c8dcSSimon Schubert 11775796c8dcSSimon Schubert /* Print as much information as possible on the location of all the 11785796c8dcSSimon Schubert registers. */ 11795796c8dcSSimon Schubert { 11805796c8dcSSimon Schubert enum lval_type lval; 11815796c8dcSSimon Schubert int optimized; 11825796c8dcSSimon Schubert CORE_ADDR addr; 11835796c8dcSSimon Schubert int realnum; 11845796c8dcSSimon Schubert int count; 11855796c8dcSSimon Schubert int i; 11865796c8dcSSimon Schubert int need_nl = 1; 11875796c8dcSSimon Schubert 11885796c8dcSSimon Schubert /* The sp is special; what's displayed isn't the save address, but 11895796c8dcSSimon Schubert the value of the previous frame's sp. This is a legacy thing, 11905796c8dcSSimon Schubert at one stage the frame cached the previous frame's SP instead 11915796c8dcSSimon Schubert of its address, hence it was easiest to just display the cached 11925796c8dcSSimon Schubert value. */ 11935796c8dcSSimon Schubert if (gdbarch_sp_regnum (gdbarch) >= 0) 11945796c8dcSSimon Schubert { 11955796c8dcSSimon Schubert /* Find out the location of the saved stack pointer with out 11965796c8dcSSimon Schubert actually evaluating it. */ 11975796c8dcSSimon Schubert frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch), 11985796c8dcSSimon Schubert &optimized, &lval, &addr, 11995796c8dcSSimon Schubert &realnum, NULL); 12005796c8dcSSimon Schubert if (!optimized && lval == not_lval) 12015796c8dcSSimon Schubert { 12025796c8dcSSimon Schubert enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 12035796c8dcSSimon Schubert int sp_size = register_size (gdbarch, gdbarch_sp_regnum (gdbarch)); 12045796c8dcSSimon Schubert gdb_byte value[MAX_REGISTER_SIZE]; 12055796c8dcSSimon Schubert CORE_ADDR sp; 1206*cf7f2e2dSJohn Marino 12075796c8dcSSimon Schubert frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch), 12085796c8dcSSimon Schubert &optimized, &lval, &addr, 12095796c8dcSSimon Schubert &realnum, value); 12105796c8dcSSimon Schubert /* NOTE: cagney/2003-05-22: This is assuming that the 12115796c8dcSSimon Schubert stack pointer was packed as an unsigned integer. That 12125796c8dcSSimon Schubert may or may not be valid. */ 12135796c8dcSSimon Schubert sp = extract_unsigned_integer (value, sp_size, byte_order); 12145796c8dcSSimon Schubert printf_filtered (" Previous frame's sp is "); 12155796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, sp), gdb_stdout); 12165796c8dcSSimon Schubert printf_filtered ("\n"); 12175796c8dcSSimon Schubert need_nl = 0; 12185796c8dcSSimon Schubert } 12195796c8dcSSimon Schubert else if (!optimized && lval == lval_memory) 12205796c8dcSSimon Schubert { 12215796c8dcSSimon Schubert printf_filtered (" Previous frame's sp at "); 12225796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, addr), gdb_stdout); 12235796c8dcSSimon Schubert printf_filtered ("\n"); 12245796c8dcSSimon Schubert need_nl = 0; 12255796c8dcSSimon Schubert } 12265796c8dcSSimon Schubert else if (!optimized && lval == lval_register) 12275796c8dcSSimon Schubert { 12285796c8dcSSimon Schubert printf_filtered (" Previous frame's sp in %s\n", 12295796c8dcSSimon Schubert gdbarch_register_name (gdbarch, realnum)); 12305796c8dcSSimon Schubert need_nl = 0; 12315796c8dcSSimon Schubert } 12325796c8dcSSimon Schubert /* else keep quiet. */ 12335796c8dcSSimon Schubert } 12345796c8dcSSimon Schubert 12355796c8dcSSimon Schubert count = 0; 12365796c8dcSSimon Schubert numregs = gdbarch_num_regs (gdbarch) 12375796c8dcSSimon Schubert + gdbarch_num_pseudo_regs (gdbarch); 12385796c8dcSSimon Schubert for (i = 0; i < numregs; i++) 12395796c8dcSSimon Schubert if (i != gdbarch_sp_regnum (gdbarch) 12405796c8dcSSimon Schubert && gdbarch_register_reggroup_p (gdbarch, i, all_reggroup)) 12415796c8dcSSimon Schubert { 12425796c8dcSSimon Schubert /* Find out the location of the saved register without 12435796c8dcSSimon Schubert fetching the corresponding value. */ 12445796c8dcSSimon Schubert frame_register_unwind (fi, i, &optimized, &lval, &addr, &realnum, 12455796c8dcSSimon Schubert NULL); 12465796c8dcSSimon Schubert /* For moment, only display registers that were saved on the 12475796c8dcSSimon Schubert stack. */ 12485796c8dcSSimon Schubert if (!optimized && lval == lval_memory) 12495796c8dcSSimon Schubert { 12505796c8dcSSimon Schubert if (count == 0) 12515796c8dcSSimon Schubert puts_filtered (" Saved registers:\n "); 12525796c8dcSSimon Schubert else 12535796c8dcSSimon Schubert puts_filtered (","); 12545796c8dcSSimon Schubert wrap_here (" "); 12555796c8dcSSimon Schubert printf_filtered (" %s at ", 12565796c8dcSSimon Schubert gdbarch_register_name (gdbarch, i)); 12575796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, addr), gdb_stdout); 12585796c8dcSSimon Schubert count++; 12595796c8dcSSimon Schubert } 12605796c8dcSSimon Schubert } 12615796c8dcSSimon Schubert if (count || need_nl) 12625796c8dcSSimon Schubert puts_filtered ("\n"); 12635796c8dcSSimon Schubert } 12645796c8dcSSimon Schubert 12655796c8dcSSimon Schubert do_cleanups (back_to); 12665796c8dcSSimon Schubert } 12675796c8dcSSimon Schubert 12685796c8dcSSimon Schubert /* Print briefly all stack frames or just the innermost COUNT_EXP 12695796c8dcSSimon Schubert frames. */ 12705796c8dcSSimon Schubert 12715796c8dcSSimon Schubert static void 12725796c8dcSSimon Schubert backtrace_command_1 (char *count_exp, int show_locals, int from_tty) 12735796c8dcSSimon Schubert { 12745796c8dcSSimon Schubert struct frame_info *fi; 12755796c8dcSSimon Schubert int count; 12765796c8dcSSimon Schubert int i; 12775796c8dcSSimon Schubert struct frame_info *trailing; 12785796c8dcSSimon Schubert int trailing_level; 12795796c8dcSSimon Schubert 12805796c8dcSSimon Schubert if (!target_has_stack) 12815796c8dcSSimon Schubert error (_("No stack.")); 12825796c8dcSSimon Schubert 12835796c8dcSSimon Schubert /* The following code must do two things. First, it must set the 12845796c8dcSSimon Schubert variable TRAILING to the frame from which we should start 12855796c8dcSSimon Schubert printing. Second, it must set the variable count to the number 12865796c8dcSSimon Schubert of frames which we should print, or -1 if all of them. */ 12875796c8dcSSimon Schubert trailing = get_current_frame (); 12885796c8dcSSimon Schubert 12895796c8dcSSimon Schubert trailing_level = 0; 12905796c8dcSSimon Schubert if (count_exp) 12915796c8dcSSimon Schubert { 12925796c8dcSSimon Schubert count = parse_and_eval_long (count_exp); 12935796c8dcSSimon Schubert if (count < 0) 12945796c8dcSSimon Schubert { 12955796c8dcSSimon Schubert struct frame_info *current; 12965796c8dcSSimon Schubert 12975796c8dcSSimon Schubert count = -count; 12985796c8dcSSimon Schubert 12995796c8dcSSimon Schubert current = trailing; 13005796c8dcSSimon Schubert while (current && count--) 13015796c8dcSSimon Schubert { 13025796c8dcSSimon Schubert QUIT; 13035796c8dcSSimon Schubert current = get_prev_frame (current); 13045796c8dcSSimon Schubert } 13055796c8dcSSimon Schubert 13065796c8dcSSimon Schubert /* Will stop when CURRENT reaches the top of the stack. 13075796c8dcSSimon Schubert TRAILING will be COUNT below it. */ 13085796c8dcSSimon Schubert while (current) 13095796c8dcSSimon Schubert { 13105796c8dcSSimon Schubert QUIT; 13115796c8dcSSimon Schubert trailing = get_prev_frame (trailing); 13125796c8dcSSimon Schubert current = get_prev_frame (current); 13135796c8dcSSimon Schubert trailing_level++; 13145796c8dcSSimon Schubert } 13155796c8dcSSimon Schubert 13165796c8dcSSimon Schubert count = -1; 13175796c8dcSSimon Schubert } 13185796c8dcSSimon Schubert } 13195796c8dcSSimon Schubert else 13205796c8dcSSimon Schubert count = -1; 13215796c8dcSSimon Schubert 13225796c8dcSSimon Schubert if (info_verbose) 13235796c8dcSSimon Schubert { 13245796c8dcSSimon Schubert /* Read in symbols for all of the frames. Need to do this in a 13255796c8dcSSimon Schubert separate pass so that "Reading in symbols for xxx" messages 13265796c8dcSSimon Schubert don't screw up the appearance of the backtrace. Also if 13275796c8dcSSimon Schubert people have strong opinions against reading symbols for 13285796c8dcSSimon Schubert backtrace this may have to be an option. */ 13295796c8dcSSimon Schubert i = count; 13305796c8dcSSimon Schubert for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi)) 13315796c8dcSSimon Schubert { 1332*cf7f2e2dSJohn Marino CORE_ADDR pc; 1333*cf7f2e2dSJohn Marino 13345796c8dcSSimon Schubert QUIT; 1335*cf7f2e2dSJohn Marino pc = get_frame_address_in_block (fi); 1336*cf7f2e2dSJohn Marino find_pc_sect_symtab_via_partial (pc, find_pc_mapped_section (pc)); 13375796c8dcSSimon Schubert } 13385796c8dcSSimon Schubert } 13395796c8dcSSimon Schubert 13405796c8dcSSimon Schubert for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi)) 13415796c8dcSSimon Schubert { 13425796c8dcSSimon Schubert QUIT; 13435796c8dcSSimon Schubert 13445796c8dcSSimon Schubert /* Don't use print_stack_frame; if an error() occurs it probably 13455796c8dcSSimon Schubert means further attempts to backtrace would fail (on the other 13465796c8dcSSimon Schubert hand, perhaps the code does or could be fixed to make sure 13475796c8dcSSimon Schubert the frame->prev field gets set to NULL in that case). */ 13485796c8dcSSimon Schubert print_frame_info (fi, 1, LOCATION, 1); 13495796c8dcSSimon Schubert if (show_locals) 13505796c8dcSSimon Schubert print_frame_local_vars (fi, 1, gdb_stdout); 13515796c8dcSSimon Schubert 13525796c8dcSSimon Schubert /* Save the last frame to check for error conditions. */ 13535796c8dcSSimon Schubert trailing = fi; 13545796c8dcSSimon Schubert } 13555796c8dcSSimon Schubert 13565796c8dcSSimon Schubert /* If we've stopped before the end, mention that. */ 13575796c8dcSSimon Schubert if (fi && from_tty) 13585796c8dcSSimon Schubert printf_filtered (_("(More stack frames follow...)\n")); 13595796c8dcSSimon Schubert 13605796c8dcSSimon Schubert /* If we've run out of frames, and the reason appears to be an error 13615796c8dcSSimon Schubert condition, print it. */ 13625796c8dcSSimon Schubert if (fi == NULL && trailing != NULL) 13635796c8dcSSimon Schubert { 13645796c8dcSSimon Schubert enum unwind_stop_reason reason; 13655796c8dcSSimon Schubert 13665796c8dcSSimon Schubert reason = get_frame_unwind_stop_reason (trailing); 13675796c8dcSSimon Schubert if (reason > UNWIND_FIRST_ERROR) 13685796c8dcSSimon Schubert printf_filtered (_("Backtrace stopped: %s\n"), 13695796c8dcSSimon Schubert frame_stop_reason_string (reason)); 13705796c8dcSSimon Schubert } 13715796c8dcSSimon Schubert } 13725796c8dcSSimon Schubert 13735796c8dcSSimon Schubert struct backtrace_command_args 13745796c8dcSSimon Schubert { 13755796c8dcSSimon Schubert char *count_exp; 13765796c8dcSSimon Schubert int show_locals; 13775796c8dcSSimon Schubert int from_tty; 13785796c8dcSSimon Schubert }; 13795796c8dcSSimon Schubert 13805796c8dcSSimon Schubert /* Stub for catch_errors. */ 13815796c8dcSSimon Schubert 13825796c8dcSSimon Schubert static int 13835796c8dcSSimon Schubert backtrace_command_stub (void *data) 13845796c8dcSSimon Schubert { 13855796c8dcSSimon Schubert struct backtrace_command_args *args = data; 1386*cf7f2e2dSJohn Marino 13875796c8dcSSimon Schubert backtrace_command_1 (args->count_exp, args->show_locals, args->from_tty); 13885796c8dcSSimon Schubert return 0; 13895796c8dcSSimon Schubert } 13905796c8dcSSimon Schubert 13915796c8dcSSimon Schubert static void 13925796c8dcSSimon Schubert backtrace_command (char *arg, int from_tty) 13935796c8dcSSimon Schubert { 13945796c8dcSSimon Schubert struct cleanup *old_chain = NULL; 13955796c8dcSSimon Schubert int fulltrace_arg = -1, arglen = 0, argc = 0; 13965796c8dcSSimon Schubert struct backtrace_command_args btargs; 13975796c8dcSSimon Schubert 13985796c8dcSSimon Schubert if (arg) 13995796c8dcSSimon Schubert { 14005796c8dcSSimon Schubert char **argv; 14015796c8dcSSimon Schubert int i; 14025796c8dcSSimon Schubert 14035796c8dcSSimon Schubert argv = gdb_buildargv (arg); 14045796c8dcSSimon Schubert old_chain = make_cleanup_freeargv (argv); 14055796c8dcSSimon Schubert argc = 0; 14065796c8dcSSimon Schubert for (i = 0; argv[i]; i++) 14075796c8dcSSimon Schubert { 14085796c8dcSSimon Schubert unsigned int j; 14095796c8dcSSimon Schubert 14105796c8dcSSimon Schubert for (j = 0; j < strlen (argv[i]); j++) 14115796c8dcSSimon Schubert argv[i][j] = tolower (argv[i][j]); 14125796c8dcSSimon Schubert 14135796c8dcSSimon Schubert if (fulltrace_arg < 0 && subset_compare (argv[i], "full")) 14145796c8dcSSimon Schubert fulltrace_arg = argc; 14155796c8dcSSimon Schubert else 14165796c8dcSSimon Schubert { 14175796c8dcSSimon Schubert arglen += strlen (argv[i]); 14185796c8dcSSimon Schubert argc++; 14195796c8dcSSimon Schubert } 14205796c8dcSSimon Schubert } 14215796c8dcSSimon Schubert arglen += argc; 14225796c8dcSSimon Schubert if (fulltrace_arg >= 0) 14235796c8dcSSimon Schubert { 14245796c8dcSSimon Schubert if (arglen > 0) 14255796c8dcSSimon Schubert { 14265796c8dcSSimon Schubert arg = xmalloc (arglen + 1); 14275796c8dcSSimon Schubert memset (arg, 0, arglen + 1); 14285796c8dcSSimon Schubert for (i = 0; i < (argc + 1); i++) 14295796c8dcSSimon Schubert { 14305796c8dcSSimon Schubert if (i != fulltrace_arg) 14315796c8dcSSimon Schubert { 14325796c8dcSSimon Schubert strcat (arg, argv[i]); 14335796c8dcSSimon Schubert strcat (arg, " "); 14345796c8dcSSimon Schubert } 14355796c8dcSSimon Schubert } 14365796c8dcSSimon Schubert } 14375796c8dcSSimon Schubert else 14385796c8dcSSimon Schubert arg = NULL; 14395796c8dcSSimon Schubert } 14405796c8dcSSimon Schubert } 14415796c8dcSSimon Schubert 14425796c8dcSSimon Schubert btargs.count_exp = arg; 14435796c8dcSSimon Schubert btargs.show_locals = (fulltrace_arg >= 0); 14445796c8dcSSimon Schubert btargs.from_tty = from_tty; 14455796c8dcSSimon Schubert catch_errors (backtrace_command_stub, &btargs, "", RETURN_MASK_ERROR); 14465796c8dcSSimon Schubert 14475796c8dcSSimon Schubert if (fulltrace_arg >= 0 && arglen > 0) 14485796c8dcSSimon Schubert xfree (arg); 14495796c8dcSSimon Schubert 14505796c8dcSSimon Schubert if (old_chain) 14515796c8dcSSimon Schubert do_cleanups (old_chain); 14525796c8dcSSimon Schubert } 14535796c8dcSSimon Schubert 14545796c8dcSSimon Schubert static void 14555796c8dcSSimon Schubert backtrace_full_command (char *arg, int from_tty) 14565796c8dcSSimon Schubert { 14575796c8dcSSimon Schubert struct backtrace_command_args btargs; 1458*cf7f2e2dSJohn Marino 14595796c8dcSSimon Schubert btargs.count_exp = arg; 14605796c8dcSSimon Schubert btargs.show_locals = 1; 14615796c8dcSSimon Schubert btargs.from_tty = from_tty; 14625796c8dcSSimon Schubert catch_errors (backtrace_command_stub, &btargs, "", RETURN_MASK_ERROR); 14635796c8dcSSimon Schubert } 14645796c8dcSSimon Schubert 14655796c8dcSSimon Schubert 1466*cf7f2e2dSJohn Marino /* Iterate over the local variables of a block B, calling CB with 1467*cf7f2e2dSJohn Marino CB_DATA. */ 14685796c8dcSSimon Schubert 1469*cf7f2e2dSJohn Marino static void 1470*cf7f2e2dSJohn Marino iterate_over_block_locals (struct block *b, 1471*cf7f2e2dSJohn Marino iterate_over_block_arg_local_vars_cb cb, 1472*cf7f2e2dSJohn Marino void *cb_data) 14735796c8dcSSimon Schubert { 14745796c8dcSSimon Schubert struct dict_iterator iter; 14755796c8dcSSimon Schubert struct symbol *sym; 14765796c8dcSSimon Schubert 14775796c8dcSSimon Schubert ALL_BLOCK_SYMBOLS (b, iter, sym) 14785796c8dcSSimon Schubert { 14795796c8dcSSimon Schubert switch (SYMBOL_CLASS (sym)) 14805796c8dcSSimon Schubert { 14815796c8dcSSimon Schubert case LOC_LOCAL: 14825796c8dcSSimon Schubert case LOC_REGISTER: 14835796c8dcSSimon Schubert case LOC_STATIC: 14845796c8dcSSimon Schubert case LOC_COMPUTED: 14855796c8dcSSimon Schubert if (SYMBOL_IS_ARGUMENT (sym)) 14865796c8dcSSimon Schubert break; 1487*cf7f2e2dSJohn Marino (*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data); 14885796c8dcSSimon Schubert break; 14895796c8dcSSimon Schubert 14905796c8dcSSimon Schubert default: 14915796c8dcSSimon Schubert /* Ignore symbols which are not locals. */ 14925796c8dcSSimon Schubert break; 14935796c8dcSSimon Schubert } 14945796c8dcSSimon Schubert } 14955796c8dcSSimon Schubert } 14965796c8dcSSimon Schubert 1497*cf7f2e2dSJohn Marino 14985796c8dcSSimon Schubert /* Same, but print labels. */ 14995796c8dcSSimon Schubert 1500*cf7f2e2dSJohn Marino #if 0 1501*cf7f2e2dSJohn Marino /* Commented out, as the code using this function has also been 1502*cf7f2e2dSJohn Marino commented out. FIXME:brobecker/2009-01-13: Find out why the code 1503*cf7f2e2dSJohn Marino was commented out in the first place. The discussion introducing 1504*cf7f2e2dSJohn Marino this change (2007-12-04: Support lexical blocks and function bodies 1505*cf7f2e2dSJohn Marino that occupy non-contiguous address ranges) did not explain why 1506*cf7f2e2dSJohn Marino this change was made. */ 15075796c8dcSSimon Schubert static int 15085796c8dcSSimon Schubert print_block_frame_labels (struct gdbarch *gdbarch, struct block *b, 15095796c8dcSSimon Schubert int *have_default, struct ui_file *stream) 15105796c8dcSSimon Schubert { 15115796c8dcSSimon Schubert struct dict_iterator iter; 15125796c8dcSSimon Schubert struct symbol *sym; 15135796c8dcSSimon Schubert int values_printed = 0; 15145796c8dcSSimon Schubert 15155796c8dcSSimon Schubert ALL_BLOCK_SYMBOLS (b, iter, sym) 15165796c8dcSSimon Schubert { 15175796c8dcSSimon Schubert if (strcmp (SYMBOL_LINKAGE_NAME (sym), "default") == 0) 15185796c8dcSSimon Schubert { 15195796c8dcSSimon Schubert if (*have_default) 15205796c8dcSSimon Schubert continue; 15215796c8dcSSimon Schubert *have_default = 1; 15225796c8dcSSimon Schubert } 15235796c8dcSSimon Schubert if (SYMBOL_CLASS (sym) == LOC_LABEL) 15245796c8dcSSimon Schubert { 15255796c8dcSSimon Schubert struct symtab_and_line sal; 15265796c8dcSSimon Schubert struct value_print_options opts; 1527*cf7f2e2dSJohn Marino 15285796c8dcSSimon Schubert sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); 15295796c8dcSSimon Schubert values_printed = 1; 15305796c8dcSSimon Schubert fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); 15315796c8dcSSimon Schubert get_user_print_options (&opts); 15325796c8dcSSimon Schubert if (opts.addressprint) 15335796c8dcSSimon Schubert { 15345796c8dcSSimon Schubert fprintf_filtered (stream, " "); 15355796c8dcSSimon Schubert fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (sym)), 15365796c8dcSSimon Schubert stream); 15375796c8dcSSimon Schubert } 15385796c8dcSSimon Schubert fprintf_filtered (stream, " in file %s, line %d\n", 15395796c8dcSSimon Schubert sal.symtab->filename, sal.line); 15405796c8dcSSimon Schubert } 15415796c8dcSSimon Schubert } 15425796c8dcSSimon Schubert 15435796c8dcSSimon Schubert return values_printed; 15445796c8dcSSimon Schubert } 1545*cf7f2e2dSJohn Marino #endif 15465796c8dcSSimon Schubert 1547*cf7f2e2dSJohn Marino /* Iterate over all the local variables in block B, including all its 1548*cf7f2e2dSJohn Marino superblocks, stopping when the top-level block is reached. */ 15495796c8dcSSimon Schubert 1550*cf7f2e2dSJohn Marino void 1551*cf7f2e2dSJohn Marino iterate_over_block_local_vars (struct block *block, 1552*cf7f2e2dSJohn Marino iterate_over_block_arg_local_vars_cb cb, 1553*cf7f2e2dSJohn Marino void *cb_data) 1554*cf7f2e2dSJohn Marino { 1555*cf7f2e2dSJohn Marino while (block) 1556*cf7f2e2dSJohn Marino { 1557*cf7f2e2dSJohn Marino iterate_over_block_locals (block, cb, cb_data); 1558*cf7f2e2dSJohn Marino /* After handling the function's top-level block, stop. Don't 1559*cf7f2e2dSJohn Marino continue to its superblock, the block of per-file 1560*cf7f2e2dSJohn Marino symbols. */ 1561*cf7f2e2dSJohn Marino if (BLOCK_FUNCTION (block)) 1562*cf7f2e2dSJohn Marino break; 1563*cf7f2e2dSJohn Marino block = BLOCK_SUPERBLOCK (block); 1564*cf7f2e2dSJohn Marino } 1565*cf7f2e2dSJohn Marino } 1566*cf7f2e2dSJohn Marino 1567*cf7f2e2dSJohn Marino /* Data to be passed around in the calls to the locals and args 1568*cf7f2e2dSJohn Marino iterators. */ 1569*cf7f2e2dSJohn Marino 1570*cf7f2e2dSJohn Marino struct print_variable_and_value_data 1571*cf7f2e2dSJohn Marino { 1572*cf7f2e2dSJohn Marino struct frame_info *frame; 1573*cf7f2e2dSJohn Marino int num_tabs; 1574*cf7f2e2dSJohn Marino struct ui_file *stream; 1575*cf7f2e2dSJohn Marino int values_printed; 1576*cf7f2e2dSJohn Marino }; 1577*cf7f2e2dSJohn Marino 1578*cf7f2e2dSJohn Marino /* The callback for the locals and args iterators */ 1579*cf7f2e2dSJohn Marino 1580*cf7f2e2dSJohn Marino static void 1581*cf7f2e2dSJohn Marino do_print_variable_and_value (const char *print_name, 1582*cf7f2e2dSJohn Marino struct symbol *sym, 1583*cf7f2e2dSJohn Marino void *cb_data) 1584*cf7f2e2dSJohn Marino { 1585*cf7f2e2dSJohn Marino struct print_variable_and_value_data *p = cb_data; 1586*cf7f2e2dSJohn Marino 1587*cf7f2e2dSJohn Marino print_variable_and_value (print_name, sym, 1588*cf7f2e2dSJohn Marino p->frame, p->stream, p->num_tabs); 1589*cf7f2e2dSJohn Marino p->values_printed = 1; 1590*cf7f2e2dSJohn Marino } 15915796c8dcSSimon Schubert 15925796c8dcSSimon Schubert static void 15935796c8dcSSimon Schubert print_frame_local_vars (struct frame_info *frame, int num_tabs, 15945796c8dcSSimon Schubert struct ui_file *stream) 15955796c8dcSSimon Schubert { 1596*cf7f2e2dSJohn Marino struct print_variable_and_value_data cb_data; 1597*cf7f2e2dSJohn Marino struct block *block; 15985796c8dcSSimon Schubert 1599*cf7f2e2dSJohn Marino block = get_frame_block (frame, 0); 16005796c8dcSSimon Schubert if (block == 0) 16015796c8dcSSimon Schubert { 16025796c8dcSSimon Schubert fprintf_filtered (stream, "No symbol table info available.\n"); 16035796c8dcSSimon Schubert return; 16045796c8dcSSimon Schubert } 16055796c8dcSSimon Schubert 1606*cf7f2e2dSJohn Marino cb_data.frame = frame; 1607*cf7f2e2dSJohn Marino cb_data.num_tabs = 4 * num_tabs; 1608*cf7f2e2dSJohn Marino cb_data.stream = stream; 1609*cf7f2e2dSJohn Marino cb_data.values_printed = 0; 16105796c8dcSSimon Schubert 1611*cf7f2e2dSJohn Marino iterate_over_block_local_vars (block, 1612*cf7f2e2dSJohn Marino do_print_variable_and_value, 1613*cf7f2e2dSJohn Marino &cb_data); 1614*cf7f2e2dSJohn Marino 1615*cf7f2e2dSJohn Marino if (!cb_data.values_printed) 16165796c8dcSSimon Schubert fprintf_filtered (stream, _("No locals.\n")); 16175796c8dcSSimon Schubert } 16185796c8dcSSimon Schubert 16195796c8dcSSimon Schubert /* Same, but print labels. */ 16205796c8dcSSimon Schubert 16215796c8dcSSimon Schubert static void 16225796c8dcSSimon Schubert print_frame_label_vars (struct frame_info *frame, int this_level_only, 16235796c8dcSSimon Schubert struct ui_file *stream) 16245796c8dcSSimon Schubert { 16255796c8dcSSimon Schubert #if 1 16265796c8dcSSimon Schubert fprintf_filtered (stream, "print_frame_label_vars disabled.\n"); 16275796c8dcSSimon Schubert #else 16285796c8dcSSimon Schubert struct blockvector *bl; 16295796c8dcSSimon Schubert struct block *block = get_frame_block (frame, 0); 16305796c8dcSSimon Schubert struct gdbarch *gdbarch = get_frame_arch (frame); 16315796c8dcSSimon Schubert int values_printed = 0; 16325796c8dcSSimon Schubert int index, have_default = 0; 16335796c8dcSSimon Schubert char *blocks_printed; 16345796c8dcSSimon Schubert CORE_ADDR pc = get_frame_pc (frame); 16355796c8dcSSimon Schubert 16365796c8dcSSimon Schubert if (block == 0) 16375796c8dcSSimon Schubert { 16385796c8dcSSimon Schubert fprintf_filtered (stream, "No symbol table info available.\n"); 16395796c8dcSSimon Schubert return; 16405796c8dcSSimon Schubert } 16415796c8dcSSimon Schubert 16425796c8dcSSimon Schubert bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); 16435796c8dcSSimon Schubert blocks_printed = alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); 16445796c8dcSSimon Schubert memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); 16455796c8dcSSimon Schubert 16465796c8dcSSimon Schubert while (block != 0) 16475796c8dcSSimon Schubert { 16485796c8dcSSimon Schubert CORE_ADDR end = BLOCK_END (block) - 4; 16495796c8dcSSimon Schubert int last_index; 16505796c8dcSSimon Schubert 16515796c8dcSSimon Schubert if (bl != blockvector_for_pc (end, &index)) 16525796c8dcSSimon Schubert error (_("blockvector blotch")); 16535796c8dcSSimon Schubert if (BLOCKVECTOR_BLOCK (bl, index) != block) 16545796c8dcSSimon Schubert error (_("blockvector botch")); 16555796c8dcSSimon Schubert last_index = BLOCKVECTOR_NBLOCKS (bl); 16565796c8dcSSimon Schubert index += 1; 16575796c8dcSSimon Schubert 16585796c8dcSSimon Schubert /* Don't print out blocks that have gone by. */ 16595796c8dcSSimon Schubert while (index < last_index 16605796c8dcSSimon Schubert && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc) 16615796c8dcSSimon Schubert index++; 16625796c8dcSSimon Schubert 16635796c8dcSSimon Schubert while (index < last_index 16645796c8dcSSimon Schubert && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end) 16655796c8dcSSimon Schubert { 16665796c8dcSSimon Schubert if (blocks_printed[index] == 0) 16675796c8dcSSimon Schubert { 16685796c8dcSSimon Schubert if (print_block_frame_labels (gdbarch, 16695796c8dcSSimon Schubert BLOCKVECTOR_BLOCK (bl, index), 16705796c8dcSSimon Schubert &have_default, stream)) 16715796c8dcSSimon Schubert values_printed = 1; 16725796c8dcSSimon Schubert blocks_printed[index] = 1; 16735796c8dcSSimon Schubert } 16745796c8dcSSimon Schubert index++; 16755796c8dcSSimon Schubert } 16765796c8dcSSimon Schubert if (have_default) 16775796c8dcSSimon Schubert return; 16785796c8dcSSimon Schubert if (values_printed && this_level_only) 16795796c8dcSSimon Schubert return; 16805796c8dcSSimon Schubert 16815796c8dcSSimon Schubert /* After handling the function's top-level block, stop. Don't 16825796c8dcSSimon Schubert continue to its superblock, the block of per-file symbols. 16835796c8dcSSimon Schubert Also do not continue to the containing function of an inlined 16845796c8dcSSimon Schubert function. */ 16855796c8dcSSimon Schubert if (BLOCK_FUNCTION (block)) 16865796c8dcSSimon Schubert break; 16875796c8dcSSimon Schubert block = BLOCK_SUPERBLOCK (block); 16885796c8dcSSimon Schubert } 16895796c8dcSSimon Schubert 16905796c8dcSSimon Schubert if (!values_printed && !this_level_only) 16915796c8dcSSimon Schubert fprintf_filtered (stream, _("No catches.\n")); 16925796c8dcSSimon Schubert #endif 16935796c8dcSSimon Schubert } 16945796c8dcSSimon Schubert 16955796c8dcSSimon Schubert void 16965796c8dcSSimon Schubert locals_info (char *args, int from_tty) 16975796c8dcSSimon Schubert { 16985796c8dcSSimon Schubert print_frame_local_vars (get_selected_frame (_("No frame selected.")), 16995796c8dcSSimon Schubert 0, gdb_stdout); 17005796c8dcSSimon Schubert } 17015796c8dcSSimon Schubert 17025796c8dcSSimon Schubert static void 17035796c8dcSSimon Schubert catch_info (char *ignore, int from_tty) 17045796c8dcSSimon Schubert { 17055796c8dcSSimon Schubert /* Assume g++ compiled code; old GDB 4.16 behaviour. */ 17065796c8dcSSimon Schubert print_frame_label_vars (get_selected_frame (_("No frame selected.")), 17075796c8dcSSimon Schubert 0, gdb_stdout); 17085796c8dcSSimon Schubert } 17095796c8dcSSimon Schubert 1710*cf7f2e2dSJohn Marino /* Iterate over all the argument variables in block B. 1711*cf7f2e2dSJohn Marino 1712*cf7f2e2dSJohn Marino Returns 1 if any argument was walked; 0 otherwise. */ 1713*cf7f2e2dSJohn Marino 1714*cf7f2e2dSJohn Marino void 1715*cf7f2e2dSJohn Marino iterate_over_block_arg_vars (struct block *b, 1716*cf7f2e2dSJohn Marino iterate_over_block_arg_local_vars_cb cb, 1717*cf7f2e2dSJohn Marino void *cb_data) 17185796c8dcSSimon Schubert { 17195796c8dcSSimon Schubert struct dict_iterator iter; 17205796c8dcSSimon Schubert struct symbol *sym, *sym2; 17215796c8dcSSimon Schubert 17225796c8dcSSimon Schubert ALL_BLOCK_SYMBOLS (b, iter, sym) 17235796c8dcSSimon Schubert { 17245796c8dcSSimon Schubert /* Don't worry about things which aren't arguments. */ 17255796c8dcSSimon Schubert if (SYMBOL_IS_ARGUMENT (sym)) 17265796c8dcSSimon Schubert { 17275796c8dcSSimon Schubert /* We have to look up the symbol because arguments can have 17285796c8dcSSimon Schubert two entries (one a parameter, one a local) and the one we 17295796c8dcSSimon Schubert want is the local, which lookup_symbol will find for us. 17305796c8dcSSimon Schubert This includes gcc1 (not gcc2) on the sparc when passing a 17315796c8dcSSimon Schubert small structure and gcc2 when the argument type is float 17325796c8dcSSimon Schubert and it is passed as a double and converted to float by 17335796c8dcSSimon Schubert the prologue (in the latter case the type of the LOC_ARG 17345796c8dcSSimon Schubert symbol is double and the type of the LOC_LOCAL symbol is 17355796c8dcSSimon Schubert float). There are also LOC_ARG/LOC_REGISTER pairs which 17365796c8dcSSimon Schubert are not combined in symbol-reading. */ 17375796c8dcSSimon Schubert 17385796c8dcSSimon Schubert sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), 17395796c8dcSSimon Schubert b, VAR_DOMAIN, NULL); 1740*cf7f2e2dSJohn Marino (*cb) (SYMBOL_PRINT_NAME (sym), sym2, cb_data); 1741*cf7f2e2dSJohn Marino } 17425796c8dcSSimon Schubert } 17435796c8dcSSimon Schubert } 17445796c8dcSSimon Schubert 1745*cf7f2e2dSJohn Marino static void 1746*cf7f2e2dSJohn Marino print_frame_arg_vars (struct frame_info *frame, struct ui_file *stream) 1747*cf7f2e2dSJohn Marino { 1748*cf7f2e2dSJohn Marino struct print_variable_and_value_data cb_data; 1749*cf7f2e2dSJohn Marino struct symbol *func; 1750*cf7f2e2dSJohn Marino 1751*cf7f2e2dSJohn Marino func = get_frame_function (frame); 1752*cf7f2e2dSJohn Marino if (func == NULL) 1753*cf7f2e2dSJohn Marino { 1754*cf7f2e2dSJohn Marino fprintf_filtered (stream, _("No symbol table info available.\n")); 1755*cf7f2e2dSJohn Marino return; 1756*cf7f2e2dSJohn Marino } 1757*cf7f2e2dSJohn Marino 1758*cf7f2e2dSJohn Marino cb_data.frame = frame; 1759*cf7f2e2dSJohn Marino cb_data.num_tabs = 0; 1760*cf7f2e2dSJohn Marino cb_data.stream = gdb_stdout; 1761*cf7f2e2dSJohn Marino cb_data.values_printed = 0; 1762*cf7f2e2dSJohn Marino 1763*cf7f2e2dSJohn Marino iterate_over_block_arg_vars (SYMBOL_BLOCK_VALUE (func), 1764*cf7f2e2dSJohn Marino do_print_variable_and_value, &cb_data); 1765*cf7f2e2dSJohn Marino 1766*cf7f2e2dSJohn Marino if (!cb_data.values_printed) 17675796c8dcSSimon Schubert fprintf_filtered (stream, _("No arguments.\n")); 17685796c8dcSSimon Schubert } 17695796c8dcSSimon Schubert 17705796c8dcSSimon Schubert void 17715796c8dcSSimon Schubert args_info (char *ignore, int from_tty) 17725796c8dcSSimon Schubert { 17735796c8dcSSimon Schubert print_frame_arg_vars (get_selected_frame (_("No frame selected.")), 17745796c8dcSSimon Schubert gdb_stdout); 17755796c8dcSSimon Schubert } 17765796c8dcSSimon Schubert 17775796c8dcSSimon Schubert 17785796c8dcSSimon Schubert static void 17795796c8dcSSimon Schubert args_plus_locals_info (char *ignore, int from_tty) 17805796c8dcSSimon Schubert { 17815796c8dcSSimon Schubert args_info (ignore, from_tty); 17825796c8dcSSimon Schubert locals_info (ignore, from_tty); 17835796c8dcSSimon Schubert } 17845796c8dcSSimon Schubert 17855796c8dcSSimon Schubert 17865796c8dcSSimon Schubert /* Select frame FRAME. Also print the stack frame and show the source 17875796c8dcSSimon Schubert if this is the tui version. */ 17885796c8dcSSimon Schubert static void 17895796c8dcSSimon Schubert select_and_print_frame (struct frame_info *frame) 17905796c8dcSSimon Schubert { 17915796c8dcSSimon Schubert select_frame (frame); 17925796c8dcSSimon Schubert if (frame) 17935796c8dcSSimon Schubert print_stack_frame (frame, 1, SRC_AND_LOC); 17945796c8dcSSimon Schubert } 17955796c8dcSSimon Schubert 17965796c8dcSSimon Schubert /* Return the symbol-block in which the selected frame is executing. 17975796c8dcSSimon Schubert Can return zero under various legitimate circumstances. 17985796c8dcSSimon Schubert 17995796c8dcSSimon Schubert If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant 18005796c8dcSSimon Schubert code address within the block returned. We use this to decide 18015796c8dcSSimon Schubert which macros are in scope. */ 18025796c8dcSSimon Schubert 18035796c8dcSSimon Schubert struct block * 18045796c8dcSSimon Schubert get_selected_block (CORE_ADDR *addr_in_block) 18055796c8dcSSimon Schubert { 18065796c8dcSSimon Schubert if (!has_stack_frames ()) 18075796c8dcSSimon Schubert return 0; 18085796c8dcSSimon Schubert 18095796c8dcSSimon Schubert return get_frame_block (get_selected_frame (NULL), addr_in_block); 18105796c8dcSSimon Schubert } 18115796c8dcSSimon Schubert 18125796c8dcSSimon Schubert /* Find a frame a certain number of levels away from FRAME. 18135796c8dcSSimon Schubert LEVEL_OFFSET_PTR points to an int containing the number of levels. 18145796c8dcSSimon Schubert Positive means go to earlier frames (up); negative, the reverse. 18155796c8dcSSimon Schubert The int that contains the number of levels is counted toward 18165796c8dcSSimon Schubert zero as the frames for those levels are found. 18175796c8dcSSimon Schubert If the top or bottom frame is reached, that frame is returned, 18185796c8dcSSimon Schubert but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates 18195796c8dcSSimon Schubert how much farther the original request asked to go. */ 18205796c8dcSSimon Schubert 18215796c8dcSSimon Schubert struct frame_info * 18225796c8dcSSimon Schubert find_relative_frame (struct frame_info *frame, int *level_offset_ptr) 18235796c8dcSSimon Schubert { 18245796c8dcSSimon Schubert /* Going up is simple: just call get_prev_frame enough times or 18255796c8dcSSimon Schubert until the initial frame is reached. */ 18265796c8dcSSimon Schubert while (*level_offset_ptr > 0) 18275796c8dcSSimon Schubert { 18285796c8dcSSimon Schubert struct frame_info *prev = get_prev_frame (frame); 1829*cf7f2e2dSJohn Marino 18305796c8dcSSimon Schubert if (!prev) 18315796c8dcSSimon Schubert break; 18325796c8dcSSimon Schubert (*level_offset_ptr)--; 18335796c8dcSSimon Schubert frame = prev; 18345796c8dcSSimon Schubert } 18355796c8dcSSimon Schubert 18365796c8dcSSimon Schubert /* Going down is just as simple. */ 18375796c8dcSSimon Schubert while (*level_offset_ptr < 0) 18385796c8dcSSimon Schubert { 18395796c8dcSSimon Schubert struct frame_info *next = get_next_frame (frame); 1840*cf7f2e2dSJohn Marino 18415796c8dcSSimon Schubert if (!next) 18425796c8dcSSimon Schubert break; 18435796c8dcSSimon Schubert (*level_offset_ptr)++; 18445796c8dcSSimon Schubert frame = next; 18455796c8dcSSimon Schubert } 18465796c8dcSSimon Schubert 18475796c8dcSSimon Schubert return frame; 18485796c8dcSSimon Schubert } 18495796c8dcSSimon Schubert 18505796c8dcSSimon Schubert /* The "select_frame" command. With no argument this is a NOP. 18515796c8dcSSimon Schubert Select the frame at level LEVEL_EXP if it is a valid level. 18525796c8dcSSimon Schubert Otherwise, treat LEVEL_EXP as an address expression and select it. 18535796c8dcSSimon Schubert 18545796c8dcSSimon Schubert See parse_frame_specification for more info on proper frame 18555796c8dcSSimon Schubert expressions. */ 18565796c8dcSSimon Schubert 18575796c8dcSSimon Schubert void 18585796c8dcSSimon Schubert select_frame_command (char *level_exp, int from_tty) 18595796c8dcSSimon Schubert { 18605796c8dcSSimon Schubert select_frame (parse_frame_specification_1 (level_exp, "No stack.", NULL)); 18615796c8dcSSimon Schubert } 18625796c8dcSSimon Schubert 18635796c8dcSSimon Schubert /* The "frame" command. With no argument, print the selected frame 18645796c8dcSSimon Schubert briefly. With an argument, behave like select_frame and then print 18655796c8dcSSimon Schubert the selected frame. */ 18665796c8dcSSimon Schubert 18675796c8dcSSimon Schubert static void 18685796c8dcSSimon Schubert frame_command (char *level_exp, int from_tty) 18695796c8dcSSimon Schubert { 18705796c8dcSSimon Schubert select_frame_command (level_exp, from_tty); 18715796c8dcSSimon Schubert print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); 18725796c8dcSSimon Schubert } 18735796c8dcSSimon Schubert 18745796c8dcSSimon Schubert /* The XDB Compatibility command to print the current frame. */ 18755796c8dcSSimon Schubert 18765796c8dcSSimon Schubert static void 18775796c8dcSSimon Schubert current_frame_command (char *level_exp, int from_tty) 18785796c8dcSSimon Schubert { 18795796c8dcSSimon Schubert print_stack_frame (get_selected_frame (_("No stack.")), 1, SRC_AND_LOC); 18805796c8dcSSimon Schubert } 18815796c8dcSSimon Schubert 18825796c8dcSSimon Schubert /* Select the frame up one or COUNT_EXP stack levels from the 18835796c8dcSSimon Schubert previously selected frame, and print it briefly. */ 18845796c8dcSSimon Schubert 18855796c8dcSSimon Schubert static void 18865796c8dcSSimon Schubert up_silently_base (char *count_exp) 18875796c8dcSSimon Schubert { 18885796c8dcSSimon Schubert struct frame_info *frame; 18895796c8dcSSimon Schubert int count = 1; 18905796c8dcSSimon Schubert 18915796c8dcSSimon Schubert if (count_exp) 18925796c8dcSSimon Schubert count = parse_and_eval_long (count_exp); 18935796c8dcSSimon Schubert 18945796c8dcSSimon Schubert frame = find_relative_frame (get_selected_frame ("No stack."), &count); 18955796c8dcSSimon Schubert if (count != 0 && count_exp == NULL) 18965796c8dcSSimon Schubert error (_("Initial frame selected; you cannot go up.")); 18975796c8dcSSimon Schubert select_frame (frame); 18985796c8dcSSimon Schubert } 18995796c8dcSSimon Schubert 19005796c8dcSSimon Schubert static void 19015796c8dcSSimon Schubert up_silently_command (char *count_exp, int from_tty) 19025796c8dcSSimon Schubert { 19035796c8dcSSimon Schubert up_silently_base (count_exp); 19045796c8dcSSimon Schubert } 19055796c8dcSSimon Schubert 19065796c8dcSSimon Schubert static void 19075796c8dcSSimon Schubert up_command (char *count_exp, int from_tty) 19085796c8dcSSimon Schubert { 19095796c8dcSSimon Schubert up_silently_base (count_exp); 19105796c8dcSSimon Schubert print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); 19115796c8dcSSimon Schubert } 19125796c8dcSSimon Schubert 19135796c8dcSSimon Schubert /* Select the frame down one or COUNT_EXP stack levels from the previously 19145796c8dcSSimon Schubert selected frame, and print it briefly. */ 19155796c8dcSSimon Schubert 19165796c8dcSSimon Schubert static void 19175796c8dcSSimon Schubert down_silently_base (char *count_exp) 19185796c8dcSSimon Schubert { 19195796c8dcSSimon Schubert struct frame_info *frame; 19205796c8dcSSimon Schubert int count = -1; 1921*cf7f2e2dSJohn Marino 19225796c8dcSSimon Schubert if (count_exp) 19235796c8dcSSimon Schubert count = -parse_and_eval_long (count_exp); 19245796c8dcSSimon Schubert 19255796c8dcSSimon Schubert frame = find_relative_frame (get_selected_frame ("No stack."), &count); 19265796c8dcSSimon Schubert if (count != 0 && count_exp == NULL) 19275796c8dcSSimon Schubert { 19285796c8dcSSimon Schubert /* We only do this if COUNT_EXP is not specified. That way 19295796c8dcSSimon Schubert "down" means to really go down (and let me know if that is 19305796c8dcSSimon Schubert impossible), but "down 9999" can be used to mean go all the 19315796c8dcSSimon Schubert way down without getting an error. */ 19325796c8dcSSimon Schubert 19335796c8dcSSimon Schubert error (_("Bottom (innermost) frame selected; you cannot go down.")); 19345796c8dcSSimon Schubert } 19355796c8dcSSimon Schubert 19365796c8dcSSimon Schubert select_frame (frame); 19375796c8dcSSimon Schubert } 19385796c8dcSSimon Schubert 19395796c8dcSSimon Schubert static void 19405796c8dcSSimon Schubert down_silently_command (char *count_exp, int from_tty) 19415796c8dcSSimon Schubert { 19425796c8dcSSimon Schubert down_silently_base (count_exp); 19435796c8dcSSimon Schubert } 19445796c8dcSSimon Schubert 19455796c8dcSSimon Schubert static void 19465796c8dcSSimon Schubert down_command (char *count_exp, int from_tty) 19475796c8dcSSimon Schubert { 19485796c8dcSSimon Schubert down_silently_base (count_exp); 19495796c8dcSSimon Schubert print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); 19505796c8dcSSimon Schubert } 19515796c8dcSSimon Schubert 19525796c8dcSSimon Schubert 19535796c8dcSSimon Schubert void 19545796c8dcSSimon Schubert return_command (char *retval_exp, int from_tty) 19555796c8dcSSimon Schubert { 19565796c8dcSSimon Schubert struct frame_info *thisframe; 19575796c8dcSSimon Schubert struct gdbarch *gdbarch; 19585796c8dcSSimon Schubert struct symbol *thisfun; 19595796c8dcSSimon Schubert struct value *return_value = NULL; 19605796c8dcSSimon Schubert const char *query_prefix = ""; 19615796c8dcSSimon Schubert 19625796c8dcSSimon Schubert thisframe = get_selected_frame ("No selected frame."); 19635796c8dcSSimon Schubert thisfun = get_frame_function (thisframe); 19645796c8dcSSimon Schubert gdbarch = get_frame_arch (thisframe); 19655796c8dcSSimon Schubert 19665796c8dcSSimon Schubert if (get_frame_type (get_current_frame ()) == INLINE_FRAME) 19675796c8dcSSimon Schubert error (_("Can not force return from an inlined function.")); 19685796c8dcSSimon Schubert 19695796c8dcSSimon Schubert /* Compute the return value. If the computation triggers an error, 19705796c8dcSSimon Schubert let it bail. If the return type can't be handled, set 19715796c8dcSSimon Schubert RETURN_VALUE to NULL, and QUERY_PREFIX to an informational 19725796c8dcSSimon Schubert message. */ 19735796c8dcSSimon Schubert if (retval_exp) 19745796c8dcSSimon Schubert { 19755796c8dcSSimon Schubert struct expression *retval_expr = parse_expression (retval_exp); 19765796c8dcSSimon Schubert struct cleanup *old_chain = make_cleanup (xfree, retval_expr); 19775796c8dcSSimon Schubert struct type *return_type = NULL; 19785796c8dcSSimon Schubert 19795796c8dcSSimon Schubert /* Compute the return value. Should the computation fail, this 19805796c8dcSSimon Schubert call throws an error. */ 19815796c8dcSSimon Schubert return_value = evaluate_expression (retval_expr); 19825796c8dcSSimon Schubert 19835796c8dcSSimon Schubert /* Cast return value to the return type of the function. Should 19845796c8dcSSimon Schubert the cast fail, this call throws an error. */ 19855796c8dcSSimon Schubert if (thisfun != NULL) 19865796c8dcSSimon Schubert return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun)); 19875796c8dcSSimon Schubert if (return_type == NULL) 19885796c8dcSSimon Schubert { 19895796c8dcSSimon Schubert if (retval_expr->elts[0].opcode != UNOP_CAST) 19905796c8dcSSimon Schubert error (_("Return value type not available for selected " 19915796c8dcSSimon Schubert "stack frame.\n" 19925796c8dcSSimon Schubert "Please use an explicit cast of the value to return.")); 19935796c8dcSSimon Schubert return_type = value_type (return_value); 19945796c8dcSSimon Schubert } 19955796c8dcSSimon Schubert do_cleanups (old_chain); 19965796c8dcSSimon Schubert CHECK_TYPEDEF (return_type); 19975796c8dcSSimon Schubert return_value = value_cast (return_type, return_value); 19985796c8dcSSimon Schubert 19995796c8dcSSimon Schubert /* Make sure the value is fully evaluated. It may live in the 20005796c8dcSSimon Schubert stack frame we're about to pop. */ 20015796c8dcSSimon Schubert if (value_lazy (return_value)) 20025796c8dcSSimon Schubert value_fetch_lazy (return_value); 20035796c8dcSSimon Schubert 20045796c8dcSSimon Schubert if (TYPE_CODE (return_type) == TYPE_CODE_VOID) 20055796c8dcSSimon Schubert /* If the return-type is "void", don't try to find the 20065796c8dcSSimon Schubert return-value's location. However, do still evaluate the 20075796c8dcSSimon Schubert return expression so that, even when the expression result 20085796c8dcSSimon Schubert is discarded, side effects such as "return i++" still 20095796c8dcSSimon Schubert occur. */ 20105796c8dcSSimon Schubert return_value = NULL; 20115796c8dcSSimon Schubert else if (thisfun != NULL 20125796c8dcSSimon Schubert && using_struct_return (gdbarch, 20135796c8dcSSimon Schubert SYMBOL_TYPE (thisfun), return_type)) 20145796c8dcSSimon Schubert { 20155796c8dcSSimon Schubert query_prefix = "\ 20165796c8dcSSimon Schubert The location at which to store the function's return value is unknown.\n\ 20175796c8dcSSimon Schubert If you continue, the return value that you specified will be ignored.\n"; 20185796c8dcSSimon Schubert return_value = NULL; 20195796c8dcSSimon Schubert } 20205796c8dcSSimon Schubert } 20215796c8dcSSimon Schubert 20225796c8dcSSimon Schubert /* Does an interactive user really want to do this? Include 20235796c8dcSSimon Schubert information, such as how well GDB can handle the return value, in 20245796c8dcSSimon Schubert the query message. */ 20255796c8dcSSimon Schubert if (from_tty) 20265796c8dcSSimon Schubert { 20275796c8dcSSimon Schubert int confirmed; 2028*cf7f2e2dSJohn Marino 20295796c8dcSSimon Schubert if (thisfun == NULL) 20305796c8dcSSimon Schubert confirmed = query (_("%sMake selected stack frame return now? "), 20315796c8dcSSimon Schubert query_prefix); 20325796c8dcSSimon Schubert else 20335796c8dcSSimon Schubert confirmed = query (_("%sMake %s return now? "), query_prefix, 20345796c8dcSSimon Schubert SYMBOL_PRINT_NAME (thisfun)); 20355796c8dcSSimon Schubert if (!confirmed) 20365796c8dcSSimon Schubert error (_("Not confirmed")); 20375796c8dcSSimon Schubert } 20385796c8dcSSimon Schubert 20395796c8dcSSimon Schubert /* Discard the selected frame and all frames inner-to it. */ 20405796c8dcSSimon Schubert frame_pop (get_selected_frame (NULL)); 20415796c8dcSSimon Schubert 20425796c8dcSSimon Schubert /* Store RETURN_VALUE in the just-returned register set. */ 20435796c8dcSSimon Schubert if (return_value != NULL) 20445796c8dcSSimon Schubert { 20455796c8dcSSimon Schubert struct type *return_type = value_type (return_value); 20465796c8dcSSimon Schubert struct gdbarch *gdbarch = get_regcache_arch (get_current_regcache ()); 20475796c8dcSSimon Schubert struct type *func_type = thisfun == NULL ? NULL : SYMBOL_TYPE (thisfun); 20485796c8dcSSimon Schubert 20495796c8dcSSimon Schubert gdb_assert (gdbarch_return_value (gdbarch, func_type, return_type, NULL, 20505796c8dcSSimon Schubert NULL, NULL) 20515796c8dcSSimon Schubert == RETURN_VALUE_REGISTER_CONVENTION); 20525796c8dcSSimon Schubert gdbarch_return_value (gdbarch, func_type, return_type, 20535796c8dcSSimon Schubert get_current_regcache (), NULL /*read*/, 20545796c8dcSSimon Schubert value_contents (return_value) /*write*/); 20555796c8dcSSimon Schubert } 20565796c8dcSSimon Schubert 20575796c8dcSSimon Schubert /* If we are at the end of a call dummy now, pop the dummy frame 20585796c8dcSSimon Schubert too. */ 20595796c8dcSSimon Schubert if (get_frame_type (get_current_frame ()) == DUMMY_FRAME) 20605796c8dcSSimon Schubert frame_pop (get_current_frame ()); 20615796c8dcSSimon Schubert 20625796c8dcSSimon Schubert /* If interactive, print the frame that is now current. */ 20635796c8dcSSimon Schubert if (from_tty) 20645796c8dcSSimon Schubert frame_command ("0", 1); 20655796c8dcSSimon Schubert else 20665796c8dcSSimon Schubert select_frame_command ("0", 0); 20675796c8dcSSimon Schubert } 20685796c8dcSSimon Schubert 20695796c8dcSSimon Schubert /* Sets the scope to input function name, provided that the function 20705796c8dcSSimon Schubert is within the current stack frame */ 20715796c8dcSSimon Schubert 20725796c8dcSSimon Schubert struct function_bounds 20735796c8dcSSimon Schubert { 20745796c8dcSSimon Schubert CORE_ADDR low, high; 20755796c8dcSSimon Schubert }; 20765796c8dcSSimon Schubert 20775796c8dcSSimon Schubert static void 20785796c8dcSSimon Schubert func_command (char *arg, int from_tty) 20795796c8dcSSimon Schubert { 20805796c8dcSSimon Schubert struct frame_info *frame; 20815796c8dcSSimon Schubert int found = 0; 20825796c8dcSSimon Schubert struct symtabs_and_lines sals; 20835796c8dcSSimon Schubert int i; 20845796c8dcSSimon Schubert int level = 1; 20855796c8dcSSimon Schubert struct function_bounds *func_bounds = NULL; 20865796c8dcSSimon Schubert 20875796c8dcSSimon Schubert if (arg != NULL) 20885796c8dcSSimon Schubert return; 20895796c8dcSSimon Schubert 20905796c8dcSSimon Schubert frame = parse_frame_specification ("0"); 20915796c8dcSSimon Schubert sals = decode_line_spec (arg, 1); 20925796c8dcSSimon Schubert func_bounds = (struct function_bounds *) xmalloc ( 20935796c8dcSSimon Schubert sizeof (struct function_bounds) * sals.nelts); 20945796c8dcSSimon Schubert for (i = 0; (i < sals.nelts && !found); i++) 20955796c8dcSSimon Schubert { 20965796c8dcSSimon Schubert if (sals.sals[i].pc == 0 20975796c8dcSSimon Schubert || find_pc_partial_function (sals.sals[i].pc, NULL, 20985796c8dcSSimon Schubert &func_bounds[i].low, 20995796c8dcSSimon Schubert &func_bounds[i].high) == 0) 21005796c8dcSSimon Schubert { 21015796c8dcSSimon Schubert func_bounds[i].low = func_bounds[i].high = 0; 21025796c8dcSSimon Schubert } 21035796c8dcSSimon Schubert } 21045796c8dcSSimon Schubert 21055796c8dcSSimon Schubert do 21065796c8dcSSimon Schubert { 21075796c8dcSSimon Schubert for (i = 0; (i < sals.nelts && !found); i++) 21085796c8dcSSimon Schubert found = (get_frame_pc (frame) >= func_bounds[i].low 21095796c8dcSSimon Schubert && get_frame_pc (frame) < func_bounds[i].high); 21105796c8dcSSimon Schubert if (!found) 21115796c8dcSSimon Schubert { 21125796c8dcSSimon Schubert level = 1; 21135796c8dcSSimon Schubert frame = find_relative_frame (frame, &level); 21145796c8dcSSimon Schubert } 21155796c8dcSSimon Schubert } 21165796c8dcSSimon Schubert while (!found && level == 0); 21175796c8dcSSimon Schubert 21185796c8dcSSimon Schubert if (func_bounds) 21195796c8dcSSimon Schubert xfree (func_bounds); 21205796c8dcSSimon Schubert 21215796c8dcSSimon Schubert if (!found) 21225796c8dcSSimon Schubert printf_filtered (_("'%s' not within current stack frame.\n"), arg); 21235796c8dcSSimon Schubert else if (frame != get_selected_frame (NULL)) 21245796c8dcSSimon Schubert select_and_print_frame (frame); 21255796c8dcSSimon Schubert } 21265796c8dcSSimon Schubert 21275796c8dcSSimon Schubert /* Gets the language of the current frame. */ 21285796c8dcSSimon Schubert 21295796c8dcSSimon Schubert enum language 21305796c8dcSSimon Schubert get_frame_language (void) 21315796c8dcSSimon Schubert { 21325796c8dcSSimon Schubert struct frame_info *frame = deprecated_safe_get_selected_frame (); 21335796c8dcSSimon Schubert 21345796c8dcSSimon Schubert if (frame) 21355796c8dcSSimon Schubert { 21365796c8dcSSimon Schubert /* We determine the current frame language by looking up its 21375796c8dcSSimon Schubert associated symtab. To retrieve this symtab, we use the frame 21385796c8dcSSimon Schubert PC. However we cannot use the frame PC as is, because it 21395796c8dcSSimon Schubert usually points to the instruction following the "call", which 21405796c8dcSSimon Schubert is sometimes the first instruction of another function. So 21415796c8dcSSimon Schubert we rely on get_frame_address_in_block(), it provides us with 21425796c8dcSSimon Schubert a PC that is guaranteed to be inside the frame's code 21435796c8dcSSimon Schubert block. */ 21445796c8dcSSimon Schubert CORE_ADDR pc = get_frame_address_in_block (frame); 21455796c8dcSSimon Schubert struct symtab *s = find_pc_symtab (pc); 21465796c8dcSSimon Schubert 21475796c8dcSSimon Schubert if (s) 21485796c8dcSSimon Schubert return s->language; 21495796c8dcSSimon Schubert } 21505796c8dcSSimon Schubert 21515796c8dcSSimon Schubert return language_unknown; 21525796c8dcSSimon Schubert } 21535796c8dcSSimon Schubert 21545796c8dcSSimon Schubert 21555796c8dcSSimon Schubert /* Provide a prototype to silence -Wmissing-prototypes. */ 21565796c8dcSSimon Schubert void _initialize_stack (void); 21575796c8dcSSimon Schubert 21585796c8dcSSimon Schubert void 21595796c8dcSSimon Schubert _initialize_stack (void) 21605796c8dcSSimon Schubert { 21615796c8dcSSimon Schubert add_com ("return", class_stack, return_command, _("\ 21625796c8dcSSimon Schubert Make selected stack frame return to its caller.\n\ 21635796c8dcSSimon Schubert Control remains in the debugger, but when you continue\n\ 21645796c8dcSSimon Schubert execution will resume in the frame above the one now selected.\n\ 21655796c8dcSSimon Schubert If an argument is given, it is an expression for the value to return.")); 21665796c8dcSSimon Schubert 21675796c8dcSSimon Schubert add_com ("up", class_stack, up_command, _("\ 21685796c8dcSSimon Schubert Select and print stack frame that called this one.\n\ 21695796c8dcSSimon Schubert An argument says how many frames up to go.")); 21705796c8dcSSimon Schubert add_com ("up-silently", class_support, up_silently_command, _("\ 21715796c8dcSSimon Schubert Same as the `up' command, but does not print anything.\n\ 21725796c8dcSSimon Schubert This is useful in command scripts.")); 21735796c8dcSSimon Schubert 21745796c8dcSSimon Schubert add_com ("down", class_stack, down_command, _("\ 21755796c8dcSSimon Schubert Select and print stack frame called by this one.\n\ 21765796c8dcSSimon Schubert An argument says how many frames down to go.")); 21775796c8dcSSimon Schubert add_com_alias ("do", "down", class_stack, 1); 21785796c8dcSSimon Schubert add_com_alias ("dow", "down", class_stack, 1); 21795796c8dcSSimon Schubert add_com ("down-silently", class_support, down_silently_command, _("\ 21805796c8dcSSimon Schubert Same as the `down' command, but does not print anything.\n\ 21815796c8dcSSimon Schubert This is useful in command scripts.")); 21825796c8dcSSimon Schubert 21835796c8dcSSimon Schubert add_com ("frame", class_stack, frame_command, _("\ 21845796c8dcSSimon Schubert Select and print a stack frame.\n\ 21855796c8dcSSimon Schubert With no argument, print the selected stack frame. (See also \"info frame\").\n\ 21865796c8dcSSimon Schubert An argument specifies the frame to select.\n\ 21875796c8dcSSimon Schubert It can be a stack frame number or the address of the frame.\n\ 21885796c8dcSSimon Schubert With argument, nothing is printed if input is coming from\n\ 21895796c8dcSSimon Schubert a command file or a user-defined command.")); 21905796c8dcSSimon Schubert 21915796c8dcSSimon Schubert add_com_alias ("f", "frame", class_stack, 1); 21925796c8dcSSimon Schubert 21935796c8dcSSimon Schubert if (xdb_commands) 21945796c8dcSSimon Schubert { 21955796c8dcSSimon Schubert add_com ("L", class_stack, current_frame_command, 21965796c8dcSSimon Schubert _("Print the current stack frame.\n")); 21975796c8dcSSimon Schubert add_com_alias ("V", "frame", class_stack, 1); 21985796c8dcSSimon Schubert } 21995796c8dcSSimon Schubert add_com ("select-frame", class_stack, select_frame_command, _("\ 22005796c8dcSSimon Schubert Select a stack frame without printing anything.\n\ 22015796c8dcSSimon Schubert An argument specifies the frame to select.\n\ 22025796c8dcSSimon Schubert It can be a stack frame number or the address of the frame.\n")); 22035796c8dcSSimon Schubert 22045796c8dcSSimon Schubert add_com ("backtrace", class_stack, backtrace_command, _("\ 22055796c8dcSSimon Schubert Print backtrace of all stack frames, or innermost COUNT frames.\n\ 22065796c8dcSSimon Schubert With a negative argument, print outermost -COUNT frames.\n\ 22075796c8dcSSimon Schubert Use of the 'full' qualifier also prints the values of the local variables.\n")); 22085796c8dcSSimon Schubert add_com_alias ("bt", "backtrace", class_stack, 0); 22095796c8dcSSimon Schubert if (xdb_commands) 22105796c8dcSSimon Schubert { 22115796c8dcSSimon Schubert add_com_alias ("t", "backtrace", class_stack, 0); 22125796c8dcSSimon Schubert add_com ("T", class_stack, backtrace_full_command, _("\ 22135796c8dcSSimon Schubert Print backtrace of all stack frames, or innermost COUNT frames\n\ 22145796c8dcSSimon Schubert and the values of the local variables.\n\ 22155796c8dcSSimon Schubert With a negative argument, print outermost -COUNT frames.\n\ 22165796c8dcSSimon Schubert Usage: T <count>\n")); 22175796c8dcSSimon Schubert } 22185796c8dcSSimon Schubert 22195796c8dcSSimon Schubert add_com_alias ("where", "backtrace", class_alias, 0); 22205796c8dcSSimon Schubert add_info ("stack", backtrace_command, 22215796c8dcSSimon Schubert _("Backtrace of the stack, or innermost COUNT frames.")); 22225796c8dcSSimon Schubert add_info_alias ("s", "stack", 1); 22235796c8dcSSimon Schubert add_info ("frame", frame_info, 22245796c8dcSSimon Schubert _("All about selected stack frame, or frame at ADDR.")); 22255796c8dcSSimon Schubert add_info_alias ("f", "frame", 1); 22265796c8dcSSimon Schubert add_info ("locals", locals_info, 22275796c8dcSSimon Schubert _("Local variables of current stack frame.")); 22285796c8dcSSimon Schubert add_info ("args", args_info, 22295796c8dcSSimon Schubert _("Argument variables of current stack frame.")); 22305796c8dcSSimon Schubert if (xdb_commands) 22315796c8dcSSimon Schubert add_com ("l", class_info, args_plus_locals_info, 22325796c8dcSSimon Schubert _("Argument and local variables of current stack frame.")); 22335796c8dcSSimon Schubert 22345796c8dcSSimon Schubert if (dbx_commands) 22355796c8dcSSimon Schubert add_com ("func", class_stack, func_command, _("\ 22365796c8dcSSimon Schubert Select the stack frame that contains <func>.\n\ 22375796c8dcSSimon Schubert Usage: func <name>\n")); 22385796c8dcSSimon Schubert 22395796c8dcSSimon Schubert add_info ("catch", catch_info, 22405796c8dcSSimon Schubert _("Exceptions that can be caught in the current stack frame.")); 22415796c8dcSSimon Schubert 22425796c8dcSSimon Schubert add_setshow_enum_cmd ("frame-arguments", class_stack, 22435796c8dcSSimon Schubert print_frame_arguments_choices, &print_frame_arguments, 22445796c8dcSSimon Schubert _("Set printing of non-scalar frame arguments"), 22455796c8dcSSimon Schubert _("Show printing of non-scalar frame arguments"), 22465796c8dcSSimon Schubert NULL, NULL, NULL, &setprintlist, &showprintlist); 22475796c8dcSSimon Schubert 22485796c8dcSSimon Schubert add_setshow_auto_boolean_cmd ("disassemble-next-line", class_stack, 22495796c8dcSSimon Schubert &disassemble_next_line, _("\ 22505796c8dcSSimon Schubert Set whether to disassemble next source line or insn when execution stops."), _("\ 22515796c8dcSSimon Schubert Show whether to disassemble next source line or insn when execution stops."), _("\ 22525796c8dcSSimon Schubert If ON, GDB will display disassembly of the next source line, in addition\n\ 22535796c8dcSSimon Schubert to displaying the source line itself. If the next source line cannot\n\ 22545796c8dcSSimon Schubert be displayed (e.g., source is unavailable or there's no line info), GDB\n\ 22555796c8dcSSimon Schubert will display disassembly of next instruction instead of showing the\n\ 22565796c8dcSSimon Schubert source line.\n\ 22575796c8dcSSimon Schubert If AUTO, display disassembly of next instruction only if the source line\n\ 22585796c8dcSSimon Schubert cannot be displayed.\n\ 22595796c8dcSSimon Schubert If OFF (which is the default), never display the disassembly of the next\n\ 22605796c8dcSSimon Schubert source line."), 22615796c8dcSSimon Schubert NULL, 22625796c8dcSSimon Schubert show_disassemble_next_line, 22635796c8dcSSimon Schubert &setlist, &showlist); 22645796c8dcSSimon Schubert disassemble_next_line = AUTO_BOOLEAN_FALSE; 22655796c8dcSSimon Schubert } 2266