public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* about souce code location
@ 2020-09-04  0:21 易会战
  2020-09-04  7:08 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: 易会战 @ 2020-09-04  0:21 UTC (permalink / raw)
  To: gcc

I am working a instrumention tool, and need get the location info for a gimple statement. I use the location structure to get the info, and it can work when i use -O1. When I use -O2, sometimes the info seems to be lost and I get line num is zero.  anyone can tell me how to get the info?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: about souce code location
  2020-09-04  0:21 about souce code location 易会战
@ 2020-09-04  7:08 ` Richard Biener
  2020-09-04 12:26   ` 易会战
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2020-09-04  7:08 UTC (permalink / raw)
  To: 易会战; +Cc: gcc

On Fri, Sep 4, 2020 at 2:23 AM 易会战 via Gcc <gcc@gcc.gnu.org> wrote:
>
> I am working a instrumention tool, and need get the location info for a gimple statement. I use the location structure to get the info, and it can work when i use -O1. When I use -O2, sometimes the info seems to be lost and I get line num is zero.&nbsp; anyone can tell me how to get the info?

Not all statements have a location, if you encounter such you need to
look at the "surrounding context"
to find one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: about souce code location
  2020-09-04  7:08 ` Richard Biener
@ 2020-09-04 12:26   ` 易会战
  2020-09-06 23:31     ` Martin Sebor
  0 siblings, 1 reply; 4+ messages in thread
From: 易会战 @ 2020-09-04 12:26 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc

how to check the location corresponding to a gimple statement? My instrument stmt include some memory access, I wish get right source code line. By context it is possible get wrong line.



---Original---
From: "Richard Biener"<richard.guenther@gmail.com&gt;
Date: Fri, Sep 4, 2020 15:08 PM
To: "易会战"<huizhanyi@foxmail.com&gt;;
Cc: "gcc"<gcc@gcc.gnu.org&gt;;
Subject: Re: about souce code location


On Fri, Sep 4, 2020 at 2:23 AM 易会战 via Gcc <gcc@gcc.gnu.org&gt; wrote:
&gt;
&gt; I am working a instrumention tool, and need get the location info for a gimple statement. I use the location structure to get the info, and it can work when i use -O1. When I use -O2, sometimes the info seems to be lost and I get line num is zero.&amp;nbsp; anyone can tell me how to get the info?

Not all statements have a location, if you encounter such you need to
look at the "surrounding context"
to find one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: about souce code location
  2020-09-04 12:26   ` 易会战
@ 2020-09-06 23:31     ` Martin Sebor
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Sebor @ 2020-09-06 23:31 UTC (permalink / raw)
  To: 易会战, Richard Biener; +Cc: gcc

On 9/4/20 6:26 AM, 易会战 via Gcc wrote:
> how to check the location corresponding to a gimple statement? My instrument stmt include some memory access, I wish get right source code line. By context it is possible get wrong line.

The gimple_location() function returns the location of the GIMPLE
statement passed to it as an argument.  When the location isn't
available (e.g., because the statement corresponds to two or more
source lines) there isn't much you can do to retrieve it.  Sometimes
it's possible to come close by using the location of the next (or
previous) GIMPLE statement.  Other times the best you can do is
point at the function body (either the opening or closing curly).

Martin

> 
> 
> 
> ---Original---
> From: "Richard Biener"<richard.guenther@gmail.com&gt;
> Date: Fri, Sep 4, 2020 15:08 PM
> To: "易会战"<huizhanyi@foxmail.com&gt;;
> Cc: "gcc"<gcc@gcc.gnu.org&gt;;
> Subject: Re: about souce code location
> 
> 
> On Fri, Sep 4, 2020 at 2:23 AM 易会战 via Gcc <gcc@gcc.gnu.org&gt; wrote:
> &gt;
> &gt; I am working a instrumention tool, and need get the location info for a gimple statement. I use the location structure to get the info, and it can work when i use -O1. When I use -O2, sometimes the info seems to be lost and I get line num is zero.&amp;nbsp; anyone can tell me how to get the info?
> 
> Not all statements have a location, if you encounter such you need to
> look at the "surrounding context"
> to find one.
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-06 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04  0:21 about souce code location 易会战
2020-09-04  7:08 ` Richard Biener
2020-09-04 12:26   ` 易会战
2020-09-06 23:31     ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).