2008-02-24 Jan Kratochvil Port to GDB-6.8pre. currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you will get: (gdb) p errno [some error] * 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 Attached suggestion patch how to deal with the most common "errno" symbol for the most common under-ggdb3 compiled programs. Original patch hooked into target_translate_tls_address. But its inferior call invalidates `struct frame *' in the callers - RH BZ 690908. https://bugzilla.redhat.com/show_bug.cgi?id=1166549 2007-11-03 Jan Kratochvil * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C. glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location diff --git a/gdb/printcmd.c b/gdb/printcmd.c --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1190,6 +1190,10 @@ print_command_1 (const char *exp, int voidprint) if (exp && *exp) { + /* '*((int *(*) (void)) __errno_location) ()' is incompatible with + function descriptors. */ + if (target_has_execution && strcmp (exp, "errno") == 0) + exp = "*(*(int *(*)(void)) __errno_location) ()"; expression_up expr = parse_expression (exp); val = evaluate_expression (expr.get ()); }