Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008 Free Software Foundation, Inc.
+ 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
{
/* Chain link to next auto-display item. */
struct display *next;
+ /* The expression as the user typed it. */
+ char *exp_string;
/* Expression to be evaluated and displayed. */
struct expression *exp;
/* Item number of this auto-display item. */
&& sect_addr < obj_section_endaddr (osect)
&& (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect)))
{
+ const char *obj_name, *mapped, *sec_name, *msym_name;
+ char *loc_string;
+ struct cleanup *old_chain;
+
matches = 1;
offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol);
+ mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped");
+ sec_name = osect->the_bfd_section->name;
+ msym_name = SYMBOL_PRINT_NAME (msymbol);
+
+ /* Don't print the offset if it is zero.
+ We assume there's no need to handle i18n of "sym + offset". */
if (offset)
- printf_filtered ("%s + %u in ",
- SYMBOL_PRINT_NAME (msymbol), offset);
+ xasprintf (&loc_string, "%s + %u", msym_name, offset);
else
- printf_filtered ("%s in ",
- SYMBOL_PRINT_NAME (msymbol));
- if (pc_in_unmapped_range (addr, osect))
- printf_filtered (_("load address range of "));
- if (section_is_overlay (osect))
- printf_filtered (_("%s overlay "),
- section_is_mapped (osect) ? "mapped" : "unmapped");
- printf_filtered (_("section %s"), osect->the_bfd_section->name);
- printf_filtered ("\n");
+ xasprintf (&loc_string, "%s", msym_name);
+
+ /* Use a cleanup to free loc_string in case the user quits
+ a pagination request inside printf_filtered. */
+ old_chain = make_cleanup (xfree, loc_string);
+
+ gdb_assert (osect->objfile && osect->objfile->name);
+ obj_name = osect->objfile->name;
+
+ if (MULTI_OBJFILE_P ())
+ if (pc_in_unmapped_range (addr, osect))
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s in load address range of "
+ "%s overlay section %s of %s\n"),
+ loc_string, mapped, sec_name, obj_name);
+ else
+ printf_filtered (_("%s in load address range of "
+ "section %s of %s\n"),
+ loc_string, sec_name, obj_name);
+ else
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s in %s overlay section %s of %s\n"),
+ loc_string, mapped, sec_name, obj_name);
+ else
+ printf_filtered (_("%s in section %s of %s\n"),
+ loc_string, sec_name, obj_name);
+ else
+ if (pc_in_unmapped_range (addr, osect))
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s in load address range of %s overlay "
+ "section %s\n"),
+ loc_string, mapped, sec_name);
+ else
+ printf_filtered (_("%s in load address range of section %s\n"),
+ loc_string, sec_name);
+ else
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s in %s overlay section %s\n"),
+ loc_string, mapped, sec_name);
+ else
+ printf_filtered (_("%s in section %s\n"),
+ loc_string, sec_name);
+
+ do_cleanups (old_chain);
}
}
if (matches == 0)
else
{
section = SYMBOL_OBJ_SECTION (msym);
- printf_filtered (_("static storage at address "));
load_addr = SYMBOL_VALUE_ADDRESS (msym);
- fputs_filtered (paddress (load_addr), gdb_stdout);
- if (section_is_overlay (section))
+
+ if (section
+ && (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
+ printf_filtered (_("a thread-local variable at offset %s "
+ "in the thread-local storage for `%s'"),
+ paddr_nz (load_addr), section->objfile->name);
+ else
{
- load_addr = overlay_unmapped_address (load_addr, section);
- printf_filtered (_(",\n -- loaded at "));
+ printf_filtered (_("static storage at address "));
fputs_filtered (paddress (load_addr), gdb_stdout);
- printf_filtered (_(" in overlay section %s"),
- section->the_bfd_section->name);
+ if (section_is_overlay (section))
+ {
+ load_addr = overlay_unmapped_address (load_addr, section);
+ printf_filtered (_(",\n -- loaded at "));
+ fputs_filtered (paddress (load_addr), gdb_stdout);
+ printf_filtered (_(" in overlay section %s"),
+ section->the_bfd_section->name);
+ }
}
}
}
new = (struct display *) xmalloc (sizeof (struct display));
+ new->exp_string = xstrdup (exp);
new->exp = expr;
new->block = innermost_block;
new->next = display_chain;
static void
free_display (struct display *d)
{
+ xfree (d->exp_string);
xfree (d->exp);
xfree (d);
}
while ((d = display_chain) != NULL)
{
- xfree (d->exp);
display_chain = d->next;
- xfree (d);
+ free_display (d);
}
}
annotate_display_expression ();
- print_expression (d->exp, gdb_stdout);
+ puts_filtered (d->exp_string);
annotate_display_expression_end ();
if (d->format.count != 1 || d->format.format == 'i')
annotate_display_expression ();
- print_expression (d->exp, gdb_stdout);
+ puts_filtered (d->exp_string);
annotate_display_expression_end ();
printf_filtered (" = ");
d->format.format);
else if (d->format.format)
printf_filtered ("/%c ", d->format.format);
- print_expression (d->exp, gdb_stdout);
+ puts_filtered (d->exp_string);
if (d->block && !contained_in (get_selected_block (0), d->block))
printf_filtered (_(" (cannot be evaluated in the current context)"));
printf_filtered ("\n");
\f
/* Print the value in stack frame FRAME of a variable specified by a
- struct symbol. */
+ struct symbol. NAME is the name to print; if NULL then VAR's print
+ name will be used. STREAM is the ui_file on which to print the
+ value. INDENT specifies the number of indent levels to print
+ before printing the variable name. */
void
-print_variable_value (struct symbol *var, struct frame_info *frame,
- struct ui_file *stream)
+print_variable_and_value (const char *name, struct symbol *var,
+ struct frame_info *frame,
+ struct ui_file *stream, int indent)
{
- struct value *val = read_var_value (var, frame);
+ struct value *val;
struct value_print_options opts;
+ if (!name)
+ name = SYMBOL_PRINT_NAME (var);
+
+ fprintf_filtered (stream, "%s%s = ", n_spaces (2 * indent), name);
+
+ val = read_var_value (var, frame);
get_user_print_options (&opts);
- value_print (val, stream, &opts);
+ common_val_print (val, stream, indent, &opts, current_language);
+ fprintf_filtered (stream, "\n");
}
static void