Merge remote-tracking branch 'up/master' into master-riscv64

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2020-06-28 12:11:45 +03:00
commit 1a35bee70b
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
13 changed files with 1633 additions and 21 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
/binutils-gdb
/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
/v2.0.1.tar.gz
/gdb-9.1.tar.xz
/gdb-9.2.tar.xz

View File

@ -400,3 +400,15 @@ Patch098: gdb-rhbz1818011-bfd-gcc10-error.patch
# Backport fix for deprecation of PyEval_InitThreads in Python 3.9.
Patch099: gdb-rhbz1822715-fix-python-deprecation.patch
# Backport "Fix Python 3.9 related runtime problems"
# Kevin Buettner <kevinb@redhat.com> and Keith Seitz <keiths@redhat.com>
Patch100: gdb-rhbz1829702-fix-python39.patch
# Fix fput?_unfiltered functions
# RH BZ 1844458 (Sergio Durigan Junior and Tom Tromey)
Patch101: gdb-rhbz1844458-use-fputX_unfiltered.patch
# Backport debuginofd support.
# (Aaron Merey, RH BZ 183877)
Patch102: gdb-rhbz1838777-debuginfod.patch

View File

@ -97,3 +97,6 @@
%patch097 -p1
%patch098 -p1
%patch099 -p1
%patch100 -p1
%patch101 -p1
%patch102 -p1

View File

@ -1 +1 @@
899016d49d289757372459f72d642a4c6b3b7732
e7fe0803b6427d3906e991bbb3b7fd2f0fd05e00

View File

@ -97,3 +97,6 @@ gdb-vla-intel-fix-print-char-array.patch
gdb-rhbz1553104-s390x-arch12-test.patch
gdb-rhbz1818011-bfd-gcc10-error.patch
gdb-rhbz1822715-fix-python-deprecation.patch
gdb-rhbz1829702-fix-python39.patch
gdb-rhbz1844458-use-fputX_unfiltered.patch
gdb-rhbz1838777-debuginfod.patch

View File

@ -262,7 +262,7 @@ new file mode 100644
+}
+
+set GDBFLAGS_orig $GDBFLAGS
+set GDBFLAGS "--pid=$testpid"
+set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
+gdb_start
+set GDBFLAGS $GDBFLAGS_orig
+
@ -284,7 +284,7 @@ new file mode 100644
+}
+
+set GDBFLAGS_orig $GDBFLAGS
+set GDBFLAGS "--pid=$testpid"
+set GDBFLAGS "-iex \"set height 0\" --pid=$testpid"
+gdb_start
+set GDBFLAGS $GDBFLAGS_orig
+

View File

