[RFA] backtrace in mixed language applications

Jerome Guitton guitton@adacore.com
Mon Sep 17 11:28:00 GMT 2007


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




More information about the Gdb-patches mailing list