public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* translate PC to statement
@ 2004-08-24 17:10 Min Xu (Hsu)
  2004-08-26  4:16 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 5+ messages in thread
From: Min Xu (Hsu) @ 2004-08-24 17:10 UTC (permalink / raw)
  To: gdb

Hi There,

Sorry if this is a stupid question, but I couldn't find answer using 
either google or gdb manual.

Basically I want to know what part of a source code statement produced a 
instruction in the final binary. I have used "info line *(pc)" command, 
which gives me pretty good information on what line produced the PC. 
However, I wanted more information than just the source line. I compiled 
my program with -g. I wonder if this information is kept in the debug 
information? How can I query it? It would be nice if I can obtain some 
information such as why a given instruction is generated from a source 
line. This is some times not obvious at all. For example, I often get a 
instruction that map back to a source line that has only a "{"!

I'd really appreciate your help.

-Min

-- 
Rong: Life is all about running after a busy agenda! How frustrating!
Min: That's right! You can either deal with things as quickly as possible or to create less items on the agenda to begin with.

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

* Re: translate PC to statement
  2004-08-24 17:10 translate PC to statement Min Xu (Hsu)
@ 2004-08-26  4:16 ` Ramana Radhakrishnan
  2004-08-26 13:53   ` Min Xu (Hsu)
  0 siblings, 1 reply; 5+ messages in thread
From: Ramana Radhakrishnan @ 2004-08-26  4:16 UTC (permalink / raw)
  To: xu; +Cc: gdb

Hey Min,


> Hi There,
> 
> Sorry if this is a stupid question, but I couldn't find answer using 
> either google or gdb manual.
> 
> Basically I want to know what part of a source code statement produced a 
> instruction in the final binary. I have used "info line *(pc)" command, 
> which gives me pretty good information on what line produced the PC. 
> However, I wanted more information than just the source line. 

Can you define more information and then maybe we can suggest something ?


>I compiled 
> my program with -g. I wonder if this information is kept in the debug 
> information? How can I query it? It would be nice if I can obtain some 
> information such as why a given instruction is generated from a source 
> line. 

Because the compiler generated it ;-) . If you want more information 
about how an instruction is generated by gcc / which pattern in the 
backend of gcc matches with the instruction, maybe you could use the RTL 
debug dumps to look at stuff. But this might not be the right list to 
query about it.



>This is some times not obvious at all. For example, I often get a 
> instruction that map back to a source line that has only a "{"!

