* Why type = <data variable, no debug info>?
@ 2006-10-21 3:20 Munzir Taha (منذر طه)
2006-10-21 3:51 ` Brian Dessent
0 siblings, 1 reply; 4+ messages in thread
From: Munzir Taha (منذر طه) @ 2006-10-21 3:20 UTC (permalink / raw)
To: gdb
Hi, in this small program logic tells me that errno and n should have the same
value displayed in gdb. Am I missing something obvious?
# gdb ./testgdb
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".
(gdb) l
1 #include <errno.h>
2 #include <stdio.h>
3
4 int main(int argc, char *argv[])
5 {
6 errno = ENOENT;
7 int n = errno;
8 printf("%d, %d\n", n, errno);
9 return(0);
10 }
(gdb) break 8
Breakpoint 1 at 0x80483ba: file testgdb.c, line 8.
(gdb) r
Starting program: /home/munzir/testgdb
warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at
ffffe0b4
Breakpoint 1, main () at testgdb.c:8
8 printf("%d, %d\n", n, errno);
(gdb) p errno
$1 = 0
(gdb) p n
$2 = 2
(gdb) whatis errno
type = <data variable, no debug info>
(gdb) whatis n
type = int
--
Munzir Taha
Telecommunications and Electronics Engineer
Maintainer of Fedora Arabic Translation Project
https://listman.redhat.com/mailman/listinfo/fedora-trans-ar
Maintainer of the OpenBugs project page at
http://www.arabic-fedora.org/munzir/OpenBugs.html
Master CIW Designer, ICDL, MOUS, Linux+, LPI 101
Riyadh, SA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why type = <data variable, no debug info>?
2006-10-21 3:20 Why type = <data variable, no debug info>? Munzir Taha (منذر طه)
@ 2006-10-21 3:51 ` Brian Dessent
2006-10-21 4:44 ` Munzir Taha (منذر طه)
2006-10-21 5:13 ` Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Brian Dessent @ 2006-10-21 3:51 UTC (permalink / raw)
To: gdb
"Munzir Taha (???? ??)" wrote:
>
> Hi, in this small program logic tells me that errno and n should have the same
> value displayed in gdb. Am I missing something obvious?
You're probably running into the fact that on modern glibc errno is a
TLS symbol, not a regular one. This means it can take on a different
value in each thread, and thus is accessed through an indirection.
You might get better debugging ability if you compile with -ggdb3
instead of just -g, which gives gdb some additional information. I
believe that without any debug information in the binary, gdb cannot do
anything about TLS symbols, but I'm not sure. See also the proposed
patch <http://sourceware.org/ml/gdb-patches/2006-08/threads.html#00187>
and/or <https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337>.
Brian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why type = <data variable, no debug info>?
2006-10-21 3:51 ` Brian Dessent
@ 2006-10-21 4:44 ` Munzir Taha (منذر طه)
2006-10-21 5:13 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Munzir Taha (منذر طه) @ 2006-10-21 4:44 UTC (permalink / raw)
To: gdb
On Saturday 21 October 2006 06:51, Brian Dessent wrote:
> "Munzir Taha (منذر طه)" wrote:
> > Hi, in this small program logic tells me that errno and n should have the
> > same value displayed in gdb. Am I missing something obvious?
>
> You're probably running into the fact that on modern glibc errno is a
> TLS symbol, not a regular one. This means it can take on a different
> value in each thread, and thus is accessed through an indirection.
>
> You might get better debugging ability if you compile with -ggdb3
Thanks a lot Brian for your quick and accurate response. Compiling with -ggdb3
displays the correct value for errno now.
--
Munzir Taha
Telecommunications and Electronics Engineer
Maintainer of Fedora Arabic Translation Project
https://listman.redhat.com/mailman/listinfo/fedora-trans-ar
Maintainer of the OpenBugs project page at
http://www.arabic-fedora.org/munzir/OpenBugs.html
Master CIW Designer, ICDL, MOUS, Linux+, LPI 101
Riyadh, SA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Why type = <data variable, no debug info>?
2006-10-21 3:51 ` Brian Dessent
2006-10-21 4:44 ` Munzir Taha (منذر طه)
@ 2006-10-21 5:13 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-10-21 5:13 UTC (permalink / raw)
To: Munzir Taha (???????? ????), gdb
On Sat, Oct 21, 2006 at 06:20:23AM +0300, Munzir Taha (???????? ????) wrote:
> (gdb) p n
> $2 = 2
> (gdb) whatis errno
> type = <data variable, no debug info>
n is a variable in your program, which you compiled with -g. errno is
a variable in the C library, which does not contain debugging
information.
On Fri, Oct 20, 2006 at 08:51:10PM -0700, Brian Dessent wrote:
> "Munzir Taha (???? ??)" wrote:
> >
> > Hi, in this small program logic tells me that errno and n should have the same
> > value displayed in gdb. Am I missing something obvious?
>
> You're probably running into the fact that on modern glibc errno is a
> TLS symbol, not a regular one. This means it can take on a different
> value in each thread, and thus is accessed through an indirection.
>
> You might get better debugging ability if you compile with -ggdb3
> instead of just -g, which gives gdb some additional information. I
> believe that without any debug information in the binary, gdb cannot do
> anything about TLS symbols, but I'm not sure. See also the proposed
> patch <http://sourceware.org/ml/gdb-patches/2006-08/threads.html#00187>
> and/or <https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337>.
-g3 will help (because you'll get __errno_location), but other than
that this is right for the wrong reasons. You're right that it's a TLS
symbol, but that's not why its type is wrong.
Anyway, you'll note a revised version of support for TLS symbols
without debug info has already been committed, but Jan's changes for
TLS symbols in single threaded programs are much thornier.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-21 5:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-21 3:20 Why type = <data variable, no debug info>? Munzir Taha (منذر طه)
2006-10-21 3:51 ` Brian Dessent
2006-10-21 4:44 ` Munzir Taha (منذر طه)
2006-10-21 5:13 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox