2006-09-21 13:07:53 +00:00
|
|
|
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337
|
|
|
|
|
|
|
|
|
|
|
|
currently for trivia nonthreaded helloworld with no debug info up to -ggdb2 you
|
|
|
|
will get:
|
|
|
|
(gdb) p errno
|
2007-01-21 01:53:01 +00:00
|
|
|
[some error]
|
2006-09-21 13:07:53 +00:00
|
|
|
|
|
|
|
* with -ggdb2 and less "errno" in fact does not exist anywhere as it was
|
|
|
|
compiled to "(*__errno_location ())" and the macro definition is not present.
|
|
|
|
Unfortunately gdb will find the TLS symbol and it will try to access it but
|
|
|
|
as the program has been compiled without -lpthread the TLS base register
|
|
|
|
(%gs on i386) is not setup and it will result in:
|
|
|
|
Cannot access memory at address 0x8
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
Attached suggestion patch how to deal with the most common "errno" symbol
|
2006-09-21 13:07:53 +00:00
|
|
|
for the most common under-ggdb3 compiled programs.
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
* target.c (target_translate_tls_address): Provided warnings for TLS
|
|
|
|
`errno' on non-TLS targets.
|
2006-09-21 13:07:53 +00:00
|
|
|
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
Index: gdb-6.6/gdb/target.c
|
2006-09-21 13:07:53 +00:00
|
|
|
===================================================================
|
2007-01-21 01:53:01 +00:00
|
|
|
--- gdb-6.6.orig/gdb/target.c 2007-01-17 01:25:31.000000000 +0100
|
|
|
|
+++ gdb-6.6/gdb/target.c 2007-01-20 06:31:36.000000000 +0100
|
|
|
|
@@ -898,7 +898,18 @@
|
|
|
|
/* It wouldn't be wrong here to try a gdbarch method, too; finding
|
|
|
|
TLS is an ABI-specific thing. But we don't do that yet. */
|
|
|
|
else
|
2006-09-21 13:07:53 +00:00
|
|
|
- error (_("Cannot find thread-local variables on this target"));
|
|
|
|
+ {
|
|
|
|
+ struct minimal_symbol *msymbol;
|
|
|
|
+
|
|
|
|
+ msymbol = lookup_minimal_symbol ("errno", NULL, NULL);
|
|
|
|
+ if (msymbol != NULL
|
|
|
|
+ && SYMBOL_VALUE_ADDRESS (msymbol) == offset
|
|
|
|
+ && SYMBOL_BFD_SECTION (msymbol)->owner == objfile->obfd)
|
|
|
|
+ error (_("TLS symbol `errno' not resolved for non-TLS program."
|
|
|
|
+ " You should use symbol \"(*__errno_location ())\" or"
|
|
|
|
+ " compile the program with `gcc -ggdb3' or `gcc -pthread'."));
|
|
|
|
+ error (_("Cannot find thread-local variables on this target"));
|
|
|
|
+ }
|
|
|
|
|
2007-01-21 01:53:01 +00:00
|
|
|
return addr;
|
2006-09-21 13:07:53 +00:00
|
|
|
}
|