Further if the debug format is in Dwarf2 you might try using dwarfdump 
(Don't remember the link , so do a google for it ) and use the 
information it prints out about the debug information in your program .

Hope this helps.

cheers
Ramana


> 
> I'd really appreciate your help.
> 
> -Min
> 

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

* Re: translate PC to statement
  2004-08-26  4:16 ` Ramana Radhakrishnan
@ 2004-08-26 13:53   ` Min Xu (Hsu)
  2004-08-26 17:47     ` Ramana Radhakrishnan
  0 siblings, 1 reply; 5+ messages in thread
From: Min Xu (Hsu) @ 2004-08-26 13:53 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: gdb

Ramana,

Thank you very much for the reply. I realize I didn't explain my question well
enough. Basically, the instructions that I am interested in are always loads
or stores on SPARC. I am particularly interested in known what's the variable
the instruction is accessing. I Imagine that information can be obtained
statically, without need of a live frame, since the instruction is always
accessing some variable encoded in some source code statements.

Thanks for the info on RTL debug dump and dwarfdump, I will check it out.

-Min

On Thu, 26 Aug 2004 Ramana Radhakrishnan wrote :
> Hey Min,
> 
> 
> >Hi There,
> >
> >Sorry if this is a stupid question, but I couldn't find answer using 
> >either google or gdb manual.
> >
> >Basically I want to know what part of a source code statement produced a 
> >instruction in the final binary. I have used "info line *(pc)" command, 
> >which gives me pretty good information on what line produced the PC. 
> >However, I wanted more information than just the source line. 
> 
> Can you define more information and then maybe we can suggest something ?
> 
> 
> >I compiled 
> >my program with -g. I wonder if this information is kept in the debug 
> >information? How can I query it? It would be nice if I can obtain some 
> >information such as why a given instruction is generated from a source 
> >line. 
> 
> Because the compiler generated it ;-) . If you want more information 
> about how an instruction is generated by gcc / which pattern in the 
> backend of gcc matches with the instruction, maybe you could use the RTL 
> debug dumps to look at stuff. But this might not be the right list to 
> query about it.
> 
> 
> 
> >This is some times not obvious at all. For example, I often get a 
> >instruction that map back to a source line that has only a "{"!
> 
> Further if the debug format is in Dwarf2 you might try using dwarfdump 
> (Don't remember the link , so do a google for it ) and use the 
> information it prints out about the debug information in your program .
> 
> Hope this helps.
> 
> cheers
> Ramana
> 
> 
> >
> >I'd really appreciate your help.
> >
> >-Min
> >
> 

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

* Re: translate PC to statement
  2004-08-26 13:53   ` Min Xu (Hsu)
@ 2004-08-26 17:47     ` Ramana Radhakrishnan
  2004-08-29  5:12       ` Min Xu (Hsu)
  0 siblings, 1 reply; 5+ messages in thread
From: Ramana Radhakrishnan @ 2004-08-26 17:47 UTC (permalink / raw)
  To: Min Xu (Hsu); +Cc: gdb


Hi Min,

> Ramana,
>
> Thank you very much for the reply. I realize I didn't explain my question
> well
> enough. Basically, the instructions that I am interested in are always
> loads
> or stores on SPARC. I am particularly interested in known what's the
> variable
> the instruction is accessing. I Imagine that information can be obtained
> statically, without need of a live frame, since the instruction is always
> accessing some variable encoded in some source code statements.

Yes that information can certainly be obtained statically using a dwarf
dump utility. Recently gcc (3.5 onwards) introduced location lists for
tracking information regarding local variables in a frame and to track the
same (Even though I am not sure about how much it works since I saw a post
on the gcc mailing list which claimed a few regressions in the debug
output vis a vis gdb ). .
I am not sure though if dwarfdump gives you the output for this.


In any case if you are looking at only tracking a fixed number of 
variables changing maybe you could use watchpoints to do that  ?


Hope this helps.

cheers
Ramana











>
> Thanks for the info on RTL debug dump and dwarfdump, I will check it out.
>
> -Min
>
> On Thu, 26 Aug 2004 Ramana Radhakrishnan wrote :
>> Hey Min,
>>
>>
>> >Hi There,
>> >
>> >Sorry if this is a stupid question, but I couldn't find answer using
>> >either google or gdb manual.
>> >
>> >Basically I want to know what part of a source code statement produced
>> a
>> >instruction in the final binary. I have used "info line *(pc)" command,
>> >which gives me pretty good information on what line produced the PC.
>> >However, I wanted more information than just the source line.
>>
>> Can you define more information and then maybe we can suggest something
>> ?
>>
>>
>> >I compiled
>> >my program with -g. I wonder if this information is kept in the debug
>> >information? How can I query it? It would be nice if I can obtain some
>> >information such as why a given instruction is generated from a source
>> >line.
>>
>> Because the compiler generated it ;-) . If you want more information
>> about how an instruction is generated by gcc / which pattern in the
>> backend of gcc matches with the instruction, maybe you could use the RTL
>> debug dumps to look at stuff. But this might not be the right list to
>> query about it.
>>
>>
>>
>> >This is some times not obvious at all. For example, I often get a
>> >instruction that map back to a source line that has only a "{"!
>>
>> Further if the debug format is in Dwarf2 you might try using dwarfdump
>> (Don't remember the link , so do a google for it ) and use the
>> information it prints out about the debug information in your program .
>>
>> Hope this helps.
>>
>> cheers
>> Ramana
>>
>>
>> >
>> >I'd really appreciate your help.
>> >
>> >-Min
>> >
>>
>


----
Ramana Radhakrishnan
Codito Technologies

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

* Re: translate PC to statement
  2004-08-26 17:47     ` Ramana Radhakrishnan
@ 2004-08-29  5:12       ` Min Xu (Hsu)
  0 siblings, 0 replies; 5+ messages in thread
From: Min Xu (Hsu) @ 2004-08-29  5:12 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: gdb

Ramana,

On Thu, 26 Aug 2004 Ramana Radhakrishnan wrote :
> > I am particularly interested in known what's the variable
> > the instruction is accessing. I Imagine that information can be obtained
> > statically, without need of a live frame, since the instruction is always
> > accessing some variable encoded in some source code statements.
> 
> Yes that information can certainly be obtained statically using a dwarf
> dump utility.

After some extra work, I have got gcc-3.3.2 to generate dwarf information
for my binary. However, I could not find instructions on how to statically
get the variable an instruction is accessing. Like before I could use gdb
to get a line number for a given VPC of an instruction. But I don't know what
options to use to query dwarfdump to get this information.

Am I missing something here? Again, your help is greatly appreciated.

> In any case if you are looking at only tracking a fixed number of 
> variables changing maybe you could use watchpoints to do that  ?

Again, I am stuck to static analysis. I can't stop the program at specific
PC and query the variable.

-Min

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

end of thread, other threads:[~2004-08-29  5:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-24 17:10 translate PC to statement Min Xu (Hsu)
2004-08-26  4:16 ` Ramana Radhakrishnan
2004-08-26 13:53   ` Min Xu (Hsu)
2004-08-26 17:47     ` Ramana Radhakrishnan
2004-08-29  5:12       ` Min Xu (Hsu)

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