public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Re: Bizarre GCC problem - how do I debug it?
       [not found] ` <4C5C453D.4090704@caviumnetworks.com>
@ 2010-08-06 17:51   ` Bruce Korb
  2010-08-06 18:20     ` David Daney
  2010-08-06 18:42     ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Bruce Korb @ 2010-08-06 17:51 UTC (permalink / raw)
  To: David Daney; +Cc: gcc, bug-gdb, insight

On 08/06/10 10:24, David Daney wrote:
> On 08/06/2010 10:19 AM, Bruce Korb wrote:
>> The problem seems to be that GDB thinks all the code belongs to a
>> single line of text.  At first, it was a file of mine, so I presumed
>> I had done something strange and passed it off.  I needed to do some
>> more debugging again and my "-g -O0" output still said all code
>> belonged to that one line.  So, I made a .i file and compiled that.
>> Different file, but the same problem.  The .i file contains the
>> correct preprocessor directives:
>>
>>    # 309 "wrapup.c"
>>    static void
>>    done_check(void)
>>    {
>>
>> but under gdb:
>>
>>    (gdb) b done_check
>>    Breakpoint 5 at 0x40af44: file /usr/include/gmp.h, line 1661.
>>
>> the break point *is* on the entry to "done_check", but the
>> source code displayed is line 1661 of gmp.h.  Not helpful.
>> Further, I cannot set break points on line numbers because
>> all code belongs to the one line in gmp.h.
>>
>> Yes, for now I can debug in assembly code, but it isn't very easy.....
>>
>> $ gcc --version
>> gcc (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292]
>> Copyright (C) 2010 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions.  There
>> is NO
>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>> PURPOSE.
>>
>> I've googled for:  gcc|gdb wrong source file
>> which only yields how to examine source files in gdb.
>>
> 
> Which version of GDB?
> 
> IIRC with GCC-4.5 you need a very new version of GDB.  This page:
> 
> http://gcc.gnu.org/gcc-4.5/changes.html
> 
> indicates that GDB 7.0 or later would be good candidates.

That seems to work.  There are one or two or three bugs then.
Either gdb needs to recognize an out of sync object code, or else
gcc needs to produce object code that forces gdb to object in a way
more obvious than just deciding upon the wrong file and line --
or both.  I simply installed the latest openSuSE and got whatever
was supplied.  It isn't reasonable to expect folks to go traipsing
through upstream web sites looking for "changes.html" files ....

And, of course, the insight stuff needs to incorporate the latest
and greatest gdb.  (I don't use ddd because it is _completely_ non-
intuitive.)

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

* Re: Bizarre GCC problem - how do I debug it?
  2010-08-06 17:51   ` Bizarre GCC problem - how do I debug it? Bruce Korb
@ 2010-08-06 18:20     ` David Daney
  2010-08-06 18:31       ` Bruce Korb
  2010-08-06 18:42     ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: David Daney @ 2010-08-06 18:20 UTC (permalink / raw)
  To: Bruce Korb; +Cc: gcc, bug-gdb, insight

