Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: James E Wilson <wilson@specifix.com>
To: gdb-patches@sourceware.org
Subject: [patch] fix dwarf2 missing frame base problem
Date: Thu, 03 Nov 2005 20:03:00 -0000	[thread overview]
Message-ID: <1131044378.23819.32.camel@aretha.corp.specifix.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

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

[-- Attachment #2: patch.frame.address --]
[-- Type: text/plain, Size: 1561 bytes --]

2005-11-01  James E Wilson  <wilson@specifix.com>

	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));

             reply	other threads:[~2005-11-03 18:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-03 20:03 James E Wilson [this message]
2005-11-12  2:38 ` James E Wilson
2005-11-13 18:40   ` Daniel Jacobowitz
2005-11-15  8:52     ` James E Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1131044378.23819.32.camel@aretha.corp.specifix.com \
    --to=wilson@specifix.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox