void (*deprecated_selected_frame_level_changed_hook) (int);
-/* The possible choices of "set print frame-arguments, and the value
+/* The possible choices of "set print frame-arguments", and the value
of this setting. */
static const char *print_frame_arguments_choices[] =
{"all", "scalars", "none", NULL};
static const char *print_frame_arguments = "scalars";
+/* The possible choices of "set print entry-values", and the value
+ of this setting. */
+
+const char print_entry_values_no[] = "no";
+const char print_entry_values_only[] = "only";
+const char print_entry_values_preferred[] = "preferred";
+const char print_entry_values_if_needed[] = "if-needed";
+const char print_entry_values_both[] = "both";
+const char print_entry_values_compact[] = "compact";
+const char print_entry_values_default[] = "default";
+static const char *print_entry_values_choices[] =
+{
+ print_entry_values_no,
+ print_entry_values_only,
+ print_entry_values_preferred,
+ print_entry_values_if_needed,
+ print_entry_values_both,
+ print_entry_values_compact,
+ print_entry_values_default,
+ NULL
+};
+const char *print_entry_values = print_entry_values_default;
+
/* Prototypes for local functions. */
static void print_frame_local_vars (struct frame_info *, int,
enum print_what print_what, int print_args,
struct symtab_and_line sal);
+static void set_last_displayed_sal (int valid,
+ struct program_space *pspace,
+ CORE_ADDR addr,
+ struct symtab *symtab,
+ int line);
+
/* Zero means do things normally; we are interacting directly with the
user. One means print the full filename and linenumber when a
frame is printed, and do so in a format emacs18/emacs19.22 can
cases and in a slightly different syntax. */
int annotation_level = 0;
-\f
-
-struct print_stack_frame_args
-{
- struct frame_info *frame;
- int print_level;
- enum print_what print_what;
- int print_args;
-};
-
-/* Show or print the frame arguments; stub for catch_errors. */
-
-static int
-print_stack_frame_stub (void *args)
-{
- struct print_stack_frame_args *p = args;
- int center = (p->print_what == SRC_LINE || p->print_what == SRC_AND_LOC);
- print_frame_info (p->frame, p->print_level, p->print_what, p->print_args);
- set_current_sal_from_frame (p->frame, center);
- return 0;
-}
+/* These variables hold the last symtab and line we displayed to the user.
+ * This is where we insert a breakpoint or a skiplist entry by default. */
+static int last_displayed_sal_valid = 0;
+static struct program_space *last_displayed_pspace = 0;
+static CORE_ADDR last_displayed_addr = 0;
+static struct symtab *last_displayed_symtab = 0;
+static int last_displayed_line = 0;
+\f
/* Return 1 if we should display the address in addition to the location,
because we are in the middle of a statement. */
print_stack_frame (struct frame_info *frame, int print_level,
enum print_what print_what)
{
- struct print_stack_frame_args args;
+ volatile struct gdb_exception e;
- args.frame = frame;
- args.print_level = print_level;
- args.print_what = print_what;
/* For mi, alway print location and address. */
- args.print_what = ui_out_is_mi_like_p (uiout) ? LOC_AND_ADDRESS : print_what;
- args.print_args = 1;
-
- catch_errors (print_stack_frame_stub, &args, "", RETURN_MASK_ERROR);
-}
+ if (ui_out_is_mi_like_p (current_uiout))
+ print_what = LOC_AND_ADDRESS;
-struct print_args_args
-{
- struct symbol *func;
- struct frame_info *frame;
- struct ui_file *stream;
-};
+ TRY_CATCH (e, RETURN_MASK_ERROR)
+ {
+ int center = (print_what == SRC_LINE || print_what == SRC_AND_LOC);
-static int print_args_stub (void *args);
+ print_frame_info (frame, print_level, print_what, 1 /* print_args */);
+ set_current_sal_from_frame (frame, center);
+ }
+}
/* Print nameless arguments of frame FRAME on STREAM, where START is
the offset of the first nameless argument, and NUM is the number of
}
}
+/* Print single argument of inferior function. ARG must be already
+ read in.
+
+ Errors are printed as if they would be the parameter value. Use zeroed ARG
+ iff it should not be printed accoring to user settings. */
+
+static void
+print_frame_arg (const struct frame_arg *arg)
+{
+ struct ui_out *uiout = current_uiout;
+ volatile struct gdb_exception except;
+ struct cleanup *old_chain;
+ struct ui_stream *stb;
+
+ stb = ui_out_stream_new (uiout);
+ old_chain = make_cleanup_ui_out_stream_delete (stb);
+
+ gdb_assert (!arg->val || !arg->error);
+ gdb_assert (arg->entry_kind == print_entry_values_no
+ || arg->entry_kind == print_entry_values_only
+ || (!ui_out_is_mi_like_p (uiout)
+ && arg->entry_kind == print_entry_values_compact));
+
+ annotate_arg_begin ();
+
+ make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (arg->sym),
+ SYMBOL_LANGUAGE (arg->sym), DMGL_PARAMS | DMGL_ANSI);
+ if (arg->entry_kind == print_entry_values_compact)
+ {
+ /* It is OK to provide invalid MI-like stream as with
+ PRINT_ENTRY_VALUE_COMPACT we never use MI. */
+ fputs_filtered ("=", stb->stream);
+
+ fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (arg->sym),
+ SYMBOL_LANGUAGE (arg->sym),
+ DMGL_PARAMS | DMGL_ANSI);
+ }
+ if (arg->entry_kind == print_entry_values_only
+ || arg->entry_kind == print_entry_values_compact)
+ fputs_filtered ("@entry", stb->stream);
+ ui_out_field_stream (uiout, "name", stb);
+ annotate_arg_name_end ();
+ ui_out_text (uiout, "=");
+
+ if (!arg->val && !arg->error)
+ ui_out_text (uiout, "...");
+ else
+ {
+ if (arg->error)
+ except.message = arg->error;
+ else
+ {
+ /* TRY_CATCH has two statements, wrap it in a block. */
+
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ const struct language_defn *language;
+ struct value_print_options opts;
+
+ /* Avoid value_print because it will deref ref parameters. We
+ just want to print their addresses. Print ??? for args whose
+ address we do not know. We pass 2 as "recurse" to val_print
+ because our standard indentation here is 4 spaces, and
+ val_print indents 2 for each recurse. */
+
+ annotate_arg_value (value_type (arg->val));
+
+ /* Use the appropriate language to display our symbol, unless the
+ user forced the language to a specific language. */
+ if (language_mode == language_mode_auto)
+ language = language_def (SYMBOL_LANGUAGE (arg->sym));
+ else
+ language = current_language;
+
+ get_raw_print_options (&opts);
+ opts.deref_ref = 1;
+
+ /* True in "summary" mode, false otherwise. */
+ opts.summary = !strcmp (print_frame_arguments, "scalars");
+
+ common_val_print (arg->val, stb->stream, 2, &opts, language);
+ }
+ }
+ if (except.message)
+ fprintf_filtered (stb->stream, _("<error reading variable: %s>"),
+ except.message);
+ }
+
+ ui_out_field_stream (uiout, "value", stb);
+
+ /* Aleo invoke ui_out_tuple_end. */
+ do_cleanups (old_chain);
+
+ annotate_arg_end ();
+}
+
+/* Read in inferior function parameter SYM at FRAME into ARGP. Caller is
+ responsible for xfree of ARGP->ERROR. This function never throws an
+ exception. */
+
+void
+read_frame_arg (struct symbol *sym, struct frame_info *frame,
+ struct frame_arg *argp, struct frame_arg *entryargp)
+{
+ struct value *val = NULL, *entryval = NULL;
+ char *val_error = NULL, *entryval_error = NULL;
+ int val_equal = 0;
+ volatile struct gdb_exception except;
+
+ if (print_entry_values != print_entry_values_only
+ && print_entry_values != print_entry_values_preferred)
+ {
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ val = read_var_value (sym, frame);
+ }
+ if (!val)
+ {
+ val_error = alloca (strlen (except.message) + 1);
+ strcpy (val_error, except.message);
+ }
+ }
+
+ if (SYMBOL_CLASS (sym) == LOC_COMPUTED
+ && print_entry_values != print_entry_values_no
+ && (print_entry_values != print_entry_values_if_needed
+ || !val || value_optimized_out (val)))
+ {
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ const struct symbol_computed_ops *ops;
+
+ ops = SYMBOL_COMPUTED_OPS (sym);
+ entryval = ops->read_variable_at_entry (sym, frame);
+ }
+ if (!entryval)
+ {
+ entryval_error = alloca (strlen (except.message) + 1);
+ strcpy (entryval_error, except.message);
+ }
+
+ if (except.error == NO_ENTRY_VALUE_ERROR
+ || (entryval && value_optimized_out (entryval)))
+ {
+ entryval = NULL;
+ entryval_error = NULL;
+ }
+
+ if (print_entry_values == print_entry_values_compact
+ || print_entry_values == print_entry_values_default)
+ {
+ /* For MI do not try to use print_entry_values_compact for ARGP. */
+
+ if (val && entryval && !ui_out_is_mi_like_p (current_uiout))
+ {
+ unsigned len = TYPE_LENGTH (value_type (val));
+
+ if (!value_optimized_out (val) && value_lazy (val))
+ value_fetch_lazy (val);
+ if (!value_optimized_out (val) && value_lazy (entryval))
+ value_fetch_lazy (entryval);
+ if (!value_optimized_out (val)
+ && value_available_contents_eq (val, 0, entryval, 0, len))
+ {
+ /* Initialize it just to avoid a GCC false warning. */
+ struct value *val_deref = NULL, *entryval_deref;
+
+ /* DW_AT_GNU_call_site_value does match with the current
+ value. If it is a reference still try to verify if
+ dereferenced DW_AT_GNU_call_site_data_value does not
+ differ. */
+
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ unsigned len_deref;
+
+ val_deref = coerce_ref (val);
+ if (value_lazy (val_deref))
+ value_fetch_lazy (val_deref);
+ len_deref = TYPE_LENGTH (value_type (val_deref));
+
+ entryval_deref = coerce_ref (entryval);
+ if (value_lazy (entryval_deref))
+ value_fetch_lazy (entryval_deref);
+
+ /* If the reference addresses match but dereferenced
+ content does not match print them. */
+ if (val != val_deref
+ && value_available_contents_eq (val_deref, 0,
+ entryval_deref, 0,
+ len_deref))
+ val_equal = 1;
+ }
+
+ /* Value was not a reference; and its content matches. */
+ if (val == val_deref)
+ val_equal = 1;
+ /* If the dereferenced content could not be fetched do not
+ display anything. */
+ else if (except.error == NO_ENTRY_VALUE_ERROR)
+ val_equal = 1;
+ else if (except.message)
+ {
+ entryval_error = alloca (strlen (except.message) + 1);
+ strcpy (entryval_error, except.message);
+ }
+
+ if (val_equal)
+ entryval = NULL;
+ }
+ }
+
+ /* Try to remove possibly duplicate error message for ENTRYARGP even
+ in MI mode. */
+
+ if (val_error && entryval_error
+ && strcmp (val_error, entryval_error) == 0)
+ {
+ entryval_error = NULL;
+
+ /* Do not se VAL_EQUAL as the same error message may be shown for
+ the entry value even if no entry values are present in the
+ inferior. */
+ }
+ }
+ }
+
+ if (entryval == NULL)
+ {
+ if (print_entry_values == print_entry_values_preferred)
+ {
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ val = read_var_value (sym, frame);
+ }
+ if (!val)
+ {
+ val_error = alloca (strlen (except.message) + 1);
+ strcpy (val_error, except.message);
+ }
+ }
+ if (print_entry_values == print_entry_values_only
+ || print_entry_values == print_entry_values_both
+ || (print_entry_values == print_entry_values_preferred
+ && (!val || value_optimized_out (val))))
+ entryval = allocate_optimized_out_value (SYMBOL_TYPE (sym));
+ }
+ if ((print_entry_values == print_entry_values_compact
+ || print_entry_values == print_entry_values_if_needed
+ || print_entry_values == print_entry_values_preferred)
+ && (!val || value_optimized_out (val)) && entryval != NULL)
+ {
+ val = NULL;
+ val_error = NULL;
+ }
+
+ argp->sym = sym;
+ argp->val = val;
+ argp->error = val_error ? xstrdup (val_error) : NULL;
+ if (!val && !val_error)
+ argp->entry_kind = print_entry_values_only;
+ else if ((print_entry_values == print_entry_values_compact
+ || print_entry_values == print_entry_values_default) && val_equal)
+ {
+ argp->entry_kind = print_entry_values_compact;
+ gdb_assert (!ui_out_is_mi_like_p (current_uiout));
+ }
+ else
+ argp->entry_kind = print_entry_values_no;
+
+ entryargp->sym = sym;
+ entryargp->val = entryval;
+ entryargp->error = entryval_error ? xstrdup (entryval_error) : NULL;
+ if (!entryval && !entryval_error)
+ entryargp->entry_kind = print_entry_values_no;
+ else
+ entryargp->entry_kind = print_entry_values_only;
+}
+
/* Print the arguments of frame FRAME on STREAM, given the function
FUNC running in that frame (as a symbol), where NUM is the number
of arguments according to the stack frame (or -1 if the number of
print_frame_args (struct symbol *func, struct frame_info *frame,
int num, struct ui_file *stream)
{
+ struct ui_out *uiout = current_uiout;
int first = 1;
/* Offset of next stack argument beyond the one we have seen that is
at the highest offset, or -1 if we haven't come to a stack
struct block *b = SYMBOL_BLOCK_VALUE (func);
struct dict_iterator iter;
struct symbol *sym;
- struct value *val;
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
+ struct frame_arg arg, entryarg;
+
QUIT;
/* Keep track of the highest stack argument offset seen, and
ui_out_text (uiout, ", ");
ui_out_wrap_hint (uiout, " ");
- annotate_arg_begin ();
-
- list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym),
- SYMBOL_LANGUAGE (sym),
- DMGL_PARAMS | DMGL_ANSI);
- ui_out_field_stream (uiout, "name", stb);
- annotate_arg_name_end ();
- ui_out_text (uiout, "=");
-
- if (print_args)
- {
- /* Avoid value_print because it will deref ref parameters.
- We just want to print their addresses. Print ??? for
- args whose address we do not know. We pass 2 as
- "recurse" to val_print because our standard indentation
- here is 4 spaces, and val_print indents 2 for each
- recurse. */
- val = read_var_value (sym, frame);
+ if (!print_args)
+ {
+ memset (&arg, 0, sizeof (arg));
+ arg.sym = sym;
+ arg.entry_kind = print_entry_values_no;
+ memset (&entryarg, 0, sizeof (entryarg));
+ entryarg.sym = sym;
+ entryarg.entry_kind = print_entry_values_no;
+ }
+ else
+ read_frame_arg (sym, frame, &arg, &entryarg);
- annotate_arg_value (val == NULL ? NULL : value_type (val));
-
- if (val)
- {
- const struct language_defn *language;
- struct value_print_options opts;
-
- /* Use the appropriate language to display our symbol,
- unless the user forced the language to a specific
- language. */
- if (language_mode == language_mode_auto)
- language = language_def (SYMBOL_LANGUAGE (sym));
- else
- language = current_language;
-
- get_raw_print_options (&opts);
- opts.deref_ref = 0;
- opts.summary = summary;
- common_val_print (val, stb->stream, 2, &opts, language);
- ui_out_field_stream (uiout, "value", stb);
- }
- else
- ui_out_text (uiout, "???");
- }
- else
- ui_out_text (uiout, "...");
+ if (arg.entry_kind != print_entry_values_only)
+ print_frame_arg (&arg);
+ if (entryarg.entry_kind != print_entry_values_no)
+ {
+ if (arg.entry_kind != print_entry_values_only)
+ {
+ ui_out_text (uiout, ", ");
+ ui_out_wrap_hint (uiout, " ");
+ }
- /* Invoke ui_out_tuple_end. */
- do_cleanups (list_chain);
+ print_frame_arg (&entryarg);
+ }
- annotate_arg_end ();
+ xfree (arg.error);
+ xfree (entryarg.error);
first = 0;
}
do_cleanups (old_chain);
}
-/* Stub for catch_errors. */
-
-static int
-print_args_stub (void *args)
-{
- struct print_args_args *p = args;
- struct gdbarch *gdbarch = get_frame_arch (p->frame);
- int numargs;
-
- if (gdbarch_frame_num_args_p (gdbarch))
- {
- numargs = gdbarch_frame_num_args (gdbarch, p->frame);
- gdb_assert (numargs >= 0);
- }
- else
- numargs = -1;
- print_frame_args (p->func, p->frame, numargs, p->stream);
- return 0;
-}
-
/* Set the current source and line to the location given by frame
FRAME, if possible. When CENTER is true, adjust so the relevant
line is in the center of the next 'list'. */
value);
}
-/* Show assembly codes; stub for catch_errors. */
-
-struct gdb_disassembly_stub_args
-{
- struct gdbarch *gdbarch;
- int how_many;
- CORE_ADDR low;
- CORE_ADDR high;
-};
-
-static void
-gdb_disassembly_stub (void *args)
-{
- struct gdb_disassembly_stub_args *p = args;
-
- gdb_disassembly (p->gdbarch, uiout, 0,
- DISASSEMBLY_RAW_INSN, p->how_many,
- p->low, p->high);
-}
-
/* Use TRY_CATCH to catch the exception from the gdb_disassembly
because it will be broken by filter sometime. */
int how_many, CORE_ADDR low, CORE_ADDR high)
{
volatile struct gdb_exception exception;
- struct gdb_disassembly_stub_args args;
- args.gdbarch = gdbarch;
- args.how_many = how_many;
- args.low = low;
- args.high = high;
- TRY_CATCH (exception, RETURN_MASK_ALL)
+ TRY_CATCH (exception, RETURN_MASK_ERROR)
+ {
+ gdb_disassembly (gdbarch, current_uiout, 0,
+ DISASSEMBLY_RAW_INSN, how_many,
+ low, high);
+ }
+ if (exception.reason < 0)
{
- gdb_disassembly_stub (&args);
+ /* If an exception was thrown while doing the disassembly, print
+ the error message, to give the user a clue of what happened. */
+ exception_print (gdb_stderr, exception);
}
- /* If an exception was thrown while doing the disassembly, print
- the error message, to give the user a clue of what happened. */
- if (exception.reason == RETURN_ERROR)
- exception_print (gdb_stderr, exception);
}
/* Print information about frame FRAME. The output is format according
- to PRINT_LEVEL and PRINT_WHAT and PRINT ARGS. The meaning of
+ to PRINT_LEVEL and PRINT_WHAT and PRINT_ARGS. The meaning of
PRINT_WHAT is:
SRC_LINE: Print only source line.
struct symtab_and_line sal;
int source_print;
int location_print;
+ struct ui_out *uiout = current_uiout;
if (get_frame_type (frame) == DUMMY_FRAME
|| get_frame_type (frame) == SIGTRAMP_FRAME
CORE_ADDR pc;
if (get_frame_pc_if_available (frame, &pc))
- set_default_breakpoint (1, sal.pspace, pc, sal.symtab, sal.line);
+ set_last_displayed_sal (1, sal.pspace, pc, sal.symtab, sal.line);
else
- set_default_breakpoint (0, 0, 0, 0, 0);
+ set_last_displayed_sal (0, 0, 0, 0, 0);
}
annotate_frame_end ();
gdb_flush (gdb_stdout);
}
+/* Remember the last symtab and line we displayed, which we use e.g.
+ * as the place to put a breakpoint when the `break' command is
+ * invoked with no arguments. */
+
+static void
+set_last_displayed_sal (int valid, struct program_space *pspace,
+ CORE_ADDR addr, struct symtab *symtab,
+ int line)
+{
+ last_displayed_sal_valid = valid;
+ last_displayed_pspace = pspace;
+ last_displayed_addr = addr;
+ last_displayed_symtab = symtab;
+ last_displayed_line = line;
+}
+
+/* Forget the last sal we displayed. */
+
+void
+clear_last_displayed_sal (void)
+{
+ last_displayed_sal_valid = 0;
+ last_displayed_pspace = 0;
+ last_displayed_addr = 0;
+ last_displayed_symtab = 0;
+ last_displayed_line = 0;
+}
+
+/* Is our record of the last sal we displayed valid? If not,
+ * the get_last_displayed_* functions will return NULL or 0, as
+ * appropriate. */
+
+int
+last_displayed_sal_is_valid (void)
+{
+ return last_displayed_sal_valid;
+}
+
+/* Get the pspace of the last sal we displayed, if it's valid. */
+
+struct program_space *
+get_last_displayed_pspace (void)
+{
+ if (last_displayed_sal_valid)
+ return last_displayed_pspace;
+ return 0;
+}
+
+/* Get the address of the last sal we displayed, if it's valid. */
+
+CORE_ADDR
+get_last_displayed_addr (void)
+{
+ if (last_displayed_sal_valid)
+ return last_displayed_addr;
+ return 0;
+}
+
+/* Get the symtab of the last sal we displayed, if it's valid. */
+
+struct symtab*
+get_last_displayed_symtab (void)
+{
+ if (last_displayed_sal_valid)
+ return last_displayed_symtab;
+ return 0;
+}
+
+/* Get the line of the last sal we displayed, if it's valid. */
+
+int
+get_last_displayed_line (void)
+{
+ if (last_displayed_sal_valid)
+ return last_displayed_line;
+ return 0;
+}
+
+/* Get the last sal we displayed, if it's valid. */
+
+void
+get_last_displayed_sal (struct symtab_and_line *sal)
+{
+ if (last_displayed_sal_valid)
+ {
+ sal->pspace = last_displayed_pspace;
+ sal->pc = last_displayed_addr;
+ sal->symtab = last_displayed_symtab;
+ sal->line = last_displayed_line;
+ }
+ else
+ {
+ sal->pspace = 0;
+ sal->pc = 0;
+ sal->symtab = 0;
+ sal->line = 0;
+ }
+}
+
+
/* Attempt to obtain the FUNNAME, FUNLANG and optionally FUNCP of the function
corresponding to FRAME. */
struct symtab_and_line sal)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct ui_out *uiout = current_uiout;
char *funname = NULL;
enum language funlang = language_unknown;
struct ui_stream *stb;
ui_out_text (uiout, " (");
if (print_args)
{
- struct print_args_args args;
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int numargs;
struct cleanup *args_list_chain;
+ volatile struct gdb_exception e;
- args.frame = frame;
- args.func = func;
- args.stream = gdb_stdout;
+ if (gdbarch_frame_num_args_p (gdbarch))
+ {
+ numargs = gdbarch_frame_num_args (gdbarch, frame);
+ gdb_assert (numargs >= 0);
+ }
+ else
+ numargs = -1;
+
args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args");
- catch_errors (print_args_stub, &args, "", RETURN_MASK_ERROR);
+ TRY_CATCH (e, RETURN_MASK_ERROR)
+ {
+ print_frame_args (func, frame, numargs, gdb_stdout);
+ }
/* FIXME: ARGS must be a list. If one argument is a string it
will have " that will not be properly escaped. */
/* Invoke ui_out_tuple_end. */
int selected_frame_p;
struct gdbarch *gdbarch;
struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
+ CORE_ADDR frame_pc;
+ int frame_pc_p;
+ CORE_ADDR caller_pc;
fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p);
gdbarch = get_frame_arch (fi);
get_frame_pc(). */
pc_regname = "pc";
+ frame_pc_p = get_frame_pc_if_available (fi, &frame_pc);
find_frame_sal (fi, &sal);
func = get_frame_function (fi);
- /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain
- the same value? */
- s = find_pc_symtab (get_frame_pc (fi));
+ s = sal.symtab;
if (func)
{
funname = SYMBOL_PRINT_NAME (func);
}
}
}
- else
+ else if (frame_pc_p)
{
struct minimal_symbol *msymbol;
- msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
+ msymbol = lookup_minimal_symbol_by_pc (frame_pc);
if (msymbol != NULL)
{
funname = SYMBOL_PRINT_NAME (msymbol);
fputs_filtered (paddress (gdbarch, get_frame_base (fi)), gdb_stdout);
printf_filtered (":\n");
printf_filtered (" %s = ", pc_regname);
- fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout);
+ if (frame_pc_p)
+ fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout);
+ else
+ fputs_filtered ("<unavailable>", gdb_stdout);
wrap_here (" ");
if (funname)
puts_filtered ("; ");
wrap_here (" ");
printf_filtered ("saved %s ", pc_regname);
- fputs_filtered (paddress (gdbarch, frame_unwind_caller_pc (fi)), gdb_stdout);
+ if (frame_unwind_caller_pc_if_available (fi, &caller_pc))
+ fputs_filtered (paddress (gdbarch, caller_pc), gdb_stdout);
+ else
+ fputs_filtered ("<unavailable>", gdb_stdout);
printf_filtered ("\n");
if (calling_frame_info == NULL)
printf_filtered (_(" Outermost frame: %s\n"),
frame_stop_reason_string (reason));
}
+ else if (get_frame_type (fi) == TAILCALL_FRAME)
+ puts_filtered (" tail call frame");
else if (get_frame_type (fi) == INLINE_FRAME)
printf_filtered (" inlined into frame %d",
frame_relative_level (get_prev_frame (fi)));
enum unwind_stop_reason reason;
reason = get_frame_unwind_stop_reason (trailing);
- if (reason > UNWIND_FIRST_ERROR)
+ if (reason >= UNWIND_FIRST_ERROR)
printf_filtered (_("Backtrace stopped: %s\n"),
frame_stop_reason_string (reason));
}
}
-struct backtrace_command_args
-{
- char *count_exp;
- int show_locals;
- int from_tty;
-};
-
-/* Stub for catch_errors. */
-
-static int
-backtrace_command_stub (void *data)
-{
- struct backtrace_command_args *args = data;
-
- backtrace_command_1 (args->count_exp, args->show_locals, args->from_tty);
- return 0;
-}
-
static void
backtrace_command (char *arg, int from_tty)
{
- struct cleanup *old_chain = NULL;
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
int fulltrace_arg = -1, arglen = 0, argc = 0;
- struct backtrace_command_args btargs;
if (arg)
{
int i;
argv = gdb_buildargv (arg);
- old_chain = make_cleanup_freeargv (argv);
+ make_cleanup_freeargv (argv);
argc = 0;
for (i = 0; argv[i]; i++)
{
if (arglen > 0)
{
arg = xmalloc (arglen + 1);
- memset (arg, 0, arglen + 1);
+ make_cleanup (xfree, arg);
+ arg[0] = 0;
for (i = 0; i < (argc + 1); i++)
{
if (i != fulltrace_arg)
}
}
- btargs.count_exp = arg;
- btargs.show_locals = (fulltrace_arg >= 0);
- btargs.from_tty = from_tty;
- catch_errors (backtrace_command_stub, &btargs, "", RETURN_MASK_ERROR);
+ backtrace_command_1 (arg, fulltrace_arg >= 0 /* show_locals */, from_tty);
- if (fulltrace_arg >= 0 && arglen > 0)
- xfree (arg);
-
- if (old_chain)
- do_cleanups (old_chain);
+ do_cleanups (old_chain);
}
static void
backtrace_full_command (char *arg, int from_tty)
{
- struct backtrace_command_args btargs;
-
- btargs.count_exp = arg;
- btargs.show_locals = 1;
- btargs.from_tty = from_tty;
- catch_errors (backtrace_command_stub, &btargs, "", RETURN_MASK_ERROR);
+ backtrace_command_1 (arg, 1 /* show_locals */, from_tty);
}
\f
{
struct print_variable_and_value_data cb_data;
struct block *block;
+ CORE_ADDR pc;
+
+ if (!get_frame_pc_if_available (frame, &pc))
+ {
+ fprintf_filtered (stream,
+ _("PC unavailable, cannot determine locals.\n"));
+ return;
+ }
block = get_frame_block (frame, 0);
if (block == 0)
{
struct print_variable_and_value_data cb_data;
struct symbol *func;
+ CORE_ADDR pc;
+
+ if (!get_frame_pc_if_available (frame, &pc))
+ {
+ fprintf_filtered (stream, _("PC unavailable, cannot determine args.\n"));
+ return;
+ }
func = get_frame_function (frame);
if (func == NULL)
show_disassemble_next_line,
&setlist, &showlist);
disassemble_next_line = AUTO_BOOLEAN_FALSE;
+
+ add_setshow_enum_cmd ("entry-values", class_stack,
+ print_entry_values_choices, &print_entry_values,
+ _("Set printing of function arguments at function "
+ "entry"),
+ _("Show printing of function arguments at function "
+ "entry"),
+ _("\
+GDB can sometimes determine the values of function arguments at entry,\n\
+in addition to their current values. This option tells GDB whether\n\
+to print the current value, the value at entry (marked as val@entry),\n\
+or both. Note that one or both of these values may be <optimized out>."),
+ NULL, NULL, &setprintlist, &showprintlist);
}