[rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon).

- [rhel6] Do not install its man page if gdb-add-index is not installed.
- [rhel] Do not migrate /usr/share/gdb/auto-load/ with symlinks on RHELs.
- Fix gdb-7.7 auto-load from /usr/share/gdb/auto-load/ regression.
This commit is contained in:
Jan Kratochvil 2014-02-23 22:57:50 +01:00
parent e86a0cc13a
commit 3af2cc602d
3 changed files with 518 additions and 2 deletions

View File

@ -0,0 +1,190 @@
http://sourceware.org/ml/gdb-patches/2014-02/msg00712.html
Subject: [patch+7.7] Fix auto-load 7.7 regression [Re: [commit 2/2] Move processing of .debug_gdb_scripts to auto-load.c]
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi Doug,
the regression affects any loading from /usr/share/gdb/auto-load .
5b2bf9471f1499bee578fcd60c05afe85794e280 is the first bad commit
commit 5b2bf9471f1499bee578fcd60c05afe85794e280
Author: Doug Evans <xdje42@gmail.com>
Date: Fri Nov 29 21:29:26 2013 -0800
Move .debug_gdb_script processing to auto-load.c.
Simplify handling of auto-loaded objfile scripts.
Fedora 20 x86_64
$ gdb -q /usr/lib64/libgobject-2.0.so
Reading symbols from /usr/lib64/libglib-2.0.so.0.3800.2...Reading symbols from /usr/lib/debug/usr/lib64/libglib-2.0.so.0.3800.2.debug...done.
done.
(gdb) _
Fedora Rawhide x86_64
$ gdb -q /usr/lib64/libgobject-2.0.so
Reading symbols from /usr/lib64/libglib-2.0.so...Reading symbols from /usr/lib/debug/usr/lib64/libglib-2.0.so.0.3990.0.debug...done.
done.
warning: File "/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load:/usr/bin/mono-gdb.py".
To enable execution of this file add
add-auto-load-safe-path /usr/lib64/libglib-2.0.so.0.3990.0-gdb.py
line to your configuration file "/home/jkratoch/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/jkratoch/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
(gdb) _
That is it tries to load "forbidden"
/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py
but it should load instead
/usr/share/gdb/auto-load/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py*
Although that is also not exactly this way, there does not exist any
/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py
despite regressed GDB says so.
Regards,
Jan
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline; filename="autoload.patch"
gdb/
2014-02-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* auto-load.c (auto_load_objfile_script_1): Change filename to
debugfile.
gdb/testsuite/
2014-02-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/auto-load-script: New file.
* gdb.base/auto-load.c: New file.
* gdb.base/auto-load.exp: New file.
--- gdb-7.7/gdb/auto-load.c-orig 2014-02-06 03:21:29.000000000 +0100
+++ gdb-7.7/gdb/auto-load.c 2014-02-23 22:38:53.858374840 +0100
@@ -791,17 +791,17 @@ auto_load_objfile_script_1 (struct objfi
make_cleanup_fclose (input);
is_safe
- = file_is_auto_load_safe (filename,
+ = file_is_auto_load_safe (debugfile,
_("auto-load: Loading %s script \"%s\""
" by extension for objfile \"%s\".\n"),
- language->name, filename,
+ language->name, debugfile,
objfile_name (objfile));
/* Add this script to the hash table too so
"info auto-load ${lang}-scripts" can print it. */
pspace_info
= get_auto_load_pspace_data_for_loading (current_program_space);
- maybe_add_script (pspace_info, is_safe, filename, filename, language);
+ maybe_add_script (pspace_info, is_safe, debugfile, debugfile, language);
/* To preserve existing behaviour we don't check for whether the
script was already in the table, and always load it.
diff --git a/gdb/testsuite/gdb.base/auto-load-script b/gdb/testsuite/gdb.base/auto-load-script
new file mode 100644
index 0000000..d02bd1a
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load-script
@@ -0,0 +1,17 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+echo script_loaded\n
+set $script_loaded=42
diff --git a/gdb/testsuite/gdb.base/auto-load.c b/gdb/testsuite/gdb.base/auto-load.c
new file mode 100644
index 0000000..4b94803
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/auto-load.exp b/gdb/testsuite/gdb.base/auto-load.exp
new file mode 100644
index 0000000..9b8211d
--- /dev/null
+++ b/gdb/testsuite/gdb.base/auto-load.exp
@@ -0,0 +1,36 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ return -1
+}
+
+set targetdir "${binfile}.dir"
+set sourcescript "${binfile}-script"
+set targetscriptdir "${targetdir}/[file dirname ${sourcescript}]"
+set targetscript "${targetscriptdir}/${testfile}-gdb.gdb"
+
+remote_exec host "rm -rf ${targetdir}"
+remote_exec host "mkdir -p ${targetscriptdir}"
+remote_exec host "cp ${sourcescript} ${targetscript}"
+
+gdb_test_no_output "set auto-load scripts-directory ${targetdir}" "set auto-load scripts-directory"
+gdb_test_no_output "set auto-load safe-path ${targetscript}" "set auto-load safe-path"
+
+gdb_load ${binfile}
+
+gdb_test {print $script_loaded} " = 42"
--6c2NcOVqGQ03X4Wi--

View File

@ -0,0 +1,300 @@
https://bugzilla.redhat.com/show_bug.cgi?id=1020004
diff -dup -ruNp gdb-7.7-orig/gdb/data-directory/Makefile.in gdb-7.7/gdb/data-directory/Makefile.in
--- gdb-7.7-orig/gdb/data-directory/Makefile.in 2014-02-23 18:12:51.338866391 +0100
+++ gdb-7.7/gdb/data-directory/Makefile.in 2014-02-23 18:14:31.187756983 +0100
@@ -58,9 +58,12 @@ PYTHON_FILES = \
gdb/frames.py \
gdb/FrameIterator.py \
gdb/FrameDecorator.py \
+ gdb/FrameWrapper.py \
+ gdb/backtrace.py \
gdb/types.py \
gdb/printing.py \
gdb/prompt.py \
+ gdb/command/backtrace.py \
gdb/command/bound_registers.py \
gdb/command/__init__.py \
gdb/command/ignore_errors.py \
diff -dup -ruNp gdb-7.7-orig/gdb/python/lib/gdb/FrameWrapper.py gdb-7.7/gdb/python/lib/gdb/FrameWrapper.py
--- gdb-7.7-orig/gdb/python/lib/gdb/FrameWrapper.py 1970-01-01 01:00:00.000000000 +0100
+++ gdb-7.7/gdb/python/lib/gdb/FrameWrapper.py 2014-02-23 18:14:31.188756981 +0100
@@ -0,0 +1,122 @@
+# Wrapper API for frames.
+
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+
+# FIXME: arguably all this should be on Frame somehow.
+class FrameWrapper:
+ def __init__ (self, frame):
+ self.frame = frame;
+
+ def write_symbol (self, stream, sym, block):
+ if len (sym.linkage_name):
+ nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block)
+ if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER:
+ sym = nsym
+
+ stream.write (sym.print_name + "=")
+ try:
+ val = self.read_var (sym)
+ if val != None:
+ val = str (val)
+ # FIXME: would be nice to have a more precise exception here.
+ except RuntimeError, text:
+ val = text
+ if val == None:
+ stream.write ("???")
+ else:
+ stream.write (str (val))
+
+ def print_frame_locals (self, stream, func):
+
+ try:
+ block = self.frame.block()
+ except RuntimeError:
+ block = None
+
+ while block != None:
+ if block.is_global or block.is_static:
+ break
+
+ for sym in block:
+ if sym.is_argument:
+ continue;
+
+ self.write_symbol (stream, sym, block)
+ stream.write ('\n')
+
+ def print_frame_args (self, stream, func):
+
+ try:
+ block = self.frame.block()
+ except RuntimeError:
+ block = None
+
+ while block != None:
+ if block.function != None:
+ break
+ block = block.superblock
+
+ first = True
+ for sym in block:
+ if not sym.is_argument:
+ continue;
+
+ if not first:
+ stream.write (", ")
+
+ self.write_symbol (stream, sym, block)
+ first = False
+
+ # FIXME: this should probably just be a method on gdb.Frame.
+ # But then we need stream wrappers.
+ def describe (self, stream, full):
+ if self.type () == gdb.DUMMY_FRAME:
+ stream.write (" <function called from gdb>\n")
+ elif self.type () == gdb.SIGTRAMP_FRAME:
+ stream.write (" <signal handler called>\n")
+ else:
+ sal = self.find_sal ()
+ pc = self.pc ()
+ name = self.name ()
+ if not name:
+ name = "??"
+ if pc != sal.pc or not sal.symtab:
+ stream.write (" 0x%08x in" % pc)
+ stream.write (" " + name + " (")
+
+ func = self.function ()
+ self.print_frame_args (stream, func)
+
+ stream.write (")")
+
+ if sal.symtab and sal.symtab.filename:
+ stream.write (" at " + sal.symtab.filename)
+ stream.write (":" + str (sal.line))
+
+ if not self.name () or (not sal.symtab or not sal.symtab.filename):
+ lib = gdb.solib_name (pc)
+ if lib:
+ stream.write (" from " + lib)
+
+ stream.write ("\n")
+
+ if full:
+ self.print_frame_locals (stream, func)
+
+ def __getattr__ (self, name):
+ return getattr (self.frame, name)
diff -dup -ruNp gdb-7.7-orig/gdb/python/lib/gdb/backtrace.py gdb-7.7/gdb/python/lib/gdb/backtrace.py
--- gdb-7.7-orig/gdb/python/lib/gdb/backtrace.py 1970-01-01 01:00:00.000000000 +0100
+++ gdb-7.7/gdb/python/lib/gdb/backtrace.py 2014-02-23 18:14:31.188756981 +0100
@@ -0,0 +1,42 @@
+# Filtering backtrace.
+
+# Copyright (C) 2008, 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+import itertools
+
+# Our only exports.
+__all__ = ['push_frame_filter', 'create_frame_filter']
+
+old_frame_filter = None
+
+def push_frame_filter (constructor):
+ """Register a new backtrace filter class with the 'backtrace' command.
+The filter will be passed an iterator as an argument. The iterator
+will return gdb.Frame-like objects. The filter should in turn act as
+an iterator returning such objects."""
+ global old_frame_filter
+ if old_frame_filter == None:
+ old_frame_filter = constructor
+ else:
+ old_frame_filter = lambda iterator, filter = frame_filter: constructor (filter(iterator))
+
+def create_frame_filter (iter):
+ global old_frame_filter
+ if old_frame_filter is None:
+ return iter
+ return old_frame_filter (iter)
+
diff -dup -ruNp gdb-7.7-orig/gdb/python/lib/gdb/command/backtrace.py gdb-7.7/gdb/python/lib/gdb/command/backtrace.py
--- gdb-7.7-orig/gdb/python/lib/gdb/command/backtrace.py 1970-01-01 01:00:00.000000000 +0100
+++ gdb-7.7/gdb/python/lib/gdb/command/backtrace.py 2014-02-23 18:14:31.188756981 +0100
@@ -0,0 +1,106 @@
+# New backtrace command.
+
+# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+import gdb.backtrace
+import itertools
+from gdb.FrameIterator import FrameIterator
+from gdb.FrameWrapper import FrameWrapper
+import sys
+
+class ReverseBacktraceParameter (gdb.Parameter):
+ """The new-backtrace command can show backtraces in 'reverse' order.
+This means that the innermost frame will be printed last.
+Note that reverse backtraces are more expensive to compute."""
+
+ set_doc = "Enable or disable reverse backtraces."
+ show_doc = "Show whether backtraces will be printed in reverse order."
+
+ def __init__(self):
+ gdb.Parameter.__init__ (self, "reverse-backtrace",
+ gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
+ # Default to compatibility with gdb.
+ self.value = False
+
+class FilteringBacktrace (gdb.Command):
+ """Print backtrace of all stack frames, or innermost COUNT frames.
+With a negative argument, print outermost -COUNT frames.
+Use of the 'full' qualifier also prints the values of the local variables.
+Use of the 'raw' qualifier avoids any filtering by loadable modules.
+"""
+
+ def __init__ (self):
+ # FIXME: this is not working quite well enough to replace
+ # "backtrace" yet.
+ gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK)
+ self.reverse = ReverseBacktraceParameter()
+
+ def reverse_iter (self, iter):
+ result = []
+ for item in iter:
+ result.append (item)
+ result.reverse()
+ return result
+
+ def final_n (self, iter, x):
+ result = []
+ for item in iter:
+ result.append (item)
+ return result[x:]
+
+ def invoke (self, arg, from_tty):
+ i = 0
+ count = 0
+ filter = True
+ full = False
+
+ for word in arg.split (" "):
+ if word == '':
+ continue
+ elif word == 'raw':
+ filter = False
+ elif word == 'full':
+ full = True
+ else:
+ count = int (word)
+
+ # FIXME: provide option to start at selected frame
+ # However, should still number as if starting from newest
+ newest_frame = gdb.newest_frame()
+ iter = itertools.imap (FrameWrapper,
+ FrameIterator (newest_frame))
+ if filter:
+ iter = gdb.backtrace.create_frame_filter (iter)
+
+ # Now wrap in an iterator that numbers the frames.
+ iter = itertools.izip (itertools.count (0), iter)
+
+ # Reverse if the user wanted that.
+ if self.reverse.value:
+ iter = self.reverse_iter (iter)
+
+ # Extract sub-range user wants.
+ if count < 0:
+ iter = self.final_n (iter, count)
+ elif count > 0:
+ iter = itertools.islice (iter, 0, count)
+
+ for pair in iter:
+ sys.stdout.write ("#%-2d" % pair[0])
+ pair[1].describe (sys.stdout, full)
+
+FilteringBacktrace()

View File

@ -39,7 +39,7 @@ Version: 7.7
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -527,6 +527,12 @@ Patch846: gdb-testsuite-nohostid.patch
# Fix Python stack corruption.
Patch847: gdb-python-stacksmash.patch
# [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon).
Patch848: gdb-dts-rhel6-python-compat.patch
# Fix gdb-7.7 auto-load from /usr/share/gdb/auto-load/ regression.
Patch849: gdb-auto-load-lost-path-7.7.patch
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
# Patch642: gdb-readline62-ask-more-rh.patch
@ -822,7 +828,12 @@ find -name "*.info*"|xargs rm -f
%patch843 -p1
%patch846 -p1
%patch847 -p1
%patch849 -p1
%patch848 -p1
%if 0%{!?el6:1}
%patch848 -p1 -R
%endif
%patch393 -p1
%if 0%{!?el5:1} || 0%{?scl:1}
%patch393 -p1 -R
@ -1155,8 +1166,8 @@ for pyo in "" "-O";do
done
%endif # 0%{?_enable_debug_packages:1} && 0%{!?_without_python:1}
mkdir $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load
%if 0%{!?_without_python:1}
mkdir $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load
%if 0%{?rhel:1} && 0%{?rhel} <= 6
# Temporarily now:
for LIB in lib lib64;do
@ -1192,6 +1203,7 @@ done
# gdb-add-index cannot be run even for SCL package on RHEL<=6.
%if 0%{?rhel:1} && 0%{?rhel} <= 6
rm -f $RPM_BUILD_ROOT%{_bindir}/gdb-add-index
rm -f $RPM_BUILD_ROOT%{_mandir}/*/gdb-add-index.1*
%endif
# Remove the files that are part of a gdb build but that are owned and
@ -1265,7 +1277,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/*/gdbinit.5*
%{_mandir}/*/gdb.1*
%{_mandir}/*/gcore.1*
# gdb-add-index cannot be run even for SCL package on RHEL<=6.
%if 0%{!?rhel:1} || 0%{?rhel} > 6
%{_mandir}/*/gdb-add-index.1*
%endif
%{_bindir}/gstack
%{_mandir}/*/gstack.1*
# Provide gdbtui for RHEL-5 and RHEL-6 as it is removed upstream (BZ 797664).
@ -1293,6 +1308,9 @@ rm -rf $RPM_BUILD_ROOT
%endif # %{have_inproctrace}
%endif
%if 0%{!?_without_python:1}
# [rhel] Do not migrate /usr/share/gdb/auto-load/ with symlinks on RHELs.
%if 0%{!?rhel:1}
%pre
for i in $(echo bin lib $(basename %{_libdir}) sbin|tr ' ' '\n'|sort -u);do
src="%{_datadir}/gdb/auto-load/$i"
@ -1304,6 +1322,8 @@ for i in $(echo bin lib $(basename %{_libdir}) sbin|tr ' ' '\n'|sort -u);do
fi
fi
done
%endif # 0%{!?rhel:1}
%endif # 0%{!?_without_python:1}
# It would break RHEL-5 by leaving excessive files for the doc subpackage.
%endif # !noarch
@ -1340,6 +1360,12 @@ fi
%endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch"
%changelog
* Sun Feb 23 2014 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.7-3.fc21
- [rhel6] DTS backward Python compatibility API (BZ 1020004, Phil Muldoon).
- [rhel6] Do not install its man page if gdb-add-index is not installed.
- [rhel] Do not migrate /usr/share/gdb/auto-load/ with symlinks on RHELs.
- Fix gdb-7.7 auto-load from /usr/share/gdb/auto-load/ regression.
* Sun Feb 9 2014 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.7-2.fc21
- [rhel] Fix rebase build regression on RHEL systems (Tobias Burnus).