* [RFA] backtrace in mixed language applications
@ 2007-08-10 10:03 Jerome Guitton
2007-08-15 19:14 ` Joel Brobecker
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Jerome Guitton @ 2007-08-10 10:03 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
Hello,
when doing a backtrace in a mixed-language application, GDB should use the
appriorate language for printing the frames (in particular for printing
arguments). Not the case for now, it prints every frame with the
language of the first one.
This is quite visible in a mixed C/Ada application; for example, in
Ada, pointer to unconstrained strings can be represented with "fat pointers",
which are records containing a pointer to the bound information (P_BOUNDS)
and a pointer to the array of characters (P_ARRAY). Imagine that you have
an ada procedure lang_switch.ada_procedure, which takes an Ada string in
parameter, calling some C code. If you get a backtrace from the C code,
you'll get:
[...]
#0 c_procedure (msg=0xbfffc170 "msg") at foo.c:4
#1 0x08049b91 in lang_switch.ada_procedure (msg={P_ARRAY = 0x805524c,
P_BOUNDS = 0x8055250}) at lang_switch.adb:14
[...]
the msg is bogus in frame #1 is bogus. you should have got:
[...]
#0 c_procedure (msg=0xbfffaa00 "msg") at foo.c:4
#1 0x08049b91 in lang_switch.ada_procedure (msg=0x805524c)
at lang_switch.adb:14
[...]
The patch in attachment should fix that. Tested on x86-linux. The
Ada/C testcase will follow. OK to apply?
Thanks in advance,
Jerome
[-- Attachment #2: stack.c.dif --]
[-- Type: video/dv, Size: 1697 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFA] backtrace in mixed language applications 2007-08-10 10:03 [RFA] backtrace in mixed language applications Jerome Guitton @ 2007-08-15 19:14 ` Joel Brobecker 2007-08-15 19:29 ` Daniel Jacobowitz 2007-09-17 11:28 ` Jerome Guitton 2008-01-09 20:48 ` [RFA] backtrace in mixed language applications (take 2) Joel Brobecker 2 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2007-08-15 19:14 UTC (permalink / raw) To: Jerome Guitton; +Cc: gdb-patches [I told Jerome about his attachments being encoded as video/dv] > 2007-08-10 Jerome Guitton <guitton@adacore.com> > > * stack.c (backtrace_command_1): select the frame that we are > about to print. I'm uncertain about this one. I should have reviewed it when it was checked in our tree... > Index: stack.c > =================================================================== > RCS file: /cvs/src/src/gdb/stack.c,v > retrieving revision 1.150 > diff -u -p -r1.150 stack.c > --- stack.c 25 Jul 2007 00:28:25 -0000 1.150 > +++ stack.c 10 Aug 2007 09:41:20 -0000 > @@ -1104,12 +1104,14 @@ backtrace_command_1 (char *count_exp, in > struct frame_info *fi; > int count; > int i; > - struct frame_info *trailing; > + struct frame_info *trailing, *selected_frame; > int trailing_level; > > if (!target_has_stack) > error (_("No stack.")); > > + selected_frame = get_selected_frame (NULL); > + > /* The following code must do two things. First, it must set the > variable TRAILING to the frame from which we should start > printing. Second, it must set the variable count to the number > @@ -1177,6 +1179,10 @@ backtrace_command_1 (char *count_exp, in > { > QUIT; > > + /* Select the frame that we are printing, so that the parameters > + are displayed using the appropriate language. */ > + select_frame (fi); > + > /* Don't use print_stack_frame; if an error() occurs it probably > means further attempts to backtrace would fail (on the other > hand, perhaps the code does or could be fixed to make sure > @@ -1188,6 +1194,7 @@ backtrace_command_1 (char *count_exp, in > /* Save the last frame to check for error conditions. */ > trailing = fi; > } > + select_frame (selected_frame); I think this opens the chance for the debugger to change the selected frame if something goes wrong (or the user presses controlC), which is an unexpected side-effect. Also, I'm thinking this is the wrong place for doing this frame switch. How about doing it inside print_frame? I think this would make sure we cover all the cases where we print a frame, such as after an "up", "down", or a "frame" command. And I think the frame selection needs to be protected against error raising. What do others think? -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications 2007-08-15 19:14 ` Joel Brobecker @ 2007-08-15 19:29 ` Daniel Jacobowitz 0 siblings, 0 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2007-08-15 19:29 UTC (permalink / raw) To: Joel Brobecker; +Cc: Jerome Guitton, gdb-patches On Wed, Aug 15, 2007 at 12:18:34PM -0700, Joel Brobecker wrote: > I think this opens the chance for the debugger to change the selected > frame if something goes wrong (or the user presses controlC), which is an > unexpected side-effect. Correct. If you have to switch the global selected frame, please use a cleanup. It's better to pass the selected frame explicitly where possible, but it may not be practical depending what is checking the language. > Also, I'm thinking this is the wrong place for doing this frame switch. > How about doing it inside print_frame? I think this would make sure > we cover all the cases where we print a frame, such as after an "up", > "down", or a "frame" command. And I think the frame selection needs > to be protected against error raising. > > What do others think? Yes, I agree. If we really need to change the selected frame to print a frame correctly, then let's do it lower down (or document/assert the requirement). -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications 2007-08-10 10:03 [RFA] backtrace in mixed language applications Jerome Guitton 2007-08-15 19:14 ` Joel Brobecker @ 2007-09-17 11:28 ` Jerome Guitton 2008-01-09 20:48 ` [RFA] backtrace in mixed language applications (take 2) Joel Brobecker 2 siblings, 0 replies; 11+ messages in thread From: Jerome Guitton @ 2007-09-17 11:28 UTC (permalink / raw) To: gdb-patches FYI: I did not have time to rework this patch to take the comments into account; and now I am experiencing some strange behavior with it (backtraces with missing frames). I am investigating; I will get back with a cleaner patch soon. Jerome Guitton (guitton@adacore.com): > Hello, > > when doing a backtrace in a mixed-language application, GDB should use the > appriorate language for printing the frames (in particular for printing > arguments). Not the case for now, it prints every frame with the > language of the first one. > > This is quite visible in a mixed C/Ada application; for example, in > Ada, pointer to unconstrained strings can be represented with "fat pointers", > which are records containing a pointer to the bound information (P_BOUNDS) > and a pointer to the array of characters (P_ARRAY). Imagine that you have > an ada procedure lang_switch.ada_procedure, which takes an Ada string in > parameter, calling some C code. If you get a backtrace from the C code, > you'll get: > > [...] > #0 c_procedure (msg=0xbfffc170 "msg") at foo.c:4 > #1 0x08049b91 in lang_switch.ada_procedure (msg={P_ARRAY = 0x805524c, > P_BOUNDS = 0x8055250}) at lang_switch.adb:14 > [...] > > the msg is bogus in frame #1 is bogus. you should have got: > > [...] > #0 c_procedure (msg=0xbfffaa00 "msg") at foo.c:4 > #1 0x08049b91 in lang_switch.ada_procedure (msg=0x805524c) > at lang_switch.adb:14 > [...] > > The patch in attachment should fix that. Tested on x86-linux. The > Ada/C testcase will follow. OK to apply? > > Thanks in advance, > Jerome ^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFA] backtrace in mixed language applications (take 2) 2007-08-10 10:03 [RFA] backtrace in mixed language applications Jerome Guitton 2007-08-15 19:14 ` Joel Brobecker 2007-09-17 11:28 ` Jerome Guitton @ 2008-01-09 20:48 ` Joel Brobecker 2008-01-29 18:06 ` Daniel Jacobowitz 2 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2008-01-09 20:48 UTC (permalink / raw) To: Jerome Guitton; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 4129 bytes --] Hello, This is a problem impacting multi-language applications that Jerome reported a while ago: On Fri, Aug 10, 2007 at 12:03:13PM +0200, Jerome Guitton wrote: > when doing a backtrace in a mixed-language application, GDB should use the > appriorate language for printing the frames (in particular for printing > arguments). Not the case for now, it prints every frame with the > language of the first one. > > This is quite visible in a mixed C/Ada application; for example, in > Ada, pointer to unconstrained strings can be represented with "fat pointers", > which are records containing a pointer to the bound information (P_BOUNDS) > and a pointer to the array of characters (P_ARRAY). Imagine that you have > an ada procedure lang_switch.ada_procedure, which takes an Ada string in > parameter, calling some C code. If you get a backtrace from the C code, > you'll get: > > [...] > #0 c_procedure (msg=0xbfffc170 "msg") at foo.c:4 > #1 0x08049b91 in lang_switch.ada_procedure (msg={P_ARRAY = 0x805524c, > P_BOUNDS = 0x8055250}) at lang_switch.adb:14 > [...] > > the msg is bogus in frame #1 is bogus. you should have got: > > [...] > #0 c_procedure (msg=0xbfffaa00 "msg") at foo.c:4 > #1 0x08049b91 in lang_switch.ada_procedure (msg=0x805524c) > at lang_switch.adb:14 > [...] Jerome posted a patch which I reviewed, and we decided that the patch needed to be reworked. Since then, Jerome has been quite busy and asked me to do it for him. I looked into the problem some more, and found that we could quite easily avoid switching a global variable, and instead find the appropriate language and explicitly pass that language to the val_print routine. This implies the addition of the language to a couple of routines (common_val_print and val_print), and a lot of mechanical edits all over, but it's a good step in the right direction anyway. As a side note, I am still thinking about updating the *parsing* routines to take a new struct parse_context parameter. In this structure, we will have the input_radix in addition to the language. I considered using that same structure for the *printing* but as a matter for fact, only the language is relevant in the printing case. So I only added the language. The meat of the change is in valprint.c (update of the val_print and common_val_print function profiles, as well as removing the use of the current_language), in stack.c (where we get the language from the symbol to be printed - we could get it from the frame but I think it's the same), and mi-stack.c. The rest are mechanical edits where I added the current_language. I didn't want to look at each of the call sites individually and try to guess whether we can pass something better. I'd much rather leave that for later, as a series of separate patches. 2008-01-09 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. The testcase is still pretty much the same. I just fixed a couple of errors that show up when testing out of tree. 2008-01-09 Jerome Guitton <guitton@adacore.com> * gdb.ada/lang_switch: New test program. * gdb.ada/lang_switch.exp: New testcase. Tested on x86-linux. OK to apply? Thanks, -- Joel [-- Attachment #2: lang_switch.diff --] [-- Type: text/plain, Size: 24516 bytes --] Index: valprint.c =================================================================== --- valprint.c (revision 119) +++ valprint.c (revision 122) @@ -180,9 +180,10 @@ show_addressprint (struct ui_file *file, } \f -/* 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 119) +++ value.h (revision 122) @@ -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: stack.c =================================================================== --- stack.c (revision 119) +++ stack.c (revision 122) @@ -366,7 +366,8 @@ print_frame_args (struct symbol *func, s if (val) { 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 Index: mi/mi-cmd-stack.c =================================================================== --- mi/mi-cmd-stack.c (revision 119) +++ mi/mi-cmd-stack.c (revision 122) @@ -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: c-valprint.c =================================================================== --- c-valprint.c (revision 119) +++ c-valprint.c (revision 122) @@ -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 119) +++ f-valprint.c (revision 122) @@ -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 119) +++ m2-valprint.c (revision 122) @@ -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 119) +++ mt-tdep.c (revision 122) @@ -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 119) +++ infcmd.c (revision 122) @@ -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-main.c =================================================================== --- mi/mi-main.c (revision 119) +++ mi/mi-main.c (revision 122) @@ -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 119) +++ jv-valprint.c (revision 122) @@ -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 119) +++ ada-valprint.c (revision 122) @@ -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 119) +++ varobj.c (revision 122) @@ -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 119) +++ p-valprint.c (revision 122) @@ -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 119) +++ scm-valprint.c (revision 122) @@ -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: cp-valprint.c =================================================================== --- cp-valprint.c (revision 119) +++ cp-valprint.c (revision 122) @@ -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 119) +++ sh64-tdep.c (revision 122) @@ -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 119) +++ printcmd.c (revision 122) @@ -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; } Index: Makefile.in =================================================================== --- Makefile.in (revision 119) +++ Makefile.in (revision 122) @@ -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 [-- Attachment #3: lang_switch-tc.diff --] [-- Type: text/plain, Size: 4311 bytes --] Index: gdb.ada/lang_switch.exp =================================================================== --- gdb.ada/lang_switch.exp (revision 0) +++ gdb.ada/lang_switch.exp (revision 121) @@ -0,0 +1,48 @@ +# 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" Index: gdb.ada/lang_switch/foo.c =================================================================== --- gdb.ada/lang_switch/foo.c (revision 0) +++ gdb.ada/lang_switch/foo.c (revision 121) @@ -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 121) @@ -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; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-01-09 20:48 ` [RFA] backtrace in mixed language applications (take 2) Joel Brobecker @ 2008-01-29 18:06 ` Daniel Jacobowitz 2008-02-04 20:56 ` Joel Brobecker 0 siblings, 1 reply; 11+ messages in thread From: Daniel Jacobowitz @ 2008-01-29 18:06 UTC (permalink / raw) To: Joel Brobecker; +Cc: Jerome Guitton, gdb-patches On Wed, Jan 09, 2008 at 12:47:12PM -0800, Joel Brobecker wrote: > @@ -366,7 +366,8 @@ print_frame_args (struct symbol *func, s > if (val) > { > 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? -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-01-29 18:06 ` Daniel Jacobowitz @ 2008-02-04 20:56 ` Joel Brobecker 2008-02-04 21:04 ` Joel Brobecker 0 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2008-02-04 20:56 UTC (permalink / raw) To: Jerome Guitton, gdb-patches > > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-02-04 20:56 ` Joel Brobecker @ 2008-02-04 21:04 ` Joel Brobecker 2008-04-24 2:15 ` Joel Brobecker 0 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2008-02-04 21:04 UTC (permalink / raw) To: Jerome Guitton, gdb-patches [-- Attachment #1: Type: text/plain, Size: 2014 bytes --] [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 [-- Attachment #2: lang_switch.diff --] [-- Type: text/plain, Size: 24929 bytes --] Index: valprint.c =================================================================== --- valprint.c (revision 161) +++ valprint.c (revision 162) @@ -180,9 +180,10 @@ show_addressprint (struct ui_file *file, } \f -/* 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; } [-- Attachment #3: lang_switch-tc.diff --] [-- Type: text/plain, Size: 4558 bytes --] 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; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-02-04 21:04 ` Joel Brobecker @ 2008-04-24 2:15 ` Joel Brobecker 2008-05-01 19:48 ` Daniel Jacobowitz 0 siblings, 1 reply; 11+ messages in thread From: Joel Brobecker @ 2008-04-24 2:15 UTC (permalink / raw) To: Jerome Guitton, gdb-patches > > 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? Ooops, for some reason, the following patch never made it. > 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. Since the adjustments from the previous iteration were relatively minor, I will commit in a week unless someone objects (or approves :). Hopefully the patch still applies cleanly - I'll retest in any case. > 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. Index: valprint.c =================================================================== --- valprint.c (revision 161) +++ valprint.c (revision 162) @@ -180,9 +180,10 @@ show_addressprint (struct ui_file *file, } \f -/* 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; } 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; -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-04-24 2:15 ` Joel Brobecker @ 2008-05-01 19:48 ` Daniel Jacobowitz 2008-05-07 11:36 ` Joel Brobecker 0 siblings, 1 reply; 11+ messages in thread From: Daniel Jacobowitz @ 2008-05-01 19:48 UTC (permalink / raw) To: Joel Brobecker; +Cc: Jerome Guitton, gdb-patches On Wed, Apr 23, 2008 at 06:30:33PM -0700, Joel Brobecker wrote: > Since the adjustments from the previous iteration were relatively > minor, I will commit in a week unless someone objects (or approves :). > Hopefully the patch still applies cleanly - I'll retest in any case. Looks OK to me. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFA] backtrace in mixed language applications (take 2) 2008-05-01 19:48 ` Daniel Jacobowitz @ 2008-05-07 11:36 ` Joel Brobecker 0 siblings, 0 replies; 11+ messages in thread From: Joel Brobecker @ 2008-05-07 11:36 UTC (permalink / raw) To: Jerome Guitton, gdb-patches > > Since the adjustments from the previous iteration were relatively > > minor, I will commit in a week unless someone objects (or approves :). > > Hopefully the patch still applies cleanly - I'll retest in any case. > > Looks OK to me. Thanks, Daniel, for double-checking the patch. I just checked it in. -- Joel ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-05-06 21:38 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-08-10 10:03 [RFA] backtrace in mixed language applications Jerome Guitton 2007-08-15 19:14 ` Joel Brobecker 2007-08-15 19:29 ` Daniel Jacobowitz 2007-09-17 11:28 ` Jerome Guitton 2008-01-09 20:48 ` [RFA] backtrace in mixed language applications (take 2) Joel Brobecker 2008-01-29 18:06 ` Daniel Jacobowitz 2008-02-04 20:56 ` Joel Brobecker 2008-02-04 21:04 ` Joel Brobecker 2008-04-24 2:15 ` Joel Brobecker 2008-05-01 19:48 ` Daniel Jacobowitz 2008-05-07 11:36 ` Joel Brobecker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox