From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32382 invoked by alias); 17 Sep 2007 11:28:57 -0000 Received: (qmail 32371 invoked by uid 22791); 17 Sep 2007 11:28:56 -0000 X-Spam-Check-By: sourceware.org Received: from province.act-europe.fr (HELO province.act-europe.fr) (212.157.227.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 17 Sep 2007 11:28:49 +0000 Received: by province.act-europe.fr (Postfix, from userid 560) id E5248164906; Mon, 17 Sep 2007 13:28:46 +0200 (CEST) Date: Mon, 17 Sep 2007 11:28:00 -0000 From: Jerome Guitton To: gdb-patches@sources.redhat.com Subject: Re: [RFA] backtrace in mixed language applications Message-ID: <20070917112846.GA8782@adacore.com> References: <20070810100313.GA29799@adacore.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070810100313.GA29799@adacore.com> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00209.txt.bz2 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