|
|
405ea9 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
405ea9 |
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
405ea9 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
405ea9 |
Subject: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
|
|
|
405ea9 |
|
|
|
405ea9 |
;; Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337).
|
|
|
405ea9 |
;;=push+jan: It should be replaced by Infinity project.
|
|
|
405ea9 |
|
|
|
405ea9 |
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337
|
|
|
405ea9 |
|
|
|
405ea9 |
2008-02-24 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
405ea9 |
|
|
|
405ea9 |
Port to GDB-6.8pre.
|
|
|
405ea9 |
|
|
|
405ea9 |
currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you
|
|
|
405ea9 |
will get:
|
|
|
405ea9 |
(gdb) p errno
|
|
|
405ea9 |
[some error]
|
|
|
405ea9 |
|
|
|
405ea9 |
* with -ggdb2 and less "errno" in fact does not exist anywhere as it was
|
|
|
405ea9 |
compiled to "(*__errno_location ())" and the macro definition is not present.
|
|
|
405ea9 |
Unfortunately gdb will find the TLS symbol and it will try to access it but
|
|
|
405ea9 |
as the program has been compiled without -lpthread the TLS base register
|
|
|
405ea9 |
(%gs on i386) is not setup and it will result in:
|
|
|
405ea9 |
Cannot access memory at address 0x8
|
|
|
405ea9 |
|
|
|
405ea9 |
Attached suggestion patch how to deal with the most common "errno" symbol
|
|
|
405ea9 |
for the most common under-ggdb3 compiled programs.
|
|
|
405ea9 |
|
|
|
405ea9 |
Original patch hooked into target_translate_tls_address. But its inferior
|
|
|
405ea9 |
call invalidates `struct frame *' in the callers - RH BZ 690908.
|
|
|
405ea9 |
|
|
|
405ea9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1166549
|
|
|
405ea9 |
|
|
|
405ea9 |
2007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
405ea9 |
|
|
|
405ea9 |
* ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer
|
|
|
405ea9 |
DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C.
|
|
|
405ea9 |
|
|
|
405ea9 |
glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
|
|
|
405ea9 |
<81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location
|
|
|
405ea9 |
<81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location
|
|
|
405ea9 |
|
|
|
405ea9 |
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
|
|
|
405ea9 |
--- a/gdb/printcmd.c
|
|
|
405ea9 |
+++ b/gdb/printcmd.c
|
|
|
405ea9 |
@@ -1210,6 +1210,10 @@ print_command_1 (const char *args, int voidprint)
|
|
|
405ea9 |
|
|
|
405ea9 |
if (exp != nullptr && *exp)
|
|
|
405ea9 |
{
|
|
|
405ea9 |
+ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with
|
|
|
405ea9 |
+ function descriptors. */
|
|
|
405ea9 |
+ if (target_has_execution && strcmp (exp, "errno") == 0)
|
|
|
405ea9 |
+ exp = "*(*(int *(*)(void)) __errno_location) ()";
|
|
|
405ea9 |
expression_up expr = parse_expression (exp);
|
|
|
405ea9 |
val = evaluate_expression (expr.get ());
|
|
|
405ea9 |
}
|
|
|
405ea9 |
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
|
|
|
405ea9 |
new file mode 100644
|
|
|
405ea9 |
--- /dev/null
|
|
|
405ea9 |
+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
|
|
|
405ea9 |
@@ -0,0 +1,28 @@
|
|
|
405ea9 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ Copyright 2005, 2007 Free Software Foundation, Inc.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
405ea9 |
+ it under the terms of the GNU General Public License as published by
|
|
|
405ea9 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
405ea9 |
+ (at your option) any later version.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ This program is distributed in the hope that it will be useful,
|
|
|
405ea9 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
405ea9 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
405ea9 |
+ GNU General Public License for more details.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ You should have received a copy of the GNU General Public License
|
|
|
405ea9 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
405ea9 |
+ bug-gdb@prep.ai.mit.edu */
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+#include <errno.h>
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+int main()
|
|
|
405ea9 |
+{
|
|
|
405ea9 |
+ errno = 42;
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ return 0; /* breakpoint */
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
|
|
|
405ea9 |
new file mode 100644
|
|
|
405ea9 |
--- /dev/null
|
|
|
405ea9 |
+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp
|
|
|
405ea9 |
@@ -0,0 +1,60 @@
|
|
|
405ea9 |
+# Copyright 2007 Free Software Foundation, Inc.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
405ea9 |
+# it under the terms of the GNU General Public License as published by
|
|
|
405ea9 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
405ea9 |
+# (at your option) any later version.
|
|
|
405ea9 |
+#
|
|
|
405ea9 |
+# This program is distributed in the hope that it will be useful,
|
|
|
405ea9 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
405ea9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
405ea9 |
+# GNU General Public License for more details.
|
|
|
405ea9 |
+#
|
|
|
405ea9 |
+# You should have received a copy of the GNU General Public License
|
|
|
405ea9 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set testfile dw2-errno
|
|
|
405ea9 |
+set srcfile ${testfile}.c
|
|
|
405ea9 |
+set binfile [standard_output_file ${testfile}]
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+proc prep {} {
|
|
|
405ea9 |
+ global srcdir subdir binfile
|
|
|
405ea9 |
+ gdb_exit
|
|
|
405ea9 |
+ gdb_start
|
|
|
405ea9 |
+ gdb_reinitialize_dir $srcdir/$subdir
|
|
|
405ea9 |
+ gdb_load ${binfile}
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ runto_main
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ gdb_breakpoint [gdb_get_line_number "breakpoint"]
|
|
|
405ea9 |
+ gdb_continue_to_breakpoint "breakpoint"
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
|
|
|
405ea9 |
+ untested "Couldn't compile test program"
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep
|
|
|
405ea9 |
+gdb_test "print errno" ".* = 42" "errno with macros=N threads=N"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
|
|
|
405ea9 |
+ untested "Couldn't compile test program"
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep
|
|
|
405ea9 |
+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } {
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep
|
|
|
405ea9 |
+gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } {
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep
|
|
|
405ea9 |
+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+# TODO: Test the error on resolving ERRNO with only libc loaded.
|
|
|
405ea9 |
+# Just how to find the current libc filename?
|
|
|
405ea9 |
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.c b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c
|
|
|
405ea9 |
new file mode 100644
|
|
|
405ea9 |
--- /dev/null
|
|
|
405ea9 |
+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c
|
|
|
405ea9 |
@@ -0,0 +1,28 @@
|
|
|
405ea9 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ Copyright 2005, 2007 Free Software Foundation, Inc.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
405ea9 |
+ it under the terms of the GNU General Public License as published by
|
|
|
405ea9 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
405ea9 |
+ (at your option) any later version.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ This program is distributed in the hope that it will be useful,
|
|
|
405ea9 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
405ea9 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
405ea9 |
+ GNU General Public License for more details.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ You should have received a copy of the GNU General Public License
|
|
|
405ea9 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
405ea9 |
+ bug-gdb@prep.ai.mit.edu */
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+#include <errno.h>
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+int main()
|
|
|
405ea9 |
+{
|
|
|
405ea9 |
+ errno = 42;
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ return 0; /* breakpoint */
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp
|
|
|
405ea9 |
new file mode 100644
|
|
|
405ea9 |
--- /dev/null
|
|
|
405ea9 |
+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp
|
|
|
405ea9 |
@@ -0,0 +1,71 @@
|
|
|
405ea9 |
+# Copyright 2007 Free Software Foundation, Inc.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
405ea9 |
+# it under the terms of the GNU General Public License as published by
|
|
|
405ea9 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
405ea9 |
+# (at your option) any later version.
|
|
|
405ea9 |
+#
|
|
|
405ea9 |
+# This program is distributed in the hope that it will be useful,
|
|
|
405ea9 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
405ea9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
405ea9 |
+# GNU General Public License for more details.
|
|
|
405ea9 |
+#
|
|
|
405ea9 |
+# You should have received a copy of the GNU General Public License
|
|
|
405ea9 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set testfile dw2-errno2
|
|
|
405ea9 |
+set srcfile ${testfile}.c
|
|
|
405ea9 |
+set binfile [standard_output_file ${testfile}]
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+proc prep { message {do_xfail 0} } { with_test_prefix $message {
|
|
|
405ea9 |
+ global srcdir subdir binfile variant
|
|
|
405ea9 |
+ gdb_exit
|
|
|
405ea9 |
+ gdb_start
|
|
|
405ea9 |
+ gdb_reinitialize_dir $srcdir/$subdir
|
|
|
405ea9 |
+ gdb_load ${binfile}${variant}
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ runto_main
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ gdb_breakpoint [gdb_get_line_number "breakpoint"]
|
|
|
405ea9 |
+ gdb_continue_to_breakpoint "breakpoint"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ gdb_test "gcore ${binfile}${variant}.core" "\r\nSaved corefile .*" "gcore $variant"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ gdb_test "print errno" ".* = 42"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+ gdb_test "kill" ".*" "kill" {Kill the program being debugged\? \(y or n\) } "y"
|
|
|
405ea9 |
+ gdb_test "core-file ${binfile}${variant}.core" "\r\nCore was generated by .*" "core-file"
|
|
|
405ea9 |
+ if $do_xfail {
|
|
|
405ea9 |
+ setup_xfail "*-*-*"
|
|
|
405ea9 |
+ }
|
|
|
405ea9 |
+ gdb_test "print (int) errno" ".* = 42" "print errno for core"
|
|
|
405ea9 |
+}}
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set variant g2thrN
|
|
|
405ea9 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } {
|
|
|
405ea9 |
+ untested "Couldn't compile test program"
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep "macros=N threads=N" 1
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set variant g3thrN
|
|
|
405ea9 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } {
|
|
|
405ea9 |
+ untested "Couldn't compile test program"
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep "macros=Y threads=N" 1
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set variant g2thrY
|
|
|
405ea9 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } {
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep "macros=N threads=Y"
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+set variant g3thrY
|
|
|
405ea9 |
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } {
|
|
|
405ea9 |
+ return -1
|
|
|
405ea9 |
+}
|
|
|
405ea9 |
+prep "macros=Y threads=Y" 1
|
|
|
405ea9 |
+
|
|
|
405ea9 |
+# TODO: Test the error on resolving ERRNO with only libc loaded.
|
|
|
405ea9 |
+# Just how to find the current libc filename?
|