From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25852 invoked by alias); 11 Apr 2011 18:26:04 -0000 Received: (qmail 25843 invoked by uid 22791); 11 Apr 2011 18:26:03 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KAM_STOCKGEN,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Apr 2011 18:25:58 +0000 Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [172.25.149.14]) by smtp-out.google.com with ESMTP id p3BIPpor017212 for ; Mon, 11 Apr 2011 11:25:56 -0700 Received: from vws7 (vws7.prod.google.com [10.241.21.135]) by hpaq14.eem.corp.google.com with ESMTP id p3BIPmOR014641 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 11 Apr 2011 11:25:49 -0700 Received: by vws7 with SMTP id 7so6746558vws.35 for ; Mon, 11 Apr 2011 11:25:48 -0700 (PDT) Received: by 10.220.53.14 with SMTP id k14mr1550406vcg.163.1302546348149; Mon, 11 Apr 2011 11:25:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.30.76 with HTTP; Mon, 11 Apr 2011 11:25:18 -0700 (PDT) In-Reply-To: <20110328151804.GA10936@host1.jankratochvil.net> References: <20110316235418.34BA7190B17@elbrus2.mtv.corp.google.com> <20110318171246.GA13366@host1.jankratochvil.net> <20110328151804.GA10936@host1.jankratochvil.net> From: Paul Pluzhnikov Date: Mon, 11 Apr 2011 18:26:00 -0000 Message-ID: Subject: Re: [patch] Do not skip prologue for -O2 -g with GCC VTA Re: [patch] Fix for PR gdb/12573 To: Jan Kratochvil Cc: Tom Tromey , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes 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: 2011-04/txt/msg00153.txt.bz2 Ping? (This fixes a crash we are actually hitting, so an upstream fix is very desirable.) Thanks! On Mon, Mar 28, 2011 at 8:18 AM, Jan Kratochvil wrote: > On Fri, 18 Mar 2011 18:12:46 +0100, Jan Kratochvil wrote: >> One of the problems is that GDB tries to skip prologue even for -O2 -g c= ode. >> There is no such reason as with -O2 -g the debug info is correct for each >> instructions. =A0With -O0 -g there are frame-related absolute addresses = of >> autovariables which is the reason GDB needs to skip the prologue to have= valid >> location of such -O0 -g autovariables. >> >> -O2 -g code can be detected for a Compilation Unit if there is reference= d any >> location list from that CU (suggested by GCC hackers). =A0In such case s= kipping >> prologues should be disabled. > > Implementation attached. =A0I was told systemtap is using the same idea (= I have > ot checked the systemtap implementation). > > It does not fix the artificial testcase of mine and it does not fix the > problem in general. =A0But it fixes the binary you (Paul) attached to PR = 12573 > and the binary in the Red Hat BZ. =A0It is a mess GDB now chooses "random" > addresses in the -O2 -g code and with this clean up the problem does not > happen in the cases I am aware of. > > I am not sure if there should not be also a GCC DW_AT_producer check but > I hope no compiler produces DW_AT_location as a location list not coverin= g the > functions prologues. > > No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu. > > This is not suitable for 7.3 so late. > > > Thanks, > Jan > > > gdb/ > 2011-03-28 =A0Jan Kratochvil =A0 > > =A0 =A0 =A0 =A0* dwarf2read.c: Include ctype.h. > =A0 =A0 =A0 =A0(struct dwarf2_cu): New field has_loclist. > =A0 =A0 =A0 =A0(process_full_comp_unit): Set also symtab->locations_valid= . =A0Move the > =A0 =A0 =A0 =A0symtab->language code. > =A0 =A0 =A0 =A0(var_decode_location): Set cu->has_loclist. > =A0 =A0 =A0 =A0* symtab.c (skip_prologue_sal): Return on LOCATIONS_VALID. > =A0 =A0 =A0 =A0* symtab.h (struct symtab): Make the primary field a bitfi= eld. =A0New > =A0 =A0 =A0 =A0field locations_valid. > > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c > @@ -57,6 +57,7 @@ > =A0#include "vec.h" > =A0#include "c-lang.h" > =A0#include "valprint.h" > +#include > > =A0#include > =A0#include "gdb_string.h" > @@ -395,6 +396,11 @@ struct dwarf2_cu > =A0 =A0 =A0DIEs for namespaces, we don't need to try to infer them > =A0 =A0 =A0from mangled names. =A0*/ > =A0 unsigned int has_namespace_info : 1; > + > + =A0/* This CU references .debug_loc. =A0It means it has been compiled w= ith > + =A0 =A0 optimizations and debug info together so that GDB may stop skip= ping the > + =A0 =A0 prologue. =A0*/ > + =A0unsigned int has_loclist : 1; > =A0}; > > =A0/* Persistent data held for a compilation unit, even when not > @@ -4626,13 +4632,15 @@ process_full_comp_unit (struct dwarf2_per_cu_data= *per_cu) > > =A0 symtab =3D end_symtab (highpc + baseaddr, objfile, SECT_OFF_TEXT (obj= file)); > > - =A0/* Set symtab language to language from DW_AT_language. > - =A0 =A0 If the compilation is from a C file generated by language prepr= ocessors, > - =A0 =A0 do not set the language if it was already deduced by start_subf= ile. =A0*/ > - =A0if (symtab !=3D NULL > - =A0 =A0 =A0&& !(cu->language =3D=3D language_c && symtab->language !=3D= language_c)) > + =A0if (symtab !=3D NULL) > =A0 =A0 { > - =A0 =A0 =A0symtab->language =3D cu->language; > + =A0 =A0 =A0/* Set symtab language to language from DW_AT_language. =A0I= f the > + =A0 =A0 =A0 =A0compilation is from a C file generated by language prepr= ocessors, do > + =A0 =A0 =A0 =A0not set the language if it was already deduced by start_= subfile. =A0*/ > + =A0 =A0 =A0if (!(cu->language =3D=3D language_c && symtab->language != =3D language_c)) > + =A0 =A0 =A0 symtab->language =3D cu->language; > + > + =A0 =A0 =A0symtab->locations_valid =3D cu->has_loclist; > =A0 =A0 } > > =A0 if (dwarf2_per_objfile->using_index) > @@ -10839,6 +10847,9 @@ var_decode_location (struct attribute *attr, stru= ct symbol *sym, > > =A0 dwarf2_symbol_mark_computed (attr, sym, cu); > =A0 SYMBOL_CLASS (sym) =3D LOC_COMPUTED; > + > + =A0if (SYMBOL_COMPUTED_OPS (sym) =3D=3D &dwarf2_loclist_funcs) > + =A0 =A0cu->has_loclist =3D 1; > =A0} > > =A0/* Given a pointer to a DWARF information entry, figure out if we need > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -2470,6 +2470,9 @@ skip_prologue_sal (struct symtab_and_line *sal) > =A0 if (sal->explicit_pc) > =A0 =A0 return; > > + =A0if (sal->symtab !=3D NULL && sal->symtab->locations_valid) > + =A0 =A0return; > + > =A0 old_chain =3D save_current_space_and_thread (); > =A0 switch_to_program_space_and_thread (sal->pspace); > > --- a/gdb/symtab.h > +++ b/gdb/symtab.h > @@ -762,7 +762,12 @@ struct symtab > =A0 =A0 =A0should be designated the primary, so that the blockvector > =A0 =A0 =A0is relocated exactly once by objfile_relocate. =A0*/ > > - =A0int primary; > + =A0unsigned int primary : 1; > + > + =A0/* GDB does not need to skip prologues as the variable locations are= valid > + =A0 =A0 for all the PC values. =A0*/ > + > + =A0unsigned int locations_valid : 1; > > =A0 /* The macro table for this symtab. =A0Like the blockvector, this > =A0 =A0 =A0may be shared between different symtabs --- and normally is for > --=20 Paul Pluzhnikov