[RFA] backtrace in mixed language applications (take 2)
Joel Brobecker
brobecker@adacore.com
Mon Feb 4 21:04:00 GMT 2008
[with the patch, this time]
> > common_val_print (val, stb->stream, 0, 0, 2,
> > - Val_no_prettyprint);
> > + Val_no_prettyprint,
> > + language_def (SYMBOL_LANGUAGE (sym)));
> > ui_out_field_stream (uiout, "value", stb);
> > }
> > else
>
> The patch looks sane to me, except for this, which ignores "set
> language" - compare to the code in select_frame. Do you think we
> ought to honor it here if it's been set?
Good catch. I don't have any clear reason why we should change
the previous behavior in this case, so I've tweaked the previous
patch to honor "set language". I also added a test in the new
testcase to verify this. The rest of the patch should be identical.
2008-02-04 Joel Brobecker <brobecker@adacore.com>
* valprint.c (val_print): Add new language parameter and use it
instead of using the current_language. Update calls to val_print
throughout.
(common_val_print): Add new langauge parameter and pass it to
val_print.
* value.h (struct language_defn): Add opaque declaration.
(val_print, common_val_print): Update declarations.
* stack.c (print_frame_args): Update call to common_val_print
using the appropriate language.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* c-valprint, f-valprint.c, m2-valprint.c, mt-tdep.c, infcmd.c,
mi/mi-main.c, jv-valprint.c, ada-valprint.c, varobj.c, p-valprint.c,
scm-valprint.c, cp-valprint.c, sh64-tdep.c, printcmd.c:
#include "language.h" if necessary.
Update calls to val_print and common_val_print.
* Makefile.in (mt-tdep.o, sh64-tdep.o, mi-cmds.o, mi-main.o):
Update dependencies.
2008-02-04 Jerome Guitton <guitton@adacore.com>
Joel Brobecker <brobecker@adacore.com>
* gdb.ada/lang_switch: New test program.
* gdb.ada/lang_switch.exp: New testcase.
Tested on x86-linux. No regression.
OK to apply?
Thanks,
--
Joel
-------------- next part --------------
Index: valprint.c
===================================================================
--- valprint.c (revision 161)
+++ valprint.c (revision 162)
@@ -180,9 +180,10 @@ show_addressprint (struct ui_file *file,
}
-/* Print data of type TYPE located at VALADDR (within GDB), which came from
- the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter, or 0 for natural format using TYPE).
+/* Print using the given LANGUAGE the data of type TYPE located at VALADDR
+ (within GDB), which came from the inferior at address ADDRESS, onto
+ stdio stream STREAM according to FORMAT (a letter, or 0 for natural
+ format using TYPE).
If DEREF_REF is nonzero, then dereference references, otherwise just print
them like pointers.
@@ -203,7 +204,8 @@ show_addressprint (struct ui_file *file,
int
val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ int deref_ref, int recurse, enum val_prettyprint pretty,
+ const struct language_defn *language)
{
volatile struct gdb_exception except;
volatile enum val_prettyprint real_pretty = pretty;
@@ -228,8 +230,9 @@ val_print (struct type *type, const gdb_
TRY_CATCH (except, RETURN_MASK_ERROR)
{
- ret = LA_VAL_PRINT (type, valaddr, embedded_offset, address,
- stream, format, deref_ref, recurse, real_pretty);
+ ret = language->la_val_print (type, valaddr, embedded_offset, address,
+ stream, format, deref_ref, recurse,
+ real_pretty);
}
if (except.reason < 0)
fprintf_filtered (stream, _("<error reading variable>"));
@@ -259,8 +262,8 @@ value_check_printable (struct value *val
return 1;
}
-/* Print the value VAL onto stream STREAM according to FORMAT (a
- letter, or 0 for natural format using TYPE).
+/* Print using the given LANGUAGE the value VAL onto stream STREAM according
+ to FORMAT (a letter, or 0 for natural format using TYPE).
If DEREF_REF is nonzero, then dereference references, otherwise just print
them like pointers.
@@ -275,14 +278,16 @@ value_check_printable (struct value *val
int
common_val_print (struct value *val, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ int deref_ref, int recurse, enum val_prettyprint pretty,
+ const struct language_defn *language)
{
if (!value_check_printable (val, stream))
return 0;
return val_print (value_type (val), value_contents_all (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stream, format, deref_ref, recurse, pretty);
+ stream, format, deref_ref, recurse, pretty,
+ language);
}
/* Print the value VAL in C-ish syntax on stream STREAM.
@@ -1061,7 +1066,7 @@ val_print_array_elements (struct type *t
if (reps > repeat_count_threshold)
{
val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
- deref_ref, recurse + 1, pretty);
+ deref_ref, recurse + 1, pretty, current_language);
annotate_elt_rep (reps);
fprintf_filtered (stream, " <repeats %u times>", reps);
annotate_elt_rep_end ();
@@ -1072,7 +1077,7 @@ val_print_array_elements (struct type *t
else
{
val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
- deref_ref, recurse + 1, pretty);
+ deref_ref, recurse + 1, pretty, current_language);
annotate_elt ();
things_printed++;
}
Index: value.h
===================================================================
--- value.h (revision 161)
+++ value.h (revision 162)
@@ -31,6 +31,7 @@ struct regcache;
struct symbol;
struct type;
struct ui_file;
+struct language_defn;
/* The structure which defines the type of a value. It should never
be possible for a program lval value to survive over a call to the
@@ -511,12 +512,14 @@ extern int val_print (struct type *type,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int format,
int deref_ref, int recurse,
- enum val_prettyprint pretty);
+ enum val_prettyprint pretty,
+ const struct language_defn *language);
extern int common_val_print (struct value *val,
struct ui_file *stream, int format,
int deref_ref, int recurse,
- enum val_prettyprint pretty);
+ enum val_prettyprint pretty,
+ const struct language_defn *language);
extern int val_print_string (CORE_ADDR addr, int len, int width,
struct ui_file *stream);
Index: c-valprint.c
===================================================================
--- c-valprint.c (revision 161)
+++ c-valprint.c (revision 162)
@@ -276,7 +276,8 @@ c_val_print (struct type *type, const gd
}
vt_val = value_at (wtype, vt_address);
common_val_print (vt_val, stream, format,
- deref_ref, recurse + 1, pretty);
+ deref_ref, recurse + 1, pretty,
+ current_language);
if (pretty)
{
fprintf_filtered (stream, "\n");
@@ -314,7 +315,7 @@ c_val_print (struct type *type, const gd
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty);
+ recurse, pretty, current_language);
}
else
fputs_filtered ("???", stream);
@@ -620,7 +621,8 @@ c_value_print (struct value *val, struct
/* Print out object: enclosing type is same as real_type if full */
return val_print (value_enclosing_type (val),
value_contents_all (val), 0,
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
+ VALUE_ADDRESS (val), stream, format, 1, 0,
+ pretty, current_language);
/* Note: When we look up RTTI entries, we don't get any information on
const or volatile attributes */
}
@@ -631,7 +633,8 @@ c_value_print (struct value *val, struct
TYPE_NAME (value_enclosing_type (val)));
return val_print (value_enclosing_type (val),
value_contents_all (val), 0,
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
+ VALUE_ADDRESS (val), stream, format, 1, 0,
+ pretty, current_language);
}
/* Otherwise, we end up at the return outside this "if" */
}
@@ -639,5 +642,5 @@ c_value_print (struct value *val, struct
return val_print (type, value_contents_all (val),
value_embedded_offset (val),
VALUE_ADDRESS (val) + value_offset (val),
- stream, format, 1, 0, pretty);
+ stream, format, 1, 0, pretty, current_language);
}
Index: f-valprint.c
===================================================================
--- f-valprint.c (revision 161)
+++ f-valprint.c (revision 162)
@@ -308,7 +308,8 @@ f77_print_array_1 (int nss, int ndimensi
valaddr + i * F77_DIM_OFFSET (ndimensions),
0,
address + i * F77_DIM_OFFSET (ndimensions),
- stream, format, deref_ref, recurse, pretty);
+ stream, format, deref_ref, recurse, pretty,
+ current_language);
if (i != (F77_DIM_SIZE (nss) - 1))
fprintf_filtered (stream, ", ");
@@ -446,7 +447,7 @@ f_val_print (struct type *type, const gd
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref, recurse,
- pretty);
+ pretty, current_language);
}
else
fputs_filtered ("???", stream);
Index: m2-valprint.c
===================================================================
--- m2-valprint.c (revision 161)
+++ m2-valprint.c (revision 162)
@@ -263,7 +263,7 @@ print_variable_at_address (struct type *
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr));
common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty);
+ recurse, pretty, current_language);
}
else
fputs_filtered ("???", stream);
@@ -423,7 +423,7 @@ m2_val_print (struct type *type, const g
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty);
+ recurse, pretty, current_language);
}
else
fputs_filtered ("???", stream);
Index: mt-tdep.c
===================================================================
--- mt-tdep.c (revision 161)
+++ mt-tdep.c (revision 162)
@@ -36,6 +36,7 @@
#include "dwarf2-frame.h"
#include "infcall.h"
#include "gdb_assert.h"
+#include "language.h"
enum mt_arch_constants
{
@@ -691,7 +692,8 @@ mt_registers_info (struct gdbarch *gdbar
(gdbarch, regnum)),
file);
val_print (register_type (gdbarch, regnum), buf,
- 0, 0, file, 0, 1, 0, Val_no_prettyprint);
+ 0, 0, file, 0, 1, 0, Val_no_prettyprint,
+ current_language);
fputs_filtered ("\n", file);
}
else if (regnum == MT_MAC_REGNUM || regnum == MT_MAC_PSEUDOREG_REGNUM)
Index: infcmd.c
===================================================================
--- infcmd.c (revision 161)
+++ infcmd.c (revision 162)
@@ -1629,7 +1629,7 @@ default_print_registers_info (struct gdb
int j;
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default);
+ file, 0, 1, 0, Val_pretty_default, current_language);
fprintf_filtered (file, "\t(raw 0x");
for (j = 0; j < register_size (gdbarch, i); j++)
@@ -1647,14 +1647,14 @@ default_print_registers_info (struct gdb
{
/* Print the register in hex. */
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 'x', 1, 0, Val_pretty_default);
+ file, 'x', 1, 0, Val_pretty_default, current_language);
/* If not a vector register, print it also according to its
natural format. */
if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
{
fprintf_filtered (file, "\t");
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default);
+ file, 0, 1, 0, Val_pretty_default, current_language);
}
}
Index: mi/mi-cmd-stack.c
===================================================================
--- mi/mi-cmd-stack.c (revision 161)
+++ mi/mi-cmd-stack.c (revision 162)
@@ -29,6 +29,7 @@
#include "stack.h"
#include "dictionary.h"
#include "gdb_string.h"
+#include "language.h"
static void list_args_or_locals (int locals, int values, struct frame_info *fi);
@@ -298,7 +299,8 @@ list_args_or_locals (int locals, int val
{
val = read_var_value (sym2, fi);
common_val_print
- (val, stb->stream, 0, 1, 0, Val_no_prettyprint);
+ (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+ language_def (SYMBOL_LANGUAGE (sym2)));
ui_out_field_stream (uiout, "value", stb);
}
do_cleanups (cleanup_tuple);
@@ -306,7 +308,8 @@ list_args_or_locals (int locals, int val
case PRINT_ALL_VALUES:
val = read_var_value (sym2, fi);
common_val_print
- (val, stb->stream, 0, 1, 0, Val_no_prettyprint);
+ (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+ language_def (SYMBOL_LANGUAGE (sym2)));
ui_out_field_stream (uiout, "value", stb);
do_cleanups (cleanup_tuple);
break;
Index: mi/mi-main.c
===================================================================
--- mi/mi-main.c (revision 161)
+++ mi/mi-main.c (revision 162)
@@ -44,6 +44,7 @@
#include "gdb.h"
#include "frame.h"
#include "mi-main.h"
+#include "language.h"
#include <ctype.h>
#include <sys/time.h>
@@ -567,7 +568,8 @@ get_register (int regnum, int format)
else
{
val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
- stb->stream, format, 1, 0, Val_pretty_default);
+ stb->stream, format, 1, 0, Val_pretty_default,
+ current_language);
ui_out_field_stream (uiout, "value", stb);
ui_out_stream_delete (stb);
}
@@ -672,7 +674,7 @@ mi_cmd_data_evaluate_expression (char *c
/* Print the result of the expression evaluation. */
val_print (value_type (val), value_contents (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stb->stream, 0, 0, 0, 0);
+ stb->stream, 0, 0, 0, 0, current_language);
ui_out_field_stream (uiout, "value", stb);
ui_out_stream_delete (stb);
Index: jv-valprint.c
===================================================================
--- jv-valprint.c (revision 161)
+++ jv-valprint.c (revision 162)
@@ -180,7 +180,8 @@ java_value_print (struct value *val, str
else
fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
- common_val_print (v, stream, format, 2, 1, pretty);
+ common_val_print (v, stream, format, 2, 1, pretty,
+ current_language);
things_printed++;
i += reps;
@@ -232,7 +233,8 @@ java_value_print (struct value *val, str
return 0;
}
- return common_val_print (val, stream, format, 1, 0, pretty);
+ return common_val_print (val, stream, format, 1, 0, pretty,
+ current_language);
}
/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
@@ -380,7 +382,8 @@ java_print_value_fields (struct type *ty
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- common_val_print (v, stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1,
+ pretty, current_language);
}
}
else
@@ -400,7 +403,7 @@ java_print_value_fields (struct type *ty
if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
v = value_addr (v);
common_val_print (v, stream, format, 0, recurse + 1,
- pretty);
+ pretty, current_language);
}
}
else if (TYPE_FIELD_TYPE (type, i) == NULL)
@@ -410,7 +413,8 @@ java_print_value_fields (struct type *ty
val_print (TYPE_FIELD_TYPE (type, i),
valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty);
+ stream, format, 0, recurse + 1, pretty,
+ current_language);
}
}
annotate_field_end ();
Index: ada-valprint.c
===================================================================
--- ada-valprint.c (revision 161)
+++ ada-valprint.c (revision 162)
@@ -201,7 +201,7 @@ val_print_packed_array_elements (struct
if (i - i0 > repeat_count_threshold)
{
val_print (elttype, value_contents (v0), 0, 0, stream, format,
- 0, recurse + 1, pretty);
+ 0, recurse + 1, pretty, current_language);
annotate_elt_rep (i - i0);
fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
annotate_elt_rep_end ();
@@ -228,7 +228,7 @@ val_print_packed_array_elements (struct
stream, format, pretty);
}
val_print (elttype, value_contents (v0), 0, 0, stream, format,
- 0, recurse + 1, pretty);
+ 0, recurse + 1, pretty, current_language);
annotate_elt ();
}
}
@@ -876,7 +876,7 @@ ada_val_print_1 (struct type *type, cons
val_print (value_type (deref_val),
value_contents (deref_val), 0,
VALUE_ADDRESS (deref_val), stream, format,
- deref_ref, recurse + 1, pretty);
+ deref_ref, recurse + 1, pretty, current_language);
}
else
fputs_filtered ("(null)", stream);
@@ -966,7 +966,7 @@ ada_value_print (struct value *val0, str
}
return (val_print (type, value_contents (val), 0, address,
- stream, format, 1, 0, pretty));
+ stream, format, 1, 0, pretty, current_language));
}
static void
@@ -1096,7 +1096,8 @@ print_field_values (struct type *type, c
bit_size,
TYPE_FIELD_TYPE (type, i));
val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
- stream, format, 0, recurse + 1, pretty);
+ stream, format, 0, recurse + 1, pretty,
+ current_language);
}
}
else
Index: varobj.c
===================================================================
--- varobj.c (revision 161)
+++ varobj.c (revision 162)
@@ -1808,7 +1808,8 @@ value_get_print_value (struct value *val
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
- common_val_print (value, stb, format_code[(int) format], 1, 0, 0);
+ common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
+ current_language);
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);
Index: p-valprint.c
===================================================================
--- p-valprint.c (revision 161)
+++ p-valprint.c (revision 162)
@@ -231,7 +231,7 @@ pascal_val_print (struct type *type, con
}
vt_val = value_at (wtype, vt_address);
common_val_print (vt_val, stream, format, deref_ref,
- recurse + 1, pretty);
+ recurse + 1, pretty, current_language);
if (pretty)
{
fprintf_filtered (stream, "\n");
@@ -270,7 +270,7 @@ pascal_val_print (struct type *type, con
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
common_val_print (deref_val, stream, format, deref_ref,
- recurse + 1, pretty);
+ recurse + 1, pretty, current_language);
}
else
fputs_filtered ("???", stream);
@@ -548,7 +548,8 @@ pascal_value_print (struct value *val, s
fprintf_filtered (stream, ") ");
}
}
- return common_val_print (val, stream, format, 1, 0, pretty);
+ return common_val_print (val, stream, format, 1, 0, pretty,
+ current_language);
}
@@ -743,7 +744,8 @@ pascal_object_print_value_fields (struct
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- common_val_print (v, stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1,
+ pretty, current_language);
}
}
else
@@ -774,7 +776,8 @@ pascal_object_print_value_fields (struct
val_print (TYPE_FIELD_TYPE (type, i),
valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty);
+ stream, format, 0, recurse + 1, pretty,
+ current_language);
}
}
annotate_field_end ();
@@ -941,7 +944,8 @@ pascal_object_print_static_field (struct
stream, format, recurse, pretty, NULL, 1);
return;
}
- common_val_print (val, stream, format, 0, recurse, pretty);
+ common_val_print (val, stream, format, 0, recurse, pretty,
+ current_language);
}
extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
Index: scm-valprint.c
===================================================================
--- scm-valprint.c (revision 161)
+++ scm-valprint.c (revision 162)
@@ -432,5 +432,6 @@ int
scm_value_print (struct value *val, struct ui_file *stream, int format,
enum val_prettyprint pretty)
{
- return (common_val_print (val, stream, format, 1, 0, pretty));
+ return (common_val_print (val, stream, format, 1, 0, pretty,
+ current_language));
}
Index: Makefile.in
===================================================================
--- Makefile.in (revision 161)
+++ Makefile.in (revision 162)
@@ -2504,7 +2504,7 @@ mt-tdep.o: mt-tdep.c $(defs_h) $(frame_h
$(symtab_h) $(dis_asm_h) $(arch_utils_h) $(gdbtypes_h) \
$(gdb_string_h) $(regcache_h) $(reggroups_h) $(gdbcore_h) \
$(trad_frame_h) $(inferior_h) $(dwarf2_frame_h) $(infcall_h) \
- $(gdb_assert_h)
+ $(gdb_assert_h) $(language_h)
nbsd-nat.o: nbsd-nat.c $(defs_h) $(nbsd_nat_h)
nbsd-tdep.o: nbsd-tdep.c $(defs_h) $(gdb_string_h) $(solib_svr4_h)
nto-procfs.o: nto-procfs.c $(defs_h) $(gdb_dirent_h) $(exceptions_h) \
@@ -2685,7 +2685,7 @@ sh64-tdep.o: sh64-tdep.c $(defs_h) $(fra
$(frame_unwind_h) $(dwarf2_frame_h) $(symtab_h) $(gdbtypes_h) \
$(gdbcmd_h) $(gdbcore_h) $(value_h) $(dis_asm_h) $(inferior_h) \
$(gdb_string_h) $(gdb_assert_h) $(arch_utils_h) $(regcache_h) \
- $(osabi_h) $(elf_bfd_h) $(elf_sh_h) $(gdb_sim_sh_h)
+ $(osabi_h) $(elf_bfd_h) $(elf_sh_h) $(gdb_sim_sh_h) $(language_h)
shnbsd-nat.o: shnbsd-nat.c $(defs_h) $(inferior_h) $(sh_tdep_h) \
$(shnbsd_tdep_h) $(inf_ptrace_h) $(regcache_h)
shnbsd-tdep.o: shnbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) $(regset_h) \
@@ -3193,7 +3193,7 @@ mi-cmds.o: $(srcdir)/mi/mi-cmds.c $(defs
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmds.c
mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
$(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h) $(block_h) \
- $(stack_h) $(dictionary_h) $(gdb_string_h)
+ $(stack_h) $(dictionary_h) $(gdb_string_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
mi-cmd-target.o: $(srcdir)/mi/mi-cmd-target.c $(defs_h) $(mi_cmds_h) \
$(mi_getopt_h) $(remote_h)
@@ -3216,7 +3216,7 @@ mi-main.o: $(srcdir)/mi/mi-main.c $(defs
$(gdb_string_h) $(exceptions_h) $(top_h) $(gdbthread_h) $(mi_cmds_h) \
$(mi_parse_h) $(mi_getopt_h) $(mi_console_h) $(ui_out_h) $(mi_out_h) \
$(interps_h) $(event_loop_h) $(event_top_h) $(gdbcore_h) $(value_h) \
- $(regcache_h) $(gdb_h) $(frame_h) $(mi_main_h)
+ $(regcache_h) $(gdb_h) $(frame_h) $(mi_main_h) $(language_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-main.c
mi-out.o: $(srcdir)/mi/mi-out.c $(defs_h) $(ui_out_h) $(mi_out_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-out.c
Index: stack.c
===================================================================
--- stack.c (revision 161)
+++ stack.c (revision 162)
@@ -365,8 +365,18 @@ print_frame_args (struct symbol *func, s
if (val)
{
+ const struct language_defn *language;
+
+ /* 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;
+
common_val_print (val, stb->stream, 0, 0, 2,
- Val_no_prettyprint);
+ Val_no_prettyprint, language);
ui_out_field_stream (uiout, "value", stb);
}
else
Index: cp-valprint.c
===================================================================
--- cp-valprint.c (revision 161)
+++ cp-valprint.c (revision 162)
@@ -267,7 +267,8 @@ cp_print_value_fields (struct type *type
(TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr + offset, i));
- common_val_print (v, stream, format, 0, recurse + 1, pretty);
+ common_val_print (v, stream, format, 0, recurse + 1, pretty,
+ current_language);
}
}
else
@@ -291,7 +292,8 @@ cp_print_value_fields (struct type *type
val_print (TYPE_FIELD_TYPE (type, i),
valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty);
+ stream, format, 0, recurse + 1, pretty,
+ current_language);
}
}
annotate_field_end ();
@@ -485,7 +487,7 @@ cp_print_static_field (struct type *type
}
val_print (type, value_contents_all (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stream, format, 0, recurse, pretty);
+ stream, format, 0, recurse, pretty, current_language);
}
Index: sh64-tdep.c
===================================================================
--- sh64-tdep.c (revision 161)
+++ sh64-tdep.c (revision 162)
@@ -47,6 +47,7 @@
#include "elf/sh.h"
/* registers numbers shared with the simulator */
#include "gdb/sim-sh.h"
+#include "language.h"
/* Information that is dependent on the processor variant. */
enum sh_abi
@@ -2109,10 +2110,10 @@ sh64_do_register (struct gdbarch *gdbarc
fprintf_filtered (file, "*value not available*\n");
val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
- file, 'x', 1, 0, Val_pretty_default);
+ file, 'x', 1, 0, Val_pretty_default, current_language);
fprintf_filtered (file, "\t");
val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default);
+ file, 0, 1, 0, Val_pretty_default, current_language);
fprintf_filtered (file, "\n");
}
Index: printcmd.c
===================================================================
--- printcmd.c (revision 161)
+++ printcmd.c (revision 162)
@@ -321,7 +321,8 @@ print_scalar_formatted (const void *vala
again. */
if (format == 's')
{
- val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default);
+ val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+ current_language);
return;
}
-------------- next part --------------
Index: gdb.ada/lang_switch.exp
===================================================================
--- gdb.ada/lang_switch.exp (revision 0)
+++ gdb.ada/lang_switch.exp (revision 160)
@@ -0,0 +1,56 @@
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "ada.exp"
+
+set testdir "lang_switch"
+set testfile "${testdir}/lang_switch"
+set cfile "${testdir}/foo"
+set adasrcfile ${srcdir}/${subdir}/${testfile}.adb
+set csrcfile ${srcdir}/${subdir}/${cfile}.c
+set cobject ${objdir}/${subdir}/${cfile}.o
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+gdb_compile "${csrcfile}" "${cobject}" object [list debug]
+if {[gdb_compile_ada "${adasrcfile}" "${binfile}" executable [list debug]] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.c]
+runto "foo.c:$bp_location"
+
+# Make sure that the language is switched to Ada for the second frame
+# by checking the string parameter.
+gdb_test "bt" \
+ ".*#1.*lang_switch\\.ada_procedure\\s*\\(msg=$hex\\).*" \
+ "backtrace"
+
+# Now, make sure that the language doesn't get automatically switched
+# if the current language is not "auto".
+gdb_test "set lang c"
+gdb_test "bt" \
+ ".*#1.*lang_switch\\.ada_procedure\\s*\\(msg={.*\\).*" \
+ "backtrace"
+
Index: gdb.ada/lang_switch/foo.c
===================================================================
--- gdb.ada/lang_switch/foo.c (revision 0)
+++ gdb.ada/lang_switch/foo.c (revision 160)
@@ -0,0 +1,22 @@
+/* Copyright 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+c_procedure (char* msg)
+{
+ return 0; /* STOP */
+}
Index: gdb.ada/lang_switch/lang_switch.adb
===================================================================
--- gdb.ada/lang_switch/lang_switch.adb (revision 0)
+++ gdb.ada/lang_switch/lang_switch.adb (revision 160)
@@ -0,0 +1,34 @@
+-- Copyright 2008 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with System;
+
+procedure Lang_Switch is
+ pragma Linker_Options ("foo.o");
+
+ function C_Procedure (Msg : String) return Integer;
+ pragma Import(C, C_Procedure, "c_procedure");
+
+ procedure Ada_Procedure (Msg : String) is
+ C_Msg : String (1 .. 1024);
+ Tmp_Int : Integer;
+ begin
+ C_Msg (1 .. Msg'length + 1) := Msg & Ascii.Nul;
+ Tmp_Int := C_Procedure (Msg => C_Msg);
+ end Ada_Procedure;
+
+begin
+ Ada_Procedure ("msg");
+end Lang_Switch;
More information about the Gdb-patches
mailing list