Re: Bizarre GCC problem - how do I debug it?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

Bruce Korb
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.)
Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

David Daney-4
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


Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

Bruce Korb
On Fri, Aug 6, 2010 at 11:19 AM, David Daney <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

Tom Tromey
In reply to this post by Bruce Korb
>>>>> "Bruce" == Bruce Korb <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

Richard Biener
On Fri, Aug 6, 2010 at 8:41 PM, Tom Tromey <[hidden email]> wrote:

>>>>>> "Bruce" == Bruce Korb <[hidden email]> 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
>
Reply | Threaded
Open this post in threaded view
|

Re: Bizarre GCC problem - how do I debug it?

Bruce Korb
Hi Richard,

On Fri, Aug 6, 2010 at 11:43 AM, Richard Guenther
<[hidden email]> 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