From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23722 invoked by alias); 22 Sep 2014 06:17:10 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 23709 invoked by uid 89); 22 Sep 2014 06:17:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 22 Sep 2014 06:17:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8M6GwHu024407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Sep 2014 02:16:58 -0400 Received: from host2.jankratochvil.net (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8M6GsDp006859 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 22 Sep 2014 02:16:57 -0400 Date: Mon, 22 Sep 2014 06:17:00 -0000 From: Jan Kratochvil To: Yao Qi Cc: Eli Zaretskii , gdb@sourceware.org Subject: Re: Complex DWARF expressions Message-ID: <20140922061654.GA15537@host2.jankratochvil.net> References: <83sijkydk4.fsf@gnu.org> <87a95sxkjr.fsf@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a95sxkjr.fsf@codesourcery.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg00070.txt.bz2 On Mon, 22 Sep 2014 07:59:20 +0200, Yao Qi wrote: > Eli Zaretskii writes: > > > Range 0x100aaf7-0x100ad4c: a complex DWARF expression: > > 0: DW_OP_GNU_entry_value > > 2: DW_OP_reg2 [$edx] > > 3: DW_OP_stack_value > > > > "A variable in $edx" I understand, but what about the "complex DWARF > > expression" parts? Is there any way a mere mortal such as myself can > > decipher this to the effect of understanding in which register or at > > what address can I look up the value, assuming that I know at which PC > > address the program stopped? > > > > (Yes, I've looked at the DWARF Standard, but couldn't understand from > > the description of these location descriptors how to convert them to > > either a register or a memory address.) > > DW_OP_GNU_entry_value isn't in DWARF Standard and it is documented here > http://www.dwarfstd.org/ShowIssue.php?issue=100909.1 > > If I understand the doc above correctly, the entry above means if PC is > within range 0x100aaf7-0x100ad4c, the value of new_width is the value of > $edx at the moment entering this function. IOW, to get value of > new_width, needs to unwind frame and read $edx. But $edx at the caller would be usually callee-clobbered so one would not be able to read the value. This is why the caller's call instruction is described by: <8><1663ca>: Abbrev Number: 24 (DW_TAG_GNU_call_site) <1663cb> DW_AT_low_pc : 0x814d44f <1663cf> DW_AT_abstract_origin: <0x15e7bc> <9><1663d8>: Abbrev Number: 3 (DW_TAG_GNU_call_site_parameter) <1663d9> DW_AT_location : 1 byte block: 52 (DW_OP_reg2 (edx)) <1663db> DW_AT_GNU_call_site_value: 1 byte block: 30 (DW_OP_lit0) So one finds matching DW_TAG_GNU_call_site and then one finds DW_TAG_GNU_call_site_parameter with matching DW_AT_location there. These rules have to be applied recursively, as in many cases there is for example: <6><1669c2>: Abbrev Number: 3 (DW_TAG_GNU_call_site_parameter) <1669c3> DW_AT_location : 1 byte block: 51 (DW_OP_reg1 (ecx)) <1669c5> DW_AT_GNU_call_site_value: 7 byte block: f3 1 51 a ff ff 1a (DW_OP_GNU_entry_value: (DW_OP_reg1 (ecx)); DW_OP_const2u: 65535; DW_OP_and) Jan