On 08/06/2010 10:51 AM, Bruce Korb wrote:
> On 08/06/10 10:24, David Daney wrote:
>> On 08/06/2010 10:19 AM, Bruce Korb wrote:
>>> The problem seems to be that GDB thinks all the code belongs to a
>>> single line of text.  At first, it was a file of mine, so I presumed
>>> I had done something strange and passed it off.  I needed to do some
>>> more debugging again and my "-g -O0" output still said all code
>>> belonged to that one line.  So, I made a .i file and compiled that.
>>> Different file, but the same problem.  The .i file contains the
>>> correct preprocessor directives:
>>>
>>>     # 309 "wrapup.c"
>>>     static void
>>>     done_check(void)
>>>     {
>>>
>>> but under gdb:
>>>
>>>     (gdb) b done_check
>>>     Breakpoint 5 at 0x40af44: file /usr/include/gmp.h, line 1661.
>>>
>>> the break point *is* on the entry to "done_check", but the
>>> source code displayed is line 1661 of gmp.h.  Not helpful.
>>> Further, I cannot set break points on line numbers because
>>> all code belongs to the one line in gmp.h.
>>>
>>> Yes, for now I can debug in assembly code, but it isn't very easy.....
>>>
>>> $ gcc --version
>>> gcc (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch revision 160292]
>>> Copyright (C) 2010 Free Software Foundation, Inc.
>>> This is free software; see the source for copying conditions.  There
>>> is NO
>>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>>> PURPOSE.
>>>
>>> I've googled for:  gcc|gdb wrong source file
>>> which only yields how to examine source files in gdb.
>>>
>>
>> Which version of GDB?
>>
>> IIRC with GCC-4.5 you need a very new version of GDB.  This page:
>>
>> http://gcc.gnu.org/gcc-4.5/changes.html
>>
>> indicates that GDB 7.0 or later would be good candidates.
>
> That seems to work.  There are one or two or three bugs then.
> Either gdb needs to recognize an out of sync object code

It cannot do this as it was released before GCC-4.5.

> , or else
> gcc needs to produce object code that forces gdb to object in a way
> more obvious than just deciding upon the wrong file and line --
> or both.  I simply installed the latest openSuSE and got whatever
> was supplied.  It isn't reasonable to expect folks to go traipsing
> through upstream web sites looking for "changes.html" files ....
>
> And, of course, the insight stuff needs to incorporate the latest
> and greatest gdb.  (I don't use ddd because it is _completely_ non-
> intuitive.)
>

My understanding is that whoever packages GCC and GDB for a particular 
distribution is responsible to make sure that they work together.

In your case it looks like that didn't happen.

David Daney


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

* Re: Bizarre GCC problem - how do I debug it?
  2010-08-06 18:20     ` David Daney
@ 2010-08-06 18:31       ` Bruce Korb
  0 siblings, 0 replies; 6+ messages in thread
From: Bruce Korb @ 2010-08-06 18:31 UTC (permalink / raw)
  To: David Daney; +Cc: gcc, bug-gdb, insight

On Fri, Aug 6, 2010 at 11:19 AM, David Daney <ddaney@caviumnetworks.com> wrote:
>> That seems to work.  There are one or two or three bugs then.
>> Either gdb needs to recognize an out of sync object code
>
> It cannot do this as it was released before GCC-4.5.

GDB and GCC communicate with each other with particular conventions.
Conventions will change over time.  GCC cannot really know which debugger
is going to be used, so it just emits its code and debug information.
GDB, on the other hand, needs to know what conventions were used when
the binaries were produced.  If it cannot tell, it is a GCC issue _and_ a
GDB issue.  If it can tell and chooses to indicate the problem by supplying
bogus responses, then it is solely a GDB bug.  Either way, we have a bug.

>> And, of course, the insight stuff needs to incorporate the latest
>> and greatest gdb.  (I don't use ddd because it is _completely_ non-
>> intuitive.)
>
> My understanding is that whoever packages GCC and GDB for a particular
> distribution is responsible to make sure that they work together.
>
> In your case it looks like that didn't happen.

openSuSE seems to think that ddd is an adequate debugger.  I do not.
I use insight.  There is no automatic update to insight and insight does
not currently have a 7.x release of the underlying GDB.  They are tightly
bound.  :(

Anyway, I now know what the problem is and I am anxiously awaiting a
new release of Insight -- and I recommend some protocol versioning fixes
for GDB and, possibly, GCC too.

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

* Re: Bizarre GCC problem - how do I debug it?
  2010-08-06 17:51   ` Bizarre GCC problem - how do I debug it? Bruce Korb
  2010-08-06 18:20     ` David Daney
@ 2010-08-06 18:42     ` Tom Tromey
  2010-08-06 18:43       ` Richard Guenther
  1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2010-08-06 18:42 UTC (permalink / raw)
  To: Bruce Korb; +Cc: David Daney, gcc, bug-gdb, insight

>>>>> "Bruce" == Bruce Korb <bruce.korb@gmail.com> writes:

Bruce> That seems to work.  There are one or two or three bugs then.
Bruce> Either gdb needs to recognize an out of sync object code, or else
Bruce> gcc needs to produce object code that forces gdb to object in a way
Bruce> more obvious than just deciding upon the wrong file and line --
Bruce> or both.

Nothing can be done about old versions of gdb.  They are fixed.

I think the situation is better in newer versions of GDB.  We've fixed a
lot of bugs, anyway.  (I'm not sure exactly what problem you hit, so I
don't know if gdb is in fact any more future-proof in that area.)

I don't think things can ever be perfect.  GDB checks the various DWARF
version numbers, but that doesn't exclude extensions.

Bruce> I simply installed the latest openSuSE and got whatever was
Bruce> supplied.  It isn't reasonable to expect folks to go traipsing
Bruce> through upstream web sites looking for "changes.html" files ....

In a situation like this, I suggest complaining to your vendor.  We've
done a lot of work in GDB to catch up with GCC's changing output.  The
development process here is actually reasonably well synchronized.

Tom

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

* Re: Bizarre GCC problem - how do I debug it?
  2010-08-06 18:42     ` Tom Tromey
@ 2010-08-06 18:43       ` Richard Guenther
  2010-08-06 19:16         ` Bruce Korb
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Guenther @ 2010-08-06 18:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Bruce Korb, David Daney, gcc, bug-gdb, insight

On Fri, Aug 6, 2010 at 8:41 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Bruce" == Bruce Korb <bruce.korb@gmail.com> writes:
>
> Bruce> That seems to work.  There are one or two or three bugs then.
> Bruce> Either gdb needs to recognize an out of sync object code, or else
> Bruce> gcc needs to produce object code that forces gdb to object in a way
> Bruce> more obvious than just deciding upon the wrong file and line --
> Bruce> or both.
>
> Nothing can be done about old versions of gdb.  They are fixed.
>
> I think the situation is better in newer versions of GDB.  We've fixed a
> lot of bugs, anyway.  (I'm not sure exactly what problem you hit, so I
> don't know if gdb is in fact any more future-proof in that area.)
>
> I don't think things can ever be perfect.  GDB checks the various DWARF
> version numbers, but that doesn't exclude extensions.
>
> Bruce> I simply installed the latest openSuSE and got whatever was
> Bruce> supplied.  It isn't reasonable to expect folks to go traipsing
> Bruce> through upstream web sites looking for "changes.html" files ....
>
> In a situation like this, I suggest complaining to your vendor.  We've
> done a lot of work in GDB to catch up with GCC's changing output.  The
> development process here is actually reasonably well synchronized.

The gdb version on openSUSE that ship with GCC 4.5 is perfectly fine
(it's 7.1 based).  No idea what the reporter is talking about (we don't ship
insight IIRC).

Richard.

> Tom
>

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

* Re: Bizarre GCC problem - how do I debug it?
  2010-08-06 18:43       ` Richard Guenther
@ 2010-08-06 19:16         ` Bruce Korb
  0 siblings, 0 replies; 6+ messages in thread
From: Bruce Korb @ 2010-08-06 19:16 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Tom Tromey, David Daney, gcc, bug-gdb, insight

Hi Richard,

On Fri, Aug 6, 2010 at 11:43 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> The gdb version on openSUSE that ship with GCC 4.5 is perfectly fine
> (it's 7.1 based).  No idea what the reporter is talking about (we don't ship
> insight IIRC).

You are remembering correctly.  I was not clear enough.  I use Insight
and Insight
is tightly bound to a particular version of GDB.  Since Insight is not
distributed or
supported by openSuSE, this is not an openSuSE issue.  This is an Insight issue
(for having fallen behind, though it is understandable...) and it is a
GDB (and? GCC)
issue *because* the _failure_mode_is_too_confusing_.  GDB/GCC should
be coordinating
so that GDB looks at the binary and says, "I do not understand the
debug information".
Instead, GDB believes that there are no newline characters in the
input.  Is that a
GDB issue or a GCC issue?  I cannot say.  What I can say is that the
hapless user
should be able to read an error message and know what the problem is.

This does not tell me:

>  (gdb) b done_check
>  Breakpoint 5 at 0x40af44: file /usr/include/gmp.h, line 1661.

Thank you everyone.  Regards, Bruce

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

end of thread, other threads:[~2010-08-06 19:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4C5C4433.60302@gmail.com>
     [not found] ` <4C5C453D.4090704@caviumnetworks.com>
2010-08-06 17:51   ` Bizarre GCC problem - how do I debug it? Bruce Korb
2010-08-06 18:20     ` David Daney
2010-08-06 18:31       ` Bruce Korb
2010-08-06 18:42     ` Tom Tromey
2010-08-06 18:43       ` Richard Guenther
2010-08-06 19:16         ` Bruce Korb

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