public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Debugging a port
@ 2004-12-07 15:58 Russell Shaw
  2004-12-07 16:09 ` Nathan Sidwell
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Russell Shaw @ 2004-12-07 15:58 UTC (permalink / raw)
  To: gcc

Hi,
I'm trying to locate a bug in code generated by the avr port of gcc.

I've looked thru all the files in gcc-3.4.3/gcc/config/avr and
have read the gcc internals manual and a few others off the web.

Dumps at various compilation phases can be done with the -d switch,
but i was wondering if a more interactive approach could be used
with gdb. Where is a good place to put gdb breakpoints in the gcc
source? What other useful methods of debugging in gcc are there?

I want to port a dsp processor some time too, so i'm doing this
to get some practice at the same time.

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

* Re: Debugging a port
  2004-12-07 15:58 Debugging a port Russell Shaw
@ 2004-12-07 16:09 ` Nathan Sidwell
  2004-12-07 16:24 ` Peter Barada
  2004-12-07 16:56 ` Eric Botcazou
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Sidwell @ 2004-12-07 16:09 UTC (permalink / raw)
  To: Russell Shaw; +Cc: gcc

Russell Shaw wrote:
> Hi,
> I'm trying to locate a bug in code generated by the avr port of gcc.
> 
> I've looked thru all the files in gcc-3.4.3/gcc/config/avr and
> have read the gcc internals manual and a few others off the web.
> 
> Dumps at various compilation phases can be done with the -d switch,
> but i was wondering if a more interactive approach could be used
> with gdb. Where is a good place to put gdb breakpoints in the gcc
> source? What other useful methods of debugging in gcc are there?

What I do for code generation bugs is examine the -d dumps to determine
which phase has done the invalid transform, and what that transform started
with.  Then in GDB set a breakpoint in the instruction generator function
to trap when the illformed insn is created.  then run the program.  When
the break point is hit, set some watch points to catch when the insn is being
manipulated.  Then continue.  Everytime the watchpoints trigger, work
out whether this is the location of the bad transform

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

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

* Re: Debugging a port
  2004-12-07 15:58 Debugging a port Russell Shaw
  2004-12-07 16:09 ` Nathan Sidwell
@ 2004-12-07 16:24 ` Peter Barada
  2004-12-07 16:56 ` Eric Botcazou
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Barada @ 2004-12-07 16:24 UTC (permalink / raw)
  To: rjshaw; +Cc: gcc


>I'm trying to locate a bug in code generated by the avr port of gcc.
>
>I've looked thru all the files in gcc-3.4.3/gcc/config/avr and
>have read the gcc internals manual and a few others off the web.

What's the offending code?  Do you have a *simple* testcase?

>Dumps at various compilation phases can be done with the -d switch,
>but i was wondering if a more interactive approach could be used
>with gdb. Where is a good place to put gdb breakpoints in the gcc
>source? What other useful methods of debugging in gcc are there?

Where you place a breakpoint depends on what part of gcc is causing
the bad code.  First you need to identify at what pass the bad code
gets generated.  Start with the assembler output from a minimal
testcase that is generated with '-dp -fverbose-asm' and find the
offending code (and its RTL). Then after running the compiler with
'-da' to create all the dump files, start from the highest numbered
dump and look at each one toward the lowest dump to find where the bad
code/rtl is generated. Then you can start looking at the particular
pass that generates the first occurance of the offending code to
decide where to put a breakpoint.

-- 
Peter Barada
peter@the-baradas.com

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

* Re: Debugging a port
  2004-12-07 15:58 Debugging a port Russell Shaw
  2004-12-07 16:09 ` Nathan Sidwell
  2004-12-07 16:24 ` Peter Barada
@ 2004-12-07 16:56 ` Eric Botcazou
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Botcazou @ 2004-12-07 16:56 UTC (permalink / raw)
  To: Russell Shaw; +Cc: gcc

> Dumps at various compilation phases can be done with the -d switch,
> but i was wondering if a more interactive approach could be used
> with gdb. Where is a good place to put gdb breakpoints in the gcc
> source? What other useful methods of debugging in gcc are there?

For the 3.x series of compilers, stopping in emit-rtl.c:make_insn_raw, 
make_jump_insn_raw and make_call_insn_raw is very useful.  Of course you 
don't want to stop on every insn, so conditionalizing on the insn index 
number (cur_insn_uid, which is actually cfun->emit->x_cur_insn_uid) might 
help too.

-- 
Eric Botcazou

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

end of thread, other threads:[~2004-12-07 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-07 15:58 Debugging a port Russell Shaw
2004-12-07 16:09 ` Nathan Sidwell
2004-12-07 16:24 ` Peter Barada
2004-12-07 16:56 ` Eric Botcazou

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