From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7965 invoked by alias); 3 Nov 2005 18:59:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 7612 invoked by uid 22791); 3 Nov 2005 18:59:33 -0000 Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO duck.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 03 Nov 2005 18:59:33 +0000 Received: from [127.0.0.1] (duck.corp.specifix.com [192.168.1.1]) by duck.specifix.com (Postfix) with ESMTP id CA676671C for ; Thu, 3 Nov 2005 10:59:31 -0800 (PST) Subject: [patch] fix dwarf2 missing frame base problem From: James E Wilson To: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary="=-zRYVMHIhU8/4c5e2TcBG" Message-Id: <1131044378.23819.32.camel@aretha.corp.specifix.com> Mime-Version: 1.0 Date: Thu, 03 Nov 2005 20:03:00 -0000 X-SW-Source: 2005-11/txt/msg00061.txt.bz2 --=-zRYVMHIhU8/4c5e2TcBG Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1570 This fixes GCC PR 24490, which I refiled as GDB PR 2024. The testcase has a function that ends with a call to abort. If you compile it with gcc-4.1 and run it under gdb until it stops in abort, and then generate a backtrace, you get an error saying the frame base can't be found. #2 0x00afb888 in abort () from /lib/libc.so.6 #3 0x080483a5 in main (argc=Could not find the frame base for "main".) at test.c:4 Gcc optimized away the function epilogue, which makes the call to abort the last instruction in the function. The return address from abort is thus past the end of the function. Gcc emitted a location list for the frame base that maps every address inside the function to the frame base value at that point in the function. But gdb is trying to use an address outside the function, and hence can't find any frame base value. Dan Jacobowitz suggested that changing get_frame_pc calls to get_frame_address_in_block calls might work, and indeed it does. There are two such calls in dwarf2loc.c that need to be fixed. I ran the gdb testsuite with and without the patch. Ignoring some spurious failures I am getting in gdb.mi, there is only one difference in the results. Without the patch, I get this failure FAIL: gdb.base/corefile.exp: print func2::coremaker_local and with the patch it does not fail. Looking at the gdb log, I see that this is exactly the problem I am trying to fix, as without the patch I get print func2::coremaker_local Could not find the frame base for "func2". -- Jim Wilson, GNU Tools Support, http://www.specifix.com --=-zRYVMHIhU8/4c5e2TcBG Content-Disposition: attachment; filename=patch.frame.address Content-Type: text/plain; name=patch.frame.address; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1561 2005-11-01 James E Wilson PR 2024 * dwarf2loc.c (dwarf_expr_frame_base): Use get_frame_address_in_block instead of get_frame_pc. (loclist_read_variable): Likewise. Index: dwarf2loc.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2loc.c,v retrieving revision 1.29 diff -p -p -r1.29 dwarf2loc.c *** dwarf2loc.c 12 Jul 2005 13:06:54 -0000 1.29 --- dwarf2loc.c 2 Nov 2005 00:13:36 -0000 *************** dwarf_expr_frame_base (void *baton, gdb_ *** 165,172 **** { struct dwarf2_loclist_baton *symbaton; symbaton = SYMBOL_LOCATION_BATON (framefunc); ! *start = find_location_expression (symbaton, length, ! get_frame_pc (debaton->frame)); } else { --- 165,173 ---- { struct dwarf2_loclist_baton *symbaton; symbaton = SYMBOL_LOCATION_BATON (framefunc); ! *start ! = find_location_expression (symbaton, length, ! get_frame_address_in_block (debaton->frame)); } else { *************** loclist_read_variable (struct symbol *sy *** 580,586 **** size_t size; data = find_location_expression (dlbaton, &size, ! frame ? get_frame_pc (frame) : 0); if (data == NULL) { val = allocate_value (SYMBOL_TYPE (symbol)); --- 581,588 ---- size_t size; data = find_location_expression (dlbaton, &size, ! frame ? get_frame_address_in_block (frame) ! : 0); if (data == NULL) { val = allocate_value (SYMBOL_TYPE (symbol)); --=-zRYVMHIhU8/4c5e2TcBG--