]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/gdb/gdb/stack.c
Import GDB in its full glory (all 25mb). We'll put it on a diet once it's
[FreeBSD/FreeBSD.git] / contrib / gdb / gdb / stack.c
1 /* Print and select stack frames for GDB, the GNU debugger.
2    Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996
3    Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21
22 #include "defs.h"
23 #include "gdb_string.h"
24 #include "value.h"
25 #include "symtab.h"
26 #include "gdbtypes.h"
27 #include "expression.h"
28 #include "language.h"
29 #include "frame.h"
30 #include "gdbcmd.h"
31 #include "gdbcore.h"
32 #include "target.h"
33 #include "breakpoint.h"
34 #include "demangle.h"
35 #include "inferior.h"
36 #include "annotate.h"
37 #include "symfile.h"
38 #include "objfiles.h"
39
40 static void return_command PARAMS ((char *, int));
41
42 static void down_command PARAMS ((char *, int));
43
44 static void down_silently_command PARAMS ((char *, int));
45
46 static void up_command PARAMS ((char *, int));
47
48 static void up_silently_command PARAMS ((char *, int));
49
50 static void frame_command PARAMS ((char *, int));
51
52 static void select_frame_command PARAMS ((char *, int));
53
54 static void args_info PARAMS ((char *, int));
55
56 static void print_frame_arg_vars PARAMS ((struct frame_info *, GDB_FILE *));
57
58 static void catch_info PARAMS ((char *, int));
59
60 static void locals_info PARAMS ((char *, int));
61
62 static void print_frame_label_vars PARAMS ((struct frame_info *, int,
63                                             GDB_FILE *));
64
65 static void print_frame_local_vars PARAMS ((struct frame_info *, GDB_FILE *));
66
67 static int print_block_frame_labels PARAMS ((struct block *, int *,
68                                              GDB_FILE *));
69
70 static int print_block_frame_locals PARAMS ((struct block *,
71                                              struct frame_info *,
72                                              GDB_FILE *));
73
74 static void backtrace_command PARAMS ((char *, int));
75
76 static struct frame_info *parse_frame_specification PARAMS ((char *));
77
78 static void frame_info PARAMS ((char *, int));
79
80 extern int addressprint;        /* Print addresses, or stay symbolic only? */
81 extern int info_verbose;        /* Verbosity of symbol reading msgs */
82 extern int lines_to_list;       /* # of lines "list" command shows by default */
83
84 /* The "selected" stack frame is used by default for local and arg access.
85    May be zero, for no selected frame.  */
86
87 struct frame_info *selected_frame;
88
89 /* Level of the selected frame:
90    0 for innermost, 1 for its caller, ...
91    or -1 for frame specified by address with no defined level.  */
92
93 int selected_frame_level;
94
95 /* Zero means do things normally; we are interacting directly with the
96    user.  One means print the full filename and linenumber when a
97    frame is printed, and do so in a format emacs18/emacs19.22 can
98    parse.  Two means print similar annotations, but in many more
99    cases and in a slightly different syntax.  */
100
101 int annotation_level = 0;
102
103 \f
104 struct print_stack_frame_args {
105   struct frame_info *fi;
106   int level;
107   int source;
108   int args;
109 };
110
111 static int print_stack_frame_stub PARAMS ((char *));
112
113 /* Pass the args the way catch_errors wants them.  */
114 static int
115 print_stack_frame_stub (args)
116      char *args;
117 {
118   struct print_stack_frame_args *p = (struct print_stack_frame_args *)args;
119
120   print_frame_info (p->fi, p->level, p->source, p->args);
121   return 0;
122 }
123
124 /* Print a stack frame briefly.  FRAME_INFI should be the frame info
125    and LEVEL should be its level in the stack (or -1 for level not defined).
126    This prints the level, the function executing, the arguments,
127    and the file name and line number.
128    If the pc is not at the beginning of the source line,
129    the actual pc is printed at the beginning.
130
131    If SOURCE is 1, print the source line as well.
132    If SOURCE is -1, print ONLY the source line.  */
133
134 void
135 print_stack_frame (fi, level, source)
136      struct frame_info *fi;
137      int level;
138      int source;
139 {
140   struct print_stack_frame_args args;
141
142   args.fi = fi;
143   args.level = level;
144   args.source = source;
145   args.args = 1;
146
147   catch_errors (print_stack_frame_stub, (char *)&args, "", RETURN_MASK_ALL);
148 }
149
150 struct print_args_args {
151   struct symbol *func;
152   struct frame_info *fi;
153 };
154
155 static int print_args_stub PARAMS ((char *));
156
157 /* Pass the args the way catch_errors wants them.  */
158
159 static int
160 print_args_stub (args)
161      char *args;
162 {
163   int numargs;
164   struct print_args_args *p = (struct print_args_args *)args;
165
166   FRAME_NUM_ARGS (numargs, (p->fi));
167   print_frame_args (p->func, p->fi, numargs, gdb_stdout);
168   return 0;
169 }
170
171 /* LEVEL is the level of the frame, or -1 if it is the innermost frame
172    but we don't want to print the level.  */
173
174 void
175 print_frame_info (fi, level, source, args)
176      struct frame_info *fi;
177      register int level;
178      int source;
179      int args;
180 {
181   struct symtab_and_line sal;
182   struct symbol *func;
183   register char *funname = 0;
184   enum language funlang = language_unknown;
185
186 #if 0
187   char buf[MAX_REGISTER_RAW_SIZE];
188   CORE_ADDR sp;
189
190   /* On the 68k, this spends too much time in m68k_find_saved_regs.  */
191
192   /* Get the value of SP_REGNUM relative to the frame.  */
193   get_saved_register (buf, (int *)NULL, (CORE_ADDR *)NULL,
194                       FRAME_INFO_ID (fi), SP_REGNUM, (enum lval_type *)NULL);
195   sp = extract_address (buf, REGISTER_RAW_SIZE (SP_REGNUM));
196
197   /* This is not a perfect test, because if a function alloca's some
198      memory, puts some code there, and then jumps into it, then the test
199      will succeed even though there is no call dummy.  Probably best is
200      to check for a bp_call_dummy breakpoint.  */
201   if (PC_IN_CALL_DUMMY (fi->pc, sp, fi->frame))
202 #else
203   if (frame_in_dummy (fi))
204 #endif
205     {
206       annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
207
208       /* Do this regardless of SOURCE because we don't have any source
209          to list for this frame.  */
210       if (level >= 0)
211         printf_filtered ("#%-2d ", level);
212       annotate_function_call ();
213       printf_filtered ("<function called from gdb>\n");
214       annotate_frame_end ();
215       return;
216     }
217   if (fi->signal_handler_caller)
218     {
219       annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
220
221       /* Do this regardless of SOURCE because we don't have any source
222          to list for this frame.  */
223       if (level >= 0)
224         printf_filtered ("#%-2d ", level);
225       annotate_signal_handler_caller ();
226       printf_filtered ("<signal handler called>\n");
227       annotate_frame_end ();
228       return;
229     }
230
231   /* If fi is not the innermost frame, that normally means that fi->pc
232      points to *after* the call instruction, and we want to get the line
233      containing the call, never the next line.  But if the next frame is
234      a signal_handler_caller or a dummy frame, then the next frame was
235      not entered as the result of a call, and we want to get the line
236      containing fi->pc.  */
237   sal =
238     find_pc_line (fi->pc,
239                   fi->next != NULL
240                   && !fi->next->signal_handler_caller
241                   && !frame_in_dummy (fi->next));
242
243   func = find_pc_function (fi->pc);
244   if (func)
245     {
246       /* In certain pathological cases, the symtabs give the wrong
247          function (when we are in the first function in a file which
248          is compiled without debugging symbols, the previous function
249          is compiled with debugging symbols, and the "foo.o" symbol
250          that is supposed to tell us where the file with debugging symbols
251          ends has been truncated by ar because it is longer than 15
252          characters).  This also occurs if the user uses asm() to create
253          a function but not stabs for it (in a file compiled -g).
254
255          So look in the minimal symbol tables as well, and if it comes
256          up with a larger address for the function use that instead.
257          I don't think this can ever cause any problems; there shouldn't
258          be any minimal symbols in the middle of a function; if this is
259          ever changed many parts of GDB will need to be changed (and we'll
260          create a find_pc_minimal_function or some such).  */
261
262       struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
263       if (msymbol != NULL
264           && (SYMBOL_VALUE_ADDRESS (msymbol) 
265               > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
266         {
267 #if 0
268           /* There is no particular reason to think the line number
269              information is wrong.  Someone might have just put in
270              a label with asm() but left the line numbers alone.  */
271           /* In this case we have no way of knowing the source file
272              and line number, so don't print them.  */
273           sal.symtab = 0;
274 #endif
275           /* We also don't know anything about the function besides
276              its address and name.  */
277           func = 0;
278           funname = SYMBOL_NAME (msymbol);
279           funlang = SYMBOL_LANGUAGE (msymbol);
280         }
281       else
282         {
283           funname = SYMBOL_NAME (func);
284           funlang = SYMBOL_LANGUAGE (func);
285         }
286     }
287   else
288     {
289       if (find_pc_section (fi->pc))
290         {
291           struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
292           if (msymbol != NULL)
293             {
294               funname = SYMBOL_NAME (msymbol);
295               funlang = SYMBOL_LANGUAGE (msymbol);
296             }
297         }
298     }
299
300   if (source >= 0 || !sal.symtab)
301     {
302       annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
303
304       if (level >= 0)
305         printf_filtered ("#%-2d ", level);
306       if (addressprint)
307         if (fi->pc != sal.pc || !sal.symtab)
308           {
309             annotate_frame_address ();
310             print_address_numeric (fi->pc, 1, gdb_stdout);
311             annotate_frame_address_end ();
312             printf_filtered (" in ");
313           }
314       annotate_frame_function_name ();
315       fprintf_symbol_filtered (gdb_stdout, funname ? funname : "??", funlang,
316                                DMGL_ANSI);
317       wrap_here ("   ");
318       annotate_frame_args ();
319       fputs_filtered (" (", gdb_stdout);
320       if (args)
321         {
322           struct print_args_args args;
323           args.fi = fi;
324           args.func = func;
325           catch_errors (print_args_stub, (char *)&args, "", RETURN_MASK_ALL);
326           QUIT;
327         }
328       printf_filtered (")");
329       if (sal.symtab && sal.symtab->filename)
330         {
331           annotate_frame_source_begin ();
332           wrap_here ("   ");
333           printf_filtered (" at ");
334           annotate_frame_source_file ();
335           printf_filtered ("%s", sal.symtab->filename);
336           annotate_frame_source_file_end ();
337           printf_filtered (":");
338           annotate_frame_source_line ();
339           printf_filtered ("%d", sal.line);
340           annotate_frame_source_end ();
341         }
342
343 #ifdef PC_LOAD_SEGMENT
344      /* If we couldn't print out function name but if can figure out what
345         load segment this pc value is from, at least print out some info
346         about its load segment. */
347       if (!funname)
348         {
349           annotate_frame_where ();
350           wrap_here ("  ");
351           printf_filtered (" from %s", PC_LOAD_SEGMENT (fi->pc));
352         }
353 #endif
354 #ifdef PC_SOLIB
355       if (!funname)
356         {
357           char *lib = PC_SOLIB (fi->pc);
358           if (lib)
359             {
360               annotate_frame_where ();
361               wrap_here ("  ");
362               printf_filtered (" from %s", lib);
363             }
364         }
365 #endif
366       printf_filtered ("\n");
367     }
368
369   if ((source != 0) && sal.symtab)
370     {
371       int done = 0;
372       int mid_statement = source < 0 && fi->pc != sal.pc;
373       if (annotation_level)
374         done = identify_source_line (sal.symtab, sal.line, mid_statement,
375                                      fi->pc);
376       if (!done)
377         {
378           if (addressprint && mid_statement)
379             {
380               print_address_numeric (fi->pc, 1, gdb_stdout);
381               printf_filtered ("\t");
382             }
383           if (print_frame_info_listing_hook)
384             print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0);
385           else
386             print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
387         }
388       current_source_line = max (sal.line - lines_to_list/2, 1);
389     }
390   if (source != 0)
391     set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
392
393   annotate_frame_end ();
394
395   gdb_flush (gdb_stdout);
396 }
397
398 /* Read a frame specification in whatever the appropriate format is.
399    Call error() if the specification is in any way invalid (i.e.
400    this function never returns NULL).  */
401
402 static struct frame_info *
403 parse_frame_specification (frame_exp)
404      char *frame_exp;
405 {
406   int numargs = 0;
407 #define MAXARGS 4
408   CORE_ADDR args[MAXARGS];
409   
410   if (frame_exp)
411     {
412       char *addr_string, *p;
413       struct cleanup *tmp_cleanup;
414
415       while (*frame_exp == ' ') frame_exp++;
416
417       while (*frame_exp)
418         {
419           if (numargs > MAXARGS)
420             error ("Too many args in frame specification");
421           /* Parse an argument.  */
422           for (p = frame_exp; *p && *p != ' '; p++)
423             ;
424           addr_string = savestring(frame_exp, p - frame_exp);
425
426           {
427             tmp_cleanup = make_cleanup (free, addr_string);
428             args[numargs++] = parse_and_eval_address (addr_string);
429             do_cleanups (tmp_cleanup);
430           }
431
432           /* Skip spaces, move to possible next arg.  */
433           while (*p == ' ') p++;
434           frame_exp = p;
435         }
436     }
437
438   switch (numargs)
439     {
440     case 0:
441       if (selected_frame == NULL)
442         error ("No selected frame.");
443       return selected_frame;
444       /* NOTREACHED */
445     case 1:
446       {
447         int level = args[0];
448         struct frame_info *fid =
449           find_relative_frame (get_current_frame (), &level);
450         struct frame_info *tfid;
451
452         if (level == 0)
453           /* find_relative_frame was successful */
454           return fid;
455
456         /* If SETUP_ARBITRARY_FRAME is defined, then frame specifications
457            take at least 2 addresses.  It is important to detect this case
458            here so that "frame 100" does not give a confusing error message
459            like "frame specification requires two addresses".  This of course
460            does not solve the "frame 100" problem for machines on which
461            a frame specification can be made with one address.  To solve
462            that, we need a new syntax for a specifying a frame by address.
463            I think the cleanest syntax is $frame(0x45) ($frame(0x23,0x45) for
464            two args, etc.), but people might think that is too much typing,
465            so I guess *0x23,0x45 would be a possible alternative (commas
466            really should be used instead of spaces to delimit; using spaces
467            normally works in an expression).  */
468 #ifdef SETUP_ARBITRARY_FRAME
469         error ("No frame %d", args[0]);
470 #endif
471
472         /* If (s)he specifies the frame with an address, he deserves what
473            (s)he gets.  Still, give the highest one that matches.  */
474
475         for (fid = get_current_frame ();
476              fid && fid->frame != args[0];
477              fid = get_prev_frame (fid))
478           ;
479
480         if (fid)
481           while ((tfid = get_prev_frame (fid)) &&
482                  (tfid->frame == args[0]))
483             fid = tfid;
484           
485         /* We couldn't identify the frame as an existing frame, but
486            perhaps we can create one with a single argument.  */
487       }
488
489      default:
490 #ifdef SETUP_ARBITRARY_FRAME
491       return SETUP_ARBITRARY_FRAME (numargs, args);
492 #else
493       /* Usual case.  Do it here rather than have everyone supply
494          a SETUP_ARBITRARY_FRAME that does this.  */
495       if (numargs == 1)
496         return create_new_frame (args[0], 0);
497       error ("Too many args in frame specification");
498 #endif
499       /* NOTREACHED */
500     }
501   /* NOTREACHED */
502 }
503
504 /* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
505    that if it is unsure about the answer, it returns 0
506    instead of guessing (this happens on the VAX and i960, for example).
507
508    On most machines, we never have to guess about the args address,
509    so FRAME_ARGS_ADDRESS{,_CORRECT} are the same.  */
510 #if !defined (FRAME_ARGS_ADDRESS_CORRECT)
511 #define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
512 #endif
513
514 /* Print verbosely the selected frame or the frame at address ADDR.
515    This means absolutely all information in the frame is printed.  */
516
517 static void
518 frame_info (addr_exp, from_tty)
519      char *addr_exp;
520      int from_tty;
521 {
522   struct frame_info *fi;
523   struct frame_saved_regs fsr;
524   struct symtab_and_line sal;
525   struct symbol *func;
526   struct symtab *s;
527   struct frame_info *calling_frame_info;
528   int i, count, numregs;
529   char *funname = 0;
530   enum language funlang = language_unknown;
531
532   if (!target_has_stack)
533     error ("No stack.");
534
535   fi = parse_frame_specification (addr_exp);
536   if (fi == NULL)
537     error ("Invalid frame specified.");
538
539   sal = find_pc_line (fi->pc,
540                       fi->next != NULL
541                       && !fi->next->signal_handler_caller
542                       && !frame_in_dummy (fi->next));
543   func = get_frame_function (fi);
544   s = find_pc_symtab(fi->pc);
545   if (func)
546     {
547       funname = SYMBOL_NAME (func);
548       funlang = SYMBOL_LANGUAGE (func);
549     }
550   else
551     {
552       register struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
553       if (msymbol != NULL)
554         {
555           funname = SYMBOL_NAME (msymbol);
556           funlang = SYMBOL_LANGUAGE (msymbol);
557         }
558     }
559   calling_frame_info = get_prev_frame (fi);
560
561   if (!addr_exp && selected_frame_level >= 0)
562     {
563       printf_filtered ("Stack level %d, frame at ", selected_frame_level);
564       print_address_numeric (fi->frame, 1, gdb_stdout);
565       printf_filtered (":\n");
566     }
567   else
568     {
569       printf_filtered ("Stack frame at ");
570       print_address_numeric (fi->frame, 1, gdb_stdout);
571       printf_filtered (":\n");
572     }
573   printf_filtered (" %s = ", reg_names[PC_REGNUM]);
574   print_address_numeric (fi->pc, 1, gdb_stdout);
575
576   wrap_here ("   ");
577   if (funname)
578     {
579       printf_filtered (" in ");
580       fprintf_symbol_filtered (gdb_stdout, funname, funlang,
581                                DMGL_ANSI | DMGL_PARAMS);
582     }
583   wrap_here ("   ");
584   if (sal.symtab)
585     printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
586   puts_filtered ("; ");
587   wrap_here ("    ");
588   printf_filtered ("saved %s ", reg_names[PC_REGNUM]);
589   print_address_numeric (FRAME_SAVED_PC (fi), 1, gdb_stdout);
590   printf_filtered ("\n");
591
592   {
593     int frameless = 0;
594 #ifdef FRAMELESS_FUNCTION_INVOCATION
595     FRAMELESS_FUNCTION_INVOCATION (fi, frameless);
596 #endif
597     if (frameless)
598       printf_filtered (" (FRAMELESS),");
599   }
600
601   if (calling_frame_info)
602     {
603       printf_filtered (" called by frame at ");
604       print_address_numeric (calling_frame_info->frame, 1, gdb_stdout);
605     }
606   if (fi->next && calling_frame_info)
607     puts_filtered (",");
608   wrap_here ("   ");
609   if (fi->next)
610     {
611       printf_filtered (" caller of frame at ");
612       print_address_numeric (fi->next->frame, 1, gdb_stdout);
613     }
614   if (fi->next || calling_frame_info)
615     puts_filtered ("\n");
616   if (s)
617     printf_filtered (" source language %s.\n", language_str (s->language));
618
619 #ifdef PRINT_EXTRA_FRAME_INFO
620   PRINT_EXTRA_FRAME_INFO (fi);
621 #endif
622
623   {
624     /* Address of the argument list for this frame, or 0.  */
625     CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);
626     /* Number of args for this frame, or -1 if unknown.  */
627     int numargs;
628
629     if (arg_list == 0)
630       printf_filtered (" Arglist at unknown address.\n");
631     else
632       {
633         printf_filtered (" Arglist at ");
634         print_address_numeric (arg_list, 1, gdb_stdout);
635         printf_filtered (",");
636
637         FRAME_NUM_ARGS (numargs, fi);
638         if (numargs < 0)
639           puts_filtered (" args: ");
640         else if (numargs == 0)
641           puts_filtered (" no args.");
642         else if (numargs == 1)
643           puts_filtered (" 1 arg: ");
644         else
645           printf_filtered (" %d args: ", numargs);
646         print_frame_args (func, fi, numargs, gdb_stdout);
647         puts_filtered ("\n");
648       }
649   }
650   {
651     /* Address of the local variables for this frame, or 0.  */
652     CORE_ADDR arg_list = FRAME_LOCALS_ADDRESS (fi);
653
654     if (arg_list == 0)
655       printf_filtered (" Locals at unknown address,");
656     else
657       {
658         printf_filtered (" Locals at ");
659         print_address_numeric (arg_list, 1, gdb_stdout);
660         printf_filtered (",");
661       }
662   }
663
664 #if defined (FRAME_FIND_SAVED_REGS)  
665   get_frame_saved_regs (fi, &fsr);
666   /* The sp is special; what's returned isn't the save address, but
667      actually the value of the previous frame's sp.  */
668   printf_filtered (" Previous frame's sp is ");
669   print_address_numeric (fsr.regs[SP_REGNUM], 1, gdb_stdout);
670   printf_filtered ("\n");
671   count = 0;
672   numregs = ARCH_NUM_REGS;
673   for (i = 0; i < numregs; i++)
674     if (fsr.regs[i] && i != SP_REGNUM)
675       {
676         if (count == 0)
677           puts_filtered (" Saved registers:\n ");
678         else
679           puts_filtered (",");
680         wrap_here (" ");
681         printf_filtered (" %s at ", reg_names[i]);
682         print_address_numeric (fsr.regs[i], 1, gdb_stdout);
683         count++;
684       }
685   if (count)
686     puts_filtered ("\n");
687 #else  /* Have FRAME_FIND_SAVED_REGS.  */
688   /* We could get some information about saved registers by calling
689      get_saved_register on each register.  Which info goes with which frame
690      is necessarily lost, however, and I suspect that the users don't care
691      whether they get the info.  */
692   puts_filtered ("\n");
693 #endif /* Have FRAME_FIND_SAVED_REGS.  */
694 }
695
696 #if 0
697 /* Set a limit on the number of frames printed by default in a
698    backtrace.  */
699
700 static int backtrace_limit;
701
702 static void
703 set_backtrace_limit_command (count_exp, from_tty)
704      char *count_exp;
705      int from_tty;
706 {
707   int count = parse_and_eval_address (count_exp);
708
709   if (count < 0)
710     error ("Negative argument not meaningful as backtrace limit.");
711
712   backtrace_limit = count;
713 }
714
715 static void
716 backtrace_limit_info (arg, from_tty)
717      char *arg;
718      int from_tty;
719 {
720   if (arg)
721     error ("\"Info backtrace-limit\" takes no arguments.");
722
723   printf_unfiltered ("Backtrace limit: %d.\n", backtrace_limit);
724 }
725 #endif
726
727 /* Print briefly all stack frames or just the innermost COUNT frames.  */
728
729 static void
730 backtrace_command (count_exp, from_tty)
731      char *count_exp;
732      int from_tty;
733 {
734   struct frame_info *fi;
735   register int count;
736   register int i;
737   register struct frame_info *trailing;
738   register int trailing_level;
739
740   if (!target_has_stack)
741     error ("No stack.");
742
743   /* The following code must do two things.  First, it must
744      set the variable TRAILING to the frame from which we should start
745      printing.  Second, it must set the variable count to the number
746      of frames which we should print, or -1 if all of them.  */
747   trailing = get_current_frame ();
748   trailing_level = 0;
749   if (count_exp)
750     {
751       count = parse_and_eval_address (count_exp);
752       if (count < 0)
753         {
754           struct frame_info *current;
755
756           count = -count;
757
758           current = trailing;
759           while (current && count--)
760             {
761               QUIT;
762               current = get_prev_frame (current);
763             }
764           
765           /* Will stop when CURRENT reaches the top of the stack.  TRAILING
766              will be COUNT below it.  */
767           while (current)
768             {
769               QUIT;
770               trailing = get_prev_frame (trailing);
771               current = get_prev_frame (current);
772               trailing_level++;
773             }
774           
775           count = -1;
776         }
777     }
778   else
779     count = -1;
780
781   if (info_verbose)
782     {
783       struct partial_symtab *ps;
784       
785       /* Read in symbols for all of the frames.  Need to do this in
786          a separate pass so that "Reading in symbols for xxx" messages
787          don't screw up the appearance of the backtrace.  Also
788          if people have strong opinions against reading symbols for
789          backtrace this may have to be an option.  */
790       i = count;
791       for (fi = trailing;
792            fi != NULL && i--;
793            fi = get_prev_frame (fi))
794         {
795           QUIT;
796           ps = find_pc_psymtab (fi->pc);
797           if (ps)
798             PSYMTAB_TO_SYMTAB (ps);     /* Force syms to come in */
799         }
800     }
801
802   for (i = 0, fi = trailing;
803        fi && count--;
804        i++, fi = get_prev_frame (fi))
805     {
806       QUIT;
807
808       /* Don't use print_stack_frame; if an error() occurs it probably
809          means further attempts to backtrace would fail (on the other
810          hand, perhaps the code does or could be fixed to make sure
811          the frame->prev field gets set to NULL in that case).  */
812       print_frame_info (fi, trailing_level + i, 0, 1);
813     }
814
815   /* If we've stopped before the end, mention that.  */
816   if (fi && from_tty)
817     printf_filtered ("(More stack frames follow...)\n");
818 }
819 \f
820 /* Print the local variables of a block B active in FRAME.
821    Return 1 if any variables were printed; 0 otherwise.  */
822
823 static int
824 print_block_frame_locals (b, fi, stream)
825      struct block *b;
826      register struct frame_info *fi;
827      register GDB_FILE *stream;
828 {
829   int nsyms;
830   register int i;
831   register struct symbol *sym;
832   register int values_printed = 0;
833
834   nsyms = BLOCK_NSYMS (b);
835
836   for (i = 0; i < nsyms; i++)
837     {
838       sym = BLOCK_SYM (b, i);
839       switch (SYMBOL_CLASS (sym))
840         {
841         case LOC_LOCAL:
842         case LOC_REGISTER:
843         case LOC_STATIC:
844         case LOC_BASEREG:
845           values_printed = 1;
846           fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
847           fputs_filtered (" = ", stream);
848           print_variable_value (sym, fi, stream);
849           fprintf_filtered (stream, "\n");
850           break;
851
852         default:
853           /* Ignore symbols which are not locals.  */
854           break;
855         }
856     }
857   return values_printed;
858 }
859
860 /* Same, but print labels.  */
861
862 static int
863 print_block_frame_labels (b, have_default, stream)
864      struct block *b;
865      int *have_default;
866      register GDB_FILE *stream;
867 {
868   int nsyms;
869   register int i;
870   register struct symbol *sym;
871   register int values_printed = 0;
872
873   nsyms = BLOCK_NSYMS (b);
874
875   for (i = 0; i < nsyms; i++)
876     {
877       sym = BLOCK_SYM (b, i);
878       if (STREQ (SYMBOL_NAME (sym), "default"))
879         {
880           if (*have_default)
881             continue;
882           *have_default = 1;
883         }
884       if (SYMBOL_CLASS (sym) == LOC_LABEL)
885         {
886           struct symtab_and_line sal;
887           sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
888           values_printed = 1;
889           fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
890           if (addressprint)
891             {
892               fprintf_filtered (stream, " ");
893               print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, stream);
894             }
895           fprintf_filtered (stream, " in file %s, line %d\n",
896                             sal.symtab->filename, sal.line);
897         }
898     }
899   return values_printed;
900 }
901
902 /* Print on STREAM all the local variables in frame FRAME,
903    including all the blocks active in that frame
904    at its current pc.
905
906    Returns 1 if the job was done,
907    or 0 if nothing was printed because we have no info
908    on the function running in FRAME.  */
909
910 static void
911 print_frame_local_vars (fi, stream)
912      register struct frame_info *fi;
913      register GDB_FILE *stream;
914 {
915   register struct block *block = get_frame_block (fi);
916   register int values_printed = 0;
917
918   if (block == 0)
919     {
920       fprintf_filtered (stream, "No symbol table info available.\n");
921       return;
922     }
923   
924   while (block != 0)
925     {
926       if (print_block_frame_locals (block, fi, stream))
927         values_printed = 1;
928       /* After handling the function's top-level block, stop.
929          Don't continue to its superblock, the block of
930          per-file symbols.  */
931       if (BLOCK_FUNCTION (block))
932         break;
933       block = BLOCK_SUPERBLOCK (block);
934     }
935
936   if (!values_printed)
937     {
938       fprintf_filtered (stream, "No locals.\n");
939     }
940 }
941
942 /* Same, but print labels.  */
943
944 static void
945 print_frame_label_vars (fi, this_level_only, stream)
946      register struct frame_info *fi;
947      int this_level_only;
948      register GDB_FILE *stream;
949 {
950   register struct blockvector *bl;
951   register struct block *block = get_frame_block (fi);
952   register int values_printed = 0;
953   int index, have_default = 0;
954   char *blocks_printed;
955   CORE_ADDR pc = fi->pc;
956
957   if (block == 0)
958     {
959       fprintf_filtered (stream, "No symbol table info available.\n");
960       return;
961     }
962
963   bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
964   blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
965   memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
966
967   while (block != 0)
968     {
969       CORE_ADDR end = BLOCK_END (block) - 4;
970       int last_index;
971
972       if (bl != blockvector_for_pc (end, &index))
973         error ("blockvector blotch");
974       if (BLOCKVECTOR_BLOCK (bl, index) != block)
975         error ("blockvector botch");
976       last_index = BLOCKVECTOR_NBLOCKS (bl);
977       index += 1;
978
979       /* Don't print out blocks that have gone by.  */
980       while (index < last_index
981              && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
982         index++;
983
984       while (index < last_index
985              && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
986         {
987           if (blocks_printed[index] == 0)
988             {
989               if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream))
990                 values_printed = 1;
991               blocks_printed[index] = 1;
992             }
993           index++;
994         }
995       if (have_default)
996         return;
997       if (values_printed && this_level_only)
998         return;
999
1000       /* After handling the function's top-level block, stop.
1001          Don't continue to its superblock, the block of
1002          per-file symbols.  */
1003       if (BLOCK_FUNCTION (block))
1004         break;
1005       block = BLOCK_SUPERBLOCK (block);
1006     }
1007
1008   if (!values_printed && !this_level_only)
1009     {
1010       fprintf_filtered (stream, "No catches.\n");
1011     }
1012 }
1013
1014 /* ARGSUSED */
1015 static void
1016 locals_info (args, from_tty)
1017      char *args;
1018      int from_tty;
1019 {
1020   if (!selected_frame)
1021     error ("No frame selected.");
1022   print_frame_local_vars (selected_frame, gdb_stdout);
1023 }
1024
1025 static void
1026 catch_info (ignore, from_tty)
1027      char *ignore;
1028      int from_tty;
1029 {
1030   if (!selected_frame)
1031     error ("No frame selected.");
1032   print_frame_label_vars (selected_frame, 0, gdb_stdout);
1033 }
1034
1035 static void
1036 print_frame_arg_vars (fi, stream)
1037      register struct frame_info *fi;
1038      register GDB_FILE *stream;
1039 {
1040   struct symbol *func = get_frame_function (fi);
1041   register struct block *b;
1042   int nsyms;
1043   register int i;
1044   register struct symbol *sym, *sym2;
1045   register int values_printed = 0;
1046
1047   if (func == 0)
1048     {
1049       fprintf_filtered (stream, "No symbol table info available.\n");
1050       return;
1051     }
1052
1053   b = SYMBOL_BLOCK_VALUE (func);
1054   nsyms = BLOCK_NSYMS (b);
1055
1056   for (i = 0; i < nsyms; i++)
1057     {
1058       sym = BLOCK_SYM (b, i);
1059       switch (SYMBOL_CLASS (sym))
1060         {
1061         case LOC_ARG:
1062         case LOC_LOCAL_ARG:
1063         case LOC_REF_ARG:
1064         case LOC_REGPARM:
1065         case LOC_REGPARM_ADDR:
1066         case LOC_BASEREG_ARG:
1067           values_printed = 1;
1068           fputs_filtered (SYMBOL_SOURCE_NAME (sym), stream);
1069           fputs_filtered (" = ", stream);
1070
1071           /* We have to look up the symbol because arguments can have
1072              two entries (one a parameter, one a local) and the one we
1073              want is the local, which lookup_symbol will find for us.
1074              This includes gcc1 (not gcc2) on the sparc when passing a
1075              small structure and gcc2 when the argument type is float
1076              and it is passed as a double and converted to float by
1077              the prologue (in the latter case the type of the LOC_ARG
1078              symbol is double and the type of the LOC_LOCAL symbol is
1079              float).  There are also LOC_ARG/LOC_REGISTER pairs which
1080              are not combined in symbol-reading.  */
1081
1082           sym2 = lookup_symbol (SYMBOL_NAME (sym),
1083                         b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
1084           print_variable_value (sym2, fi, stream);
1085           fprintf_filtered (stream, "\n");
1086           break;
1087
1088         default:
1089           /* Don't worry about things which aren't arguments.  */
1090           break;
1091         }
1092     }
1093
1094   if (!values_printed)
1095     {
1096       fprintf_filtered (stream, "No arguments.\n");
1097     }
1098 }
1099
1100 static void
1101 args_info (ignore, from_tty)
1102      char *ignore;
1103      int from_tty;
1104 {
1105   if (!selected_frame)
1106     error ("No frame selected.");
1107   print_frame_arg_vars (selected_frame, gdb_stdout);
1108 }
1109 \f
1110 /* Select frame FI, and note that its stack level is LEVEL.
1111    LEVEL may be -1 if an actual level number is not known.  */
1112
1113 void
1114 select_frame (fi, level)
1115      struct frame_info *fi;
1116      int level;
1117 {
1118   register struct symtab *s;
1119
1120   selected_frame = fi;
1121   selected_frame_level = level;
1122
1123   /* Ensure that symbols for this frame are read in.  Also, determine the
1124      source language of this frame, and switch to it if desired.  */
1125   if (fi)
1126   {
1127     s = find_pc_symtab (fi->pc);
1128     if (s 
1129         && s->language != current_language->la_language
1130         && s->language != language_unknown
1131         && language_mode == language_mode_auto) {
1132       set_language(s->language);
1133     }
1134   }
1135 }
1136
1137 /* Store the selected frame and its level into *FRAMEP and *LEVELP.
1138    If there is no selected frame, *FRAMEP is set to NULL.  */
1139
1140 void
1141 record_selected_frame (frameaddrp, levelp)
1142      CORE_ADDR *frameaddrp;
1143      int *levelp;
1144 {
1145   *frameaddrp = selected_frame ? selected_frame->frame : 0;
1146   *levelp = selected_frame_level;
1147 }
1148
1149 /* Return the symbol-block in which the selected frame is executing.
1150    Can return zero under various legitimate circumstances.  */
1151
1152 struct block *
1153 get_selected_block ()
1154 {
1155   if (!target_has_stack)
1156     return 0;
1157
1158   if (!selected_frame)
1159     return get_current_block ();
1160   return get_frame_block (selected_frame);
1161 }
1162
1163 /* Find a frame a certain number of levels away from FRAME.
1164    LEVEL_OFFSET_PTR points to an int containing the number of levels.
1165    Positive means go to earlier frames (up); negative, the reverse.
1166    The int that contains the number of levels is counted toward
1167    zero as the frames for those levels are found.
1168    If the top or bottom frame is reached, that frame is returned,
1169    but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
1170    how much farther the original request asked to go.  */
1171
1172 struct frame_info *
1173 find_relative_frame (frame, level_offset_ptr)
1174      register struct frame_info *frame;
1175      register int *level_offset_ptr;
1176 {
1177   register struct frame_info *prev;
1178   register struct frame_info *frame1;
1179
1180   /* Going up is simple: just do get_prev_frame enough times
1181      or until initial frame is reached.  */
1182   while (*level_offset_ptr > 0)
1183     {
1184       prev = get_prev_frame (frame);
1185       if (prev == 0)
1186         break;
1187       (*level_offset_ptr)--;
1188       frame = prev;
1189     }
1190   /* Going down is just as simple.  */
1191   if (*level_offset_ptr < 0)
1192     {
1193       while (*level_offset_ptr < 0) {
1194         frame1 = get_next_frame (frame);
1195         if (!frame1)
1196           break;
1197         frame = frame1;
1198         (*level_offset_ptr)++;
1199       }
1200     }
1201   return frame;
1202 }
1203
1204 /* The "select_frame" command.  With no arg, NOP.
1205    With arg LEVEL_EXP, select the frame at level LEVEL if it is a
1206    valid level.  Otherwise, treat level_exp as an address expression
1207    and select it.  See parse_frame_specification for more info on proper
1208    frame expressions. */
1209
1210 /* ARGSUSED */
1211 static void
1212 select_frame_command (level_exp, from_tty)
1213      char *level_exp;
1214      int from_tty;
1215 {
1216   register struct frame_info *frame, *frame1;
1217   unsigned int level = 0;
1218
1219   if (!target_has_stack)
1220     error ("No stack.");
1221
1222   frame = parse_frame_specification (level_exp);
1223
1224   /* Try to figure out what level this frame is.  But if there is
1225      no current stack, don't error out -- let the user set one.  */
1226   frame1 = 0;
1227   if (get_current_frame()) {
1228     for (frame1 = get_prev_frame (0);
1229          frame1 && frame1 != frame;
1230          frame1 = get_prev_frame (frame1))
1231       level++;
1232   }
1233
1234   if (!frame1)
1235     level = 0;
1236
1237   select_frame (frame, level);
1238 }
1239
1240 /* The "frame" command.  With no arg, print selected frame briefly.
1241    With arg, behaves like select_frame and then prints the selected
1242    frame.  */
1243
1244 static void
1245 frame_command (level_exp, from_tty)
1246      char *level_exp;
1247      int from_tty;
1248 {
1249   select_frame_command (level_exp, from_tty);
1250   print_stack_frame (selected_frame, selected_frame_level, 1);
1251 }
1252
1253 /* Select the frame up one or COUNT stack levels
1254    from the previously selected frame, and print it briefly.  */
1255
1256 /* ARGSUSED */
1257 static void
1258 up_silently_command (count_exp, from_tty)
1259      char *count_exp;
1260      int from_tty;
1261 {
1262   register struct frame_info *fi;
1263   int count = 1, count1;
1264   if (count_exp)
1265     count = parse_and_eval_address (count_exp);
1266   count1 = count;
1267   
1268   if (target_has_stack == 0 || selected_frame == 0)
1269     error ("No stack.");
1270
1271   fi = find_relative_frame (selected_frame, &count1);
1272   if (count1 != 0 && count_exp == 0)
1273     error ("Initial frame selected; you cannot go up.");
1274   select_frame (fi, selected_frame_level + count - count1);
1275 }
1276
1277 static void
1278 up_command (count_exp, from_tty)
1279      char *count_exp;
1280      int from_tty;
1281 {
1282   up_silently_command (count_exp, from_tty);
1283   print_stack_frame (selected_frame, selected_frame_level, 1);
1284 }
1285
1286 /* Select the frame down one or COUNT stack levels
1287    from the previously selected frame, and print it briefly.  */
1288
1289 /* ARGSUSED */
1290 static void
1291 down_silently_command (count_exp, from_tty)
1292      char *count_exp;
1293      int from_tty;
1294 {
1295   register struct frame_info *frame;
1296   int count = -1, count1;
1297   if (count_exp)
1298     count = - parse_and_eval_address (count_exp);
1299   count1 = count;
1300   
1301   if (target_has_stack == 0 || selected_frame == 0)
1302     error ("No stack.");
1303
1304   frame = find_relative_frame (selected_frame, &count1);
1305   if (count1 != 0 && count_exp == 0)
1306     {
1307
1308       /* We only do this if count_exp is not specified.  That way "down"
1309          means to really go down (and let me know if that is
1310          impossible), but "down 9999" can be used to mean go all the way
1311          down without getting an error.  */
1312
1313       error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
1314     }
1315
1316   select_frame (frame, selected_frame_level + count - count1);
1317 }
1318
1319
1320 static void
1321 down_command (count_exp, from_tty)
1322      char *count_exp;
1323      int from_tty;
1324 {
1325   down_silently_command (count_exp, from_tty);
1326   print_stack_frame (selected_frame, selected_frame_level, 1);
1327 }
1328 \f
1329 static void
1330 return_command (retval_exp, from_tty)
1331      char *retval_exp;
1332      int from_tty;
1333 {
1334   struct symbol *thisfun;
1335   CORE_ADDR selected_frame_addr;
1336   CORE_ADDR selected_frame_pc;
1337   struct frame_info *frame;
1338   value_ptr return_value = NULL;
1339
1340   if (selected_frame == NULL)
1341     error ("No selected frame.");
1342   thisfun = get_frame_function (selected_frame);
1343   selected_frame_addr = FRAME_FP (selected_frame);
1344   selected_frame_pc = selected_frame->pc;
1345
1346   /* Compute the return value (if any -- possibly getting errors here).  */
1347
1348   if (retval_exp)
1349     {
1350       struct type *return_type = NULL;
1351
1352       return_value = parse_and_eval (retval_exp);
1353
1354       /* Cast return value to the return type of the function.  */
1355       if (thisfun != NULL)
1356         return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
1357       if (return_type == NULL)
1358         return_type = builtin_type_int;
1359       return_value = value_cast (return_type, return_value);
1360
1361       /* Make sure we have fully evaluated it, since
1362          it might live in the stack frame we're about to pop.  */
1363       if (VALUE_LAZY (return_value))
1364         value_fetch_lazy (return_value);
1365     }
1366
1367   /* If interactive, require confirmation.  */
1368
1369   if (from_tty)
1370     {
1371       if (thisfun != 0)
1372         {
1373           if (!query ("Make %s return now? ", SYMBOL_SOURCE_NAME (thisfun)))
1374             {
1375               error ("Not confirmed.");
1376               /* NOTREACHED */
1377             }
1378         }
1379       else
1380         if (!query ("Make selected stack frame return now? "))
1381           error ("Not confirmed.");
1382     }
1383
1384   /* Do the real work.  Pop until the specified frame is current.  We
1385      use this method because the selected_frame is not valid after
1386      a POP_FRAME.  The pc comparison makes this work even if the
1387      selected frame shares its fp with another frame.  */
1388
1389   while (selected_frame_addr != (frame = get_current_frame())->frame
1390          || selected_frame_pc != frame->pc)
1391     POP_FRAME;
1392
1393   /* Then pop that frame.  */
1394
1395   POP_FRAME;
1396
1397   /* Compute the return value (if any) and store in the place
1398      for return values.  */
1399
1400   if (retval_exp)
1401     set_return_value (return_value);
1402
1403   /* If interactive, print the frame that is now current.  */
1404
1405   if (from_tty)
1406     frame_command ("0", 1);
1407   else
1408     select_frame_command ("0", 0);
1409 }
1410
1411 /* Gets the language of the current frame.  */
1412
1413 enum language
1414 get_frame_language()
1415 {
1416   register struct symtab *s;
1417   enum language flang;          /* The language of the current frame */
1418    
1419   if (selected_frame)
1420     {
1421       s = find_pc_symtab(selected_frame->pc);
1422       if (s)
1423         flang = s->language;
1424       else
1425         flang = language_unknown;
1426     }
1427   else
1428     flang = language_unknown;
1429
1430   return flang;
1431 }
1432 \f
1433 void
1434 _initialize_stack ()
1435 {
1436 #if 0  
1437   backtrace_limit = 30;
1438 #endif
1439
1440   add_com ("return", class_stack, return_command,
1441            "Make selected stack frame return to its caller.\n\
1442 Control remains in the debugger, but when you continue\n\
1443 execution will resume in the frame above the one now selected.\n\
1444 If an argument is given, it is an expression for the value to return.");
1445
1446   add_com ("up", class_stack, up_command,
1447            "Select and print stack frame that called this one.\n\
1448 An argument says how many frames up to go.");
1449   add_com ("up-silently", class_support, up_silently_command,
1450            "Same as the `up' command, but does not print anything.\n\
1451 This is useful in command scripts.");
1452
1453   add_com ("down", class_stack, down_command,
1454            "Select and print stack frame called by this one.\n\
1455 An argument says how many frames down to go.");
1456   add_com_alias ("do", "down", class_stack, 1);
1457   add_com_alias ("dow", "down", class_stack, 1);
1458   add_com ("down-silently", class_support, down_silently_command,
1459            "Same as the `down' command, but does not print anything.\n\
1460 This is useful in command scripts.");
1461
1462   add_com ("frame", class_stack, frame_command,
1463            "Select and print a stack frame.\n\
1464 With no argument, print the selected stack frame.  (See also \"info frame\").\n\
1465 An argument specifies the frame to select.\n\
1466 It can be a stack frame number or the address of the frame.\n\
1467 With argument, nothing is printed if input is coming from\n\
1468 a command file or a user-defined command.");
1469
1470   add_com_alias ("f", "frame", class_stack, 1);
1471
1472   add_com ("select-frame", class_stack, select_frame_command,
1473            "Select a stack frame without printing anything.\n\
1474 An argument specifies the frame to select.\n\
1475 It can be a stack frame number or the address of the frame.\n");
1476
1477   add_com ("backtrace", class_stack, backtrace_command,
1478            "Print backtrace of all stack frames, or innermost COUNT frames.\n\
1479 With a negative argument, print outermost -COUNT frames.");
1480   add_com_alias ("bt", "backtrace", class_stack, 0);
1481   add_com_alias ("where", "backtrace", class_alias, 0);
1482   add_info ("stack", backtrace_command,
1483             "Backtrace of the stack, or innermost COUNT frames.");
1484   add_info_alias ("s", "stack", 1);
1485   add_info ("frame", frame_info,
1486             "All about selected stack frame, or frame at ADDR.");
1487   add_info_alias ("f", "frame", 1);
1488   add_info ("locals", locals_info,
1489             "Local variables of current stack frame.");
1490   add_info ("args", args_info,
1491             "Argument variables of current stack frame.");
1492   add_info ("catch", catch_info,
1493             "Exceptions that can be caught in the current stack frame.");
1494
1495 #if 0
1496   add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, 
1497            "Specify maximum number of frames for \"backtrace\" to print by default.",
1498            &setlist);
1499   add_info ("backtrace-limit", backtrace_limit_info,
1500             "The maximum number of frames for \"backtrace\" to print by default.");
1501 #endif
1502 }