From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25261 invoked by alias); 24 Oct 2014 22:34:21 -0000 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 Received: (qmail 25251 invoked by uid 89); 24 Oct 2014 22:34:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 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; Fri, 24 Oct 2014 22:34:20 +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 s9OMYD7c006247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 Oct 2014 18:34:13 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9OMYArR007627; Fri, 24 Oct 2014 18:34:11 -0400 Message-ID: <544AD3E1.4030003@redhat.com> Date: Fri, 24 Oct 2014 22:34:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Martin Galvan CC: gdb-patches@sourceware.org, Doug Evans , Eli Zaretskii , Ulrich Weigand , Daniel Gutson Subject: Re: [PATCH] Python API: Add gdb.is_in_prologue and gdb.is_in_epilogue. References: <1413986485-4673-1-git-send-email-martin.galvan@tallertechnologies.com> <544822D6.8020606@redhat.com> <544828BB.9040900@redhat.com> <544A68B1.9000909@redhat.com> <544AB1E5.8030509@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-10/txt/msg00680.txt.bz2 On 10/24/2014 10:11 PM, Martin Galvan wrote: > On Fri, Oct 24, 2014 at 5:09 PM, Pedro Alves wrote: >>> Well, I followed the code while testing a rather simple function and >>> noticed that handle_step_into_function is very similar (in terms of >>> the approach) to in_prologue plus some address corrections and setting >>> a breakpoint to proceed to. The API function needs only the address >>> calculation part. >>> >>> What if: >>> 1) I split handle_step_into_function in the address calc part and >>> the brakpoint insertion part, >>> moving the address calc to a new function (publicly available from infrun.h). >>> 2) I expose such function to the Python API. >>> >>> Would that be accepted? Would you want to see a patch? >>> >>> Please keep in mind that what I actually need is not really messing >>> with the prologue, but to know where the local variables are >>> accessible. If I could simply use DWARF info to accomplish that then I >>> wouldn't even touch the prologue at all. >> >> Hmm, how is this different from simply doing "break function" ? >> GDB sets function breakpoints after the prologue already. A "step" >> into a function should stop at the exact same address as if the user >> did "b function; c" to run to said function. >> >> So, when you detect that you stepped into a function, you could >> just set the breakpoint by function name? > > In order for that to work, I'd have to run the program up to that > point. You can set breakpoints before running the program: (top-gdb) b *main Breakpoint 3 at 0x45ed30: file /home/pedro/gdb/mygit/build/../src/gdb/gdb.c, line 25. (top-gdb) b main Breakpoint 4 at 0x45ed3f: file /home/pedro/gdb/mygit/build/../src/gdb/gdb.c, line 28. That offset is your "prologue", however meaningful that is. > I really need to be able to determine if at a given PC the > local variables will be accessible Why? > without actually running the > program. Ideally I'd use only DWARF info to know that. I think we still don't know what you're trying to do, only a bit of _how_ you're trying to do it. :-) It makes it harder to understand the use case, and to suggest solutions. > I looked up the approach GDB takes when setting a breakpoint at a > function name. From what I saw it appears to be similar as the > "optimistic" path from in_prologue (that is, using symtab and line > info). I guess that makes sense since setting a breakpoint by function > name by definition requires us to have debugging info. If you need access to local variables, then you're already relying on debug info. Thanks, Pedro Alves