@ -0,0 +1,224 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Thu, 4 Jun 2020 17:16:48 -0700
Subject: gdb-rhbz1829702-fix-python39.patch
;; Backport "Fix Python 3.9 related runtime problems"
;; Kevin Buettner <kevinb@redhat.com> and Keith Seitz <keiths@redhat.com>
commit c47bae859a5af0d95224d90000df0e529f7c5aa0
Author: Kevin Buettner <kevinb@redhat.com>
Date: Wed May 27 20:05:40 2020 -0700
Fix Python3.9 related runtime problems
Python3.9b1 is now available on Rawhide. GDB w/ Python 3.9 support
can be built using the configure switch -with-python=/usr/bin/python3.9.
Attempting to run gdb/Python3.9 segfaults on startup:
#0 0x00007ffff7b0582c in PyEval_ReleaseLock () from /lib64/libpython3.9
.so.1.0
#1 0x000000000069ccbf in do_start_initialization ()
at worktree-test1/gdb/python/python.c:1789
#2 _initialize_python ()
at worktree-test1/gdb/python/python.c:1877
#3 0x00000000007afb0a in initialize_all_files () at init.c:237
...
Consulting the the documentation...
https://docs.python.org/3/c-api/init.html
...we find that PyEval_ReleaseLock() has been deprecated since version
3.2. It recommends using PyEval_SaveThread or PyEval_ReleaseThread()
instead. In do_start_initialization, in gdb/python/python.c, we
can replace the calls to PyThreadState_Swap() and PyEval_ReleaseLock()
with a single call to PyEval_SaveThread. (Thanks to Keith Seitz
for working this out.)
With that in place, GDB gets a little bit further. It still dies
on startup, but the backtrace is different:
#0 0x00007ffff7b04306 in PyOS_InterruptOccurred ()
from /lib64/libpython3.9.so.1.0
#1 0x0000000000576e86 in check_quit_flag ()
at worktree-test1/gdb/extension.c:776
#2 0x0000000000576f8a in set_active_ext_lang (now_active=now_active@entry=0x983c00 <extension_language_python>)
at worktree-test1/gdb/extension.c:705
#3 0x000000000069d399 in gdbpy_enter::gdbpy_enter (this=0x7fffffffd2d0,
gdbarch=0x0, language=0x0)
at worktree-test1/gdb/python/python.c:211
#4 0x0000000000686e00 in python_new_inferior (inf=0xddeb10)
at worktree-test1/gdb/python/py-inferior.c:251
#5 0x00000000005d9fb9 in std::function<void (inferior*)>::operator()(inferior*) const (__args#0=<optimized out>, this=0xccad20)
at /usr/include/c++/10/bits/std_function.h:617
#6 gdb::observers::observable<inferior*>::notify (args#0=0xddeb10,
this=<optimized out>)
at worktree-test1/gdb/../gdbsupport/observable.h:106
#7 add_inferior_silent (pid=0)
at worktree-test1/gdb/inferior.c:113
#8 0x00000000005dbcb8 in initialize_inferiors ()
at worktree-test1/gdb/inferior.c:947
...
We checked with some Python Developers and were told that we should
acquire the GIL prior to calling any Python C API function. We
definitely don't have the GIL for calls of PyOS_InterruptOccurred().
I moved class_gdbpy_gil earlier in the file and use it in
gdbpy_check_quit_flag() to acquire (and automatically release) the
GIL.
With those changes in place, I was able to run to a GDB prompt. But,
when trying to quit, it segfaulted again due to due to some other
problems with gdbpy_check_quit_flag():
Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
0x00007ffff7bbab0c in new_threadstate () from /lib64/libpython3.9.so.1.0
(top-gdb) bt 8
#0 0x00007ffff7bbab0c in new_threadstate () from /lib64/libpython3.9.so.1.0
#1 0x00007ffff7afa5ea in PyGILState_Ensure.cold ()
from /lib64/libpython3.9.so.1.0
#2 0x000000000069b58c in gdbpy_gil::gdbpy_gil (this=<synthetic pointer>)
at worktree-test1/gdb/python/python.c:278
#3 gdbpy_check_quit_flag (extlang=<optimized out>)
at worktree-test1/gdb/python/python.c:278
#4 0x0000000000576e96 in check_quit_flag ()
at worktree-test1/gdb/extension.c:776
#5 0x000000000057700c in restore_active_ext_lang (previous=0xe9c050)
at worktree-test1/gdb/extension.c:729
#6 0x000000000088913a in do_my_cleanups (
pmy_chain=0xc31870 <final_cleanup_chain>,
old_chain=0xae5720 <sentinel_cleanup>)
at worktree-test1/gdbsupport/cleanups.cc:131
#7 do_final_cleanups ()
at worktree-test1/gdbsupport/cleanups.cc:143
In this case, we're trying to call a Python C API function after
Py_Finalize() has been called from finalize_python(). I made
finalize_python set gdb_python_initialized to false and then cause
check_quit_flag() to return early when it's false.
With these changes in place, GDB seems to be working again with
Python3.9b1. I think it likely that there are other problems lurking.
I wouldn't be surprised to find that there are other calls into Python
where we don't first make sure that we have the GIL. Further changes
may well be needed.
I see no regressions testing on Rawhide using a GDB built with the
default Python version (3.8.3) versus one built using Python 3.9b1.
I've also tested on Fedora 28, 29, 30, 31, and 32 (all x86_64) using
the default (though updated) system installed versions of Python on
those OSes. This means that I've tested against Python versions
2.7.15, 2.7.17, 2.7.18, 3.7.7, 3.8.2, and 3.8.3. In each case GDB
still builds without problem and shows no regressions after applying
this patch.
gdb/ChangeLog:
2020-MM-DD Kevin Buettner <kevinb@redhat.com>
Keith Seitz <keiths@redhat.com>
* python/python.c (do_start_initialization): For Python 3.9 and
later, call PyEval_SaveThread instead of PyEval_ReleaseLock.
(class gdbpy_gil): Move to earlier in file.
(finalize_python): Set gdb_python_initialized.
(gdbpy_check_quit_flag): Acquire GIL via gdbpy_gil. Return early
when not initialized.
diff --git a/gdb/python/python.c b/gdb/python/python.c
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -234,6 +234,30 @@ gdbpy_enter::~gdbpy_enter ()
PyGILState_Release (m_state);
}
+/* A helper class to save and restore the GIL, but without touching
+ the other globals that are handled by gdbpy_enter. */
+
+class gdbpy_gil
+{
+public:
+
+ gdbpy_gil ()
+ : m_state (PyGILState_Ensure ())
+ {
+ }
+
+ ~gdbpy_gil ()
+ {
+ PyGILState_Release (m_state);
+ }
+
+ DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
+
+private:
+
+ PyGILState_STATE m_state;
+};
+
/* Set the quit flag. */
static void
@@ -247,6 +271,10 @@ gdbpy_set_quit_flag (const struct extension_language_defn *extlang)
static int
gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
{
+ if (!gdb_python_initialized)
+ return 0;
+
+ gdbpy_gil gil;
return PyOS_InterruptOccurred ();
}
@@ -924,30 +952,6 @@ gdbpy_source_script (const struct extension_language_defn *extlang,
/* Posting and handling events. */
-/* A helper class to save and restore the GIL, but without touching
- the other globals that are handled by gdbpy_enter. */
-
-class gdbpy_gil
-{
-public:
-
- gdbpy_gil ()
- : m_state (PyGILState_Ensure ())
- {
- }
-
- ~gdbpy_gil ()
- {
- PyGILState_Release (m_state);
- }
-
- DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
-
-private:
-
- PyGILState_STATE m_state;
-};
-
/* A single event. */
struct gdbpy_event
{
@@ -1548,6 +1552,7 @@ finalize_python (void *ignore)
Py_Finalize ();
+ gdb_python_initialized = false;
restore_active_ext_lang (previous_active);
}
@@ -1720,8 +1725,7 @@ do_start_initialization ()
return false;
/* Release the GIL while gdb runs. */
- PyThreadState_Swap (NULL);
- PyEval_ReleaseLock ();
+ PyEval_SaveThread ();
make_final_cleanup (finalize_python, NULL);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,123 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Keith Seitz <keiths@redhat.com>
Date: Mon, 8 Jun 2020 11:33:47 -0700
Subject: gdb-rhbz1844458-use-fputX_unfiltered.patch
;; Fix fput?_unfiltered functions
;; RH BZ 1844458 (Sergio Durigan Junior and Tom Tromey)
From 9effb44ccbf50c16da66aaab5fd535fe17e38e32 Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Wed, 19 Feb 2020 16:40:48 -0500
Subject: [PATCH] Make '{putchar,fputc}_unfiltered' use 'fputs_unfiltered'
There is currently a regression when using
'{putchar,fputc}_unfiltered' with 'puts_unfiltered' which was
introduced by one of the commits that reworked the unfiltered print
code.
The regression makes it impossible to use '{putchar,fputc}_unfiltered'
with 'puts_unfiltered', because the former writes directly to the
ui_file stream using 'stream->write', while the latter uses a buffered
mechanism (see 'wrap_buffer') and delays the printing.
If you do a quick & dirty hack on e.g. top.c:show_gdb_datadir:
@@ -2088,6 +2088,13 @@ static void
show_gdb_datadir (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
+ putchar_unfiltered ('\n');
+ puts_unfiltered ("TEST");
+ putchar_unfiltered ('>');
+ puts_unfiltered ("PUTS");
+ puts_unfiltered ("PUTS");
+ putchar_unfiltered ('\n');
rebuild GDB and invoke the "show data-directory" command, you will
see:
(gdb) show data-directory
>
TESTPUTSGDB's data directory is "/usr/local/share/gdb".
Note how the '>' was printed before the output, and "TEST" and "PUTS"
were printed together.
My first attempt to fix this was to always call 'flush_wrap_buffer' at
the end of 'fputs_maybe_filtered', since it seemed to me that the
function should always print what was requested. But I wasn't sure
this was the right thing to do, so I talked to Tom on IRC and he gave
me another, simpler idea: make '{putchar,fputc}_unfiltered' call into
the already existing 'fputs_unfiltered' function.
This patch implements the idea. I regtested it on the Buildbot, and
no regressions were detected.
gdb/ChangeLog:
2020-02-20 Sergio Durigan Junior <sergiodj@redhat.com>
Tom Tromey <tom@tromey.com>
* utils.c (fputs_maybe_filtered): Call 'stream->puts' instead
of 'fputc_unfiltered'.
(putchar_unfiltered): Call 'fputc_unfiltered'.
(fputc_unfiltered): Call 'fputs_unfiltered'.
diff --git a/gdb/utils.c b/gdb/utils.c
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1783,7 +1783,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
newline -- if chars_per_line is right, we
probably just overflowed anyway; if it's wrong,
let us keep going. */
- fputc_unfiltered ('\n', stream);
+ /* XXX: The ideal thing would be to call
+ 'stream->putc' here, but we can't because it
+ currently calls 'fputc_unfiltered', which ends up
+ calling us, which generates an infinite
+ recursion. */
+ stream->puts ("\n");
}
else
{
@@ -1828,7 +1833,12 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
wrap_here ((char *) 0); /* Spit out chars, cancel
further wraps. */
lines_printed++;
- fputc_unfiltered ('\n', stream);
+ /* XXX: The ideal thing would be to call
+ 'stream->putc' here, but we can't because it
+ currently calls 'fputc_unfiltered', which ends up
+ calling us, which generates an infinite
+ recursion. */
+ stream->puts ("\n");
lineptr++;
}
}
@@ -1923,10 +1933,7 @@ fputs_highlighted (const char *str, const compiled_regex &highlight,
int
putchar_unfiltered (int c)
{
- char buf = c;
-
- ui_file_write (gdb_stdout, &buf, 1);
- return c;
+ return fputc_unfiltered (c, gdb_stdout);
}
/* Write character C to gdb_stdout using GDB's paging mechanism and return C.
@@ -1941,9 +1948,11 @@ putchar_filtered (int c)
int
fputc_unfiltered (int c, struct ui_file *stream)
{
- char buf = c;
+ char buf[2];
- ui_file_write (stream, &buf, 1);
+ buf[0] = c;
+ buf[1] = 0;
+ fputs_unfiltered (buf, stream);
return c;
}

View File

@ -1,7 +1,3 @@
# This package depends on automagic byte compilation
# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
%global _python_bytecompile_extra 1
# rpmbuild parameters:
# --with testsuite: Run the testsuite (biarch if possible). Default is without.
# --with buildisa: Use %%{?_isa} for BuildRequires
@ -11,8 +7,8 @@
# workload gets run it decreases the general performance now.
# --define 'scl somepkgname': Independent packages by scl-utils-build.
# https://bugzilla.redhat.com/show_bug.cgi?id=1829702
%global _without_python 1
# Turn off the brp-python-bytecompile automagic
%global _python_bytecompile_extra 0
%{?scl:%scl_package gdb}
%{!?scl:
@ -34,11 +30,11 @@ Name: %{?scl_prefix}gdb
# See timestamp of source gnulib installed into gnulib/ .
%global snapgnulib 20191216
%global tarname gdb-%{version}
Version: 9.1
Version: 9.2
# 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: 7.0.riscv64%{?dist}
Release: 2.0.riscv64%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
# Do not provide URL for snapshots as the file lasts there only for 2 days.
@ -202,9 +198,9 @@ Patch1119: gdb-testsuite-readline63-sigint-revert.patch
# Include the auto-generated file containing the "Patch:" directives.
# See README.local-patches for more details.
Source8: _gdb.spec.Patch.include
Source9: _gdb.spec.patch.include
%include %{SOURCE8}
Patch9998: _gdb.spec.Patch.include
Patch9999: _gdb.spec.patch.include
%include %{PATCH9998}
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
@ -264,7 +260,10 @@ BuildRequires: libipt-devel%{buildisa}
BuildRequires: mpfr-devel%{buildisa}
%endif
BuildRequires: source-highlight-devel
%if 0%{!?rhel:1} || 0%{?rhel} > 8
BuildRequires: xxhash-devel
%endif
BuildRequires: elfutils-debuginfod-client-devel
%if 0%{?_with_testsuite:1}
@ -376,6 +375,7 @@ BuildRequires: xz
BuildRequires: rust
%endif
BuildRequires: %{?scl_prefix}elfutils-debuginfod
%endif # 0%{?_with_testsuite:1}
%{?scl:Requires:%scl_runtime}
@ -466,7 +466,7 @@ find -name "*.info*"|xargs rm -f
# Include the auto-generated "%patch" directives.
# See README.local-patches for more details.
%include %{SOURCE9}
%include %{PATCH9999}
%if 0%{!?el6:1}
for i in \
@ -565,7 +565,8 @@ COMMON_GDB_CONFIGURE_FLAGS="\
--with-lzma \
%else
--without-lzma \
%endif
%endif \
--with-debuginfod
"
# Identify the build directory with the version of gdb as well as the
@ -953,6 +954,11 @@ for pyo in "" "-O";do
done
%endif # 0%{?_enable_debug_packages:1} && 0%{!?_without_python:1}
# Compile python files
%if 0%{!?_without_python:1}
%py_byte_compile %{__python3} %{buildroot}%{_datadir}/gdb/python/gdb
%endif
%if 0%{!?_without_python:1}
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# BZ 999645: /usr/share/gdb/auto-load/ needs filesystem symlinks
@ -1163,9 +1169,22 @@ fi
%endif
%changelog
* Mon Jun 1 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> - 9.1-7.0.riscv64
* Sun Jun 28 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> - 9.2-2.0.riscv64
- Add support for RISC-V (riscv64)
* Wed Jun 17 2020 Keith Seitz <keiths@redhat.com> - 9.2-2
- Backport debuginfod support.
* Tue Jun 9 2020 Keith Seitz <keiths@redhat.com> - 9.2-1
- Rebase to FSF GDB 9.2.
- Add explicit python bytecode compilation.
- Change included files to patches to quell error from rpminspect.
- Fix attach-32.exp from gdb-6.3-inferior-notification-20050721.patch.
* Fri Jun 5 2020 Keith Seitz <keiths@redhat.com> - 9.1-8
- Add patch for Python 3.9 and re-enable python.
- Update generate-*.sh to include stgit support.
* Thu May 21 2020 Miro Hrončok <mhroncok@redhat.com> - 9.1-7
- Disable Python support to workaround problems with Python 3.9 (RHBZ 1829702)

View File

@ -14,7 +14,7 @@ usage ()
$0 -- Generate a git repository from .patch files
Usage:
$0 <REPOSITORY>
$0 [-u] [-h] <REPOSITORY>
<REPOSITORY> is the directory where the rebase was performed. You
need to clone the repository first.
@ -22,6 +22,7 @@ need to clone the repository first.
Options are:
-h: Print this message
-u: Uncommit all patches and initialize stgit repo
EOF
exit 0
}
@ -31,8 +32,21 @@ test -f gdb.spec || die "This script needs to run from the same directory as gdb
test -z $1 && die "You need to specify the repository."
test "$1" = "-h" && usage
uncommit=0
if [ "$1" = "-u" ]; then
uncommit=1
shift
fi
git_repo=$1
if [ ! -e $git_repo ]; then
echo "$0: repository \"$git_repo\" does not exist"
exit 1
fi
test -f _git_upstream_commit || die "Cannot find _git_upstream_commit file."
test -f _patch_order || die "Cannot find _patch_order file."
command -v stg > /dev/null 2>&1 || die "Cannot find stg. Is stgit installed?"
last_ancestor_commit=`cat _git_upstream_commit`
@ -41,8 +55,26 @@ cd $1
git name-rev $last_ancestor_commit
test $? -eq 0 || die "Could not find $last_ancestor_commit in the repository $1. Did you run 'git fetch'?"
git checkout $last_ancestor_commit
f=`cd .. && pwd`
# Create a branch for the checkout if using stgit; use the distro name in
# the name of this branch.
if (($uncommit)); then
name=devel-`basename $f`
branch="-b $name"
else
branch=""
fi
git checkout $branch $last_ancestor_commit
echo "Applying patches..."
for p in `cat ../_patch_order` ; do
git am ../$p
test $? -eq 0 || die "Could not apply patch '$p'."
done
if (($uncommit)); then
echo "Uncommitting patches..."
stg init
stg uncommit -t $last_ancestor_commit -x
fi

View File

@ -52,6 +52,13 @@ done
cd $1
# If patches were uncommitted when the patches were applied,
# make sure that we're sitting at the top-most patch. Otherwise
# we'll only add patches up to the current top patch.
# It's safe to just assume stgit was used -- the push will simply
# fail.
stg push --all > /dev/null 2>&1
git name-rev $commit_or_tag
test $? -eq 0 || die "Could not find $commit_or_tag in the repository. Did you run 'git fetch'?"

View File

@ -1,3 +1,3 @@
SHA512 (gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz) = a8b1c54dd348cfeb37da73f968742896be3dd13a4215f8d8519870c2abea915f5176c3fa6989ddd10f20020a16f0fab20cbae68ee8d58a82234d8778023520f8
SHA512 (v2.0.1.tar.gz) = e38e93908c3fbf1f2384cfca381eaf4bf667033de678041bd440adac8bbce4757b77304868896256ed72c202ee22ba1646aada90125029f14f5bffaf828a7df4
SHA512 (gdb-9.1.tar.xz) = 84cdd408d80a3fc5779de459c5b26154d31b329ebde7e3aa78799fb1eb245d8b64b8c8ee7242382a1dbd95b4e6f9d84fef41d12a0646aa75d3dee4709ea1f6e7
SHA512 (gdb-9.2.tar.xz) = 73635f00f343117aa5e2436f1e1597099e2bfb31ef7bb162b273fa1ea282c3fa9b0f52762e70bfc7ad0334addb8d159e9ac7cbe5998ca4f755ea8cf90714d274