Compare commits

...

8 Commits
master ... f25

Author SHA1 Message Date
Jan Kratochvil b65f9dc492 Fix reported gdb-vla-intel-stringbt-fix.patch regression (SuSE). 2017-04-19 22:30:18 +02:00
Jan Kratochvil 1db78d1b38 Fix EOL escape in multiline command segv (Pedro Alves, RH BZ 1429172). 2017-03-08 20:07:01 +01:00
Jan Kratochvil 9a1a8f39f5 Fix <tab>-completion crash (Gary Benson, RH BZ 1398387). 2017-02-15 17:08:53 +01:00
Jan Kratochvil e0f15a9e60 Release bump. 2017-02-14 19:23:47 +01:00
Jan Kratochvil d575bd5d7f [dts] Upgrade libstdc++-v3-python to 6.3.1-20170212. 2017-02-12 14:29:43 +01:00
Jan Kratochvil d451a1fde4 Add missing %license macro 2017-02-12 14:16:59 +01:00
Jan Kratochvil a4bff2f4eb Rebase to released FSF GDB 7.12.1. 2017-01-21 19:33:44 +01:00
Jan Kratochvil aa6d0cbf75 Enable libinproctrace.so on all archs except arm32. 2017-01-17 19:36:56 +01:00
5 changed files with 242 additions and 140 deletions

4
.gitignore vendored
View File

@ -1,3 +1,3 @@
/gdb-libstdc++-v3-python-6.1.1-20160817.tar.xz
/gdb-libstdc++-v3-python-6.3.1-20170212.tar.xz
/v1.5.tar.gz
/gdb-7.12.0.20170111.tar.xz
/gdb-7.12.1.tar.xz

View File

@ -460,137 +460,210 @@ index 378eea0..7d9b198 100644
https://bugzilla.redhat.com/show_bug.cgi?id=1411094
http://sourceware.org/ml/gdb-patches/2016-11/msg00076.html
Subject: Re: [RFA 1/2] Fix some error-handling bugs in python frame filters
http://sourceware.org/ml/gdb-patches/2017-02/msg00226.html
Subject: [OB PATCH] Fix NULL pointer dereference
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
This commit fixes a segmentation fault on tab completion when
certain debuginfo is installed:
Tom> I've included a test case for the first issue.
https://bugzilla.redhat.com/show_bug.cgi?id=1398387
I did a -m32 build here and have fixed up the test case.
Here's the new patch. This is ready to review now.
gdb/ChangeLog:
Tom
* symtab.c (add_symtab_completions): Prevent NULL pointer
dereference.
---
gdb/ChangeLog | 5 +++++
gdb/symtab.c | 3 +++
2 files changed, 8 insertions(+)
commit 981628a4af5f82a12351b9764437927d3a8c8169
Author: Tom Tromey <tom@tromey.com>
Date: Mon Oct 31 11:10:35 2016 -0600
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 356f480..2c141e5 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5163,6 +5163,9 @@ add_symtab_completions (struct compunit_symtab *cust,
struct block_iterator iter;
int i;
+ if (cust == NULL)
+ return;
+
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
QUIT;
--
1.8.3.1
Fix some error-handling bugs in python frame filters
While writing a Python frame filter, I found a few bugs in the current
frame filter code. In particular:
* One spot converts a Python long to a CORE_ADDR using PyLong_AsLong.
However, this can fail on overflow. I changed this to use
get_addr_from_python.
* Another spot is doing the same but with PyLong_AsUnsignedLongLong; I
changed this as well just for consistency.
* Converting line numbers can print "-1" if conversion from long
fails. This isn't fatal but just a bit ugly.
I've included a test case for the first issue. The line number one
didn't seem important enough to bother with.
2016-10-31 Tom Tromey <tom@tromey.com>
* python/py-framefilter.c (py_print_frame): Use
get_addr_from_python. Check for errors when getting line number.
2016-10-31 Tom Tromey <tom@tromey.com>
* gdb.python/py-framefilter.py (ElidingFrameDecorator.address):
New method.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1fd85ce..98fcd21 100644
commit 6e5d74e74756fafe59e8198c4cc462cf7c57e12c
Author: Pedro Alves <palves@redhat.com>
Date: Wed Mar 8 11:41:35 2017 +0000
Fix PR 21218: GDB dumps core when escaping newline in multi-line command
With commit 3b12939dfc2399 ("Replace the sync_execution global with a
new enum prompt_state tristate"), GDB started aborting if you try
splitting an input line with a continuation char (backslash) while in
a multi-line command:
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>print \
(gdb) 1 # note "(gdb)" incorrectly printed here.
>end
readline: readline_callback_read_char() called with no handler!
$
That abort is actually a symptom of an old problem introduced when
gdb_readline_wrapper was rewritten to use asynchronous readline, back
in 2007. Note how the "(gdb)" prompt is printed above in the "(gdb)
1" line. Clearly it shouldn't be there, but it already was before the
commit mentioned above. Fixing that also fixes the readline abort
shown above.
The problem starts when command_line_input passes a NULL prompt to
gdb_readline_wrapper when it finds previous incomplete input due to a
backslash, trying to fetch more input without printing another ">"
secondary prompt. That itself should not be a problem, because
passing NULL to gdb_readline_wrapper has the same meaning as passing a
pointer to empty string, since gdb_readline_wrapper exposes the same
interface as 'readline(char *)'. However, gdb_readline_wrapper passes
the prompt argument directly to display_gdb_prompt, and for the
latter, a NULL prompt argument has a different meaning - it requests
printing the primary prompt.
Before commit 782a7b8ef9c096 (which rewrote gdb_readline_wrapper to
use asynchronous readline), GDB behaved like this:
(gdb) commands
[....]
>print \
1
>end
(gdb)
The above is what this commit restores GDB back to.
New test included.
gdb/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
PR cli/21218
* top.c (gdb_readline_wrapper): Avoid passing NULL to
display_gdb_prompt.
(command_line_input): Add comment.
gdb/testsuite/ChangeLog:
2017-03-08 Pedro Alves <palves@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
PR cli/21218
* gdb.base/commands.exp (backslash_in_multi_line_command_test):
New proc.
(top level): Call it.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,3 +1,8 @@
+2016-10-31 Tom Tromey <tom@tromey.com>
+
+ * python/py-framefilter.c (py_print_frame): Use
+ get_addr_from_python. Check for errors when getting line number.
+
2016-11-03 Yao Qi <yao.qi@linaro.org>
## -1,5 +1,12 @@
2017-03-08 Pedro Alves <palves@redhat.com>
* Makefile.in (.y.c): Replace YY_NULL with YY_NULLPTR.
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 6692ac5..4c7757c 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -1116,7 +1116,13 @@ py_print_frame (PyObject *filter, int flags,
if (paddr != Py_None)
{
- address = PyLong_AsLong (paddr);
+ if (get_addr_from_python (paddr, &address) < 0)
+ {
+ Py_DECREF (paddr);
+ do_cleanups (cleanup_stack);
+ return EXT_LANG_BT_ERROR;
+ }
+ PR cli/21218
+ * top.c (gdb_readline_wrapper): Avoid passing NULL to
+ display_gdb_prompt.
+ (command_line_input): Add comment.
+
has_addr = 1;
}
Py_DECREF (paddr);
@@ -1213,10 +1219,10 @@ py_print_frame (PyObject *filter, int flags,
}
else if (PyLong_Check (py_func))
{
- CORE_ADDR addr = PyLong_AsUnsignedLongLong (py_func);
+ CORE_ADDR addr;
struct bound_minimal_symbol msymbol;
- if (PyErr_Occurred ())
+ if (get_addr_from_python (py_func, &addr) < 0)
{
do_cleanups (cleanup_stack);
return EXT_LANG_BT_ERROR;
@@ -1340,6 +1346,12 @@ py_print_frame (PyObject *filter, int flags,
if (py_line != Py_None)
{
line = PyLong_AsLong (py_line);
+ if (PyErr_Occurred ())
+ {
+ do_cleanups (cleanup_stack);
+ return EXT_LANG_BT_ERROR;
+ }
+2017-03-08 Pedro Alves <palves@redhat.com>
+
TRY
{
ui_out_text (out, ":");
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 52038e3..d8466f1 100644
PR tui/21216
* tui/tui-file.c (tui_file::write): New.
* tui/tui-file.h (tui_file): Override "write".
### a/gdb/testsuite/ChangeLog
### b/gdb/testsuite/ChangeLog
## -1,3 +1,8 @@
+2016-10-31 Tom Tromey <tom@tromey.com>
## -1,4 +1,12 @@
2017-03-08 Pedro Alves <palves@redhat.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.python/py-framefilter.py (ElidingFrameDecorator.address):
+ New method.
+ PR cli/21218
+ * gdb.base/commands.exp (backslash_in_multi_line_command_test):
+ New proc.
+ (top level): Call it.
+
2016-10-28 Pedro Alves <palves@redhat.com>
+2017-03-08 Pedro Alves <palves@redhat.com>
* gdb.base/maint.exp <maint info line-table w/o a file name>: Use
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py
index 8fdff84..2580911 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.py
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -92,6 +92,12 @@ class ElidingFrameDecorator(FrameDecorator):
def elided(self):
return iter(self.elided_frames)
PR tui/21216
* gdb.tui/tui-nl-filtered-output.exp: New file.
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -759,6 +759,34 @@ proc redefine_backtrace_test {} {
"execute bt command in redefine_backtrace_test"
}
+ def address (self):
+ # Regression test for an overflow in the python layer.
+ bitsize = 8 * gdb.lookup_type('void').pointer().sizeof
+ mask = (1 << bitsize) - 1
+ return 0xffffffffffffffff & mask
+# Test an input line split with a continuation character (backslash)
+# while entering a multi-line command (in a secondary prompt).
+
class ElidingIterator:
def __init__(self, ii):
self.input_iterator = ii
+proc backslash_in_multi_line_command_test {} {
+ gdb_breakpoint "main"
+
+ gdb_test_multiple "commands" "commands" {
+ -re "End with a line saying just \"end\"\\.\r\n>$" {
+ pass "commands"
+ }
+ }
+
+ set test "input line split with backslash"
+ send_gdb "print \\\nargc\n"
+ gdb_test_multiple "" $test {
+ -re "^print \\\\\r\nargc\r\n>$" {
+ pass $test
+ }
+ }
+
+ gdb_test_no_output "end"
+
+ # Input any command, just to be sure the readline state is sane.
+ # In PR 21218, this would trigger the infamous:
+ # readline: readline_callback_read_char() called with no handler!
+ gdb_test "print 1" "" "run command"
+}
+
gdbvar_simple_if_test
gdbvar_simple_while_test
gdbvar_complex_if_while_test
@@ -1027,5 +1055,6 @@ recursive_source_test
if_commands_test
error_clears_commands_left
redefine_hook_test
+backslash_in_multi_line_command_test
# This one should come last, as it redefines "backtrace".
redefine_backtrace_test
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1030,8 +1030,11 @@ gdb_readline_wrapper (const char *prompt)
if (cleanup->target_is_async_orig)
target_async (0);
- /* Display our prompt and prevent double prompt display. */
- display_gdb_prompt (prompt);
+ /* Display our prompt and prevent double prompt display. Don't pass
+ down a NULL prompt, since that has special meaning for
+ display_gdb_prompt -- it indicates a request to print the primary
+ prompt, while we want a secondary prompt here. */
+ display_gdb_prompt (prompt != NULL ? prompt : "");
if (ui->command_editing)
rl_already_prompted = 1;
@@ -1307,6 +1310,9 @@ command_line_input (const char *prompt_arg, int repeat, char *annotation_suffix)
if (cmd != NULL)
break;
+ /* Got partial input. I.e., got a line that ends with a
+ continuation character (backslash). Suppress printing the
+ prompt again. */
prompt = NULL;
}

View File

@ -27,17 +27,19 @@ cannot reproduce it.
Thanks,
Jan
--- ./gdb/dwarf2loc.c 2016-08-29 04:01:25.000000000 +0200
+++ ./gdb/dwarf2loc.c 2016-09-01 11:00:20.258909494 +0200
@@ -2289,6 +2289,15 @@ const struct dwarf_expr_context_funcs dw
Index: gdb-7.12.1/gdb/dwarf2loc.c
===================================================================
--- gdb-7.12.1.orig/gdb/dwarf2loc.c 2017-04-19 21:46:34.791753815 +0200
+++ gdb-7.12.1/gdb/dwarf2loc.c 2017-04-19 21:58:08.252106538 +0200
@@ -2289,6 +2289,15 @@
dwarf_expr_get_obj_addr
};
+static void
+select_frame_cleanup (void *arg)
+{
+ struct frame_info *frame = (struct frame_info *) arg;
+
+ frame_id *frame_id_p = (frame_id *) arg;
+ struct frame_info *frame (frame_find_by_id (*frame_id_p));
+ if (frame != NULL)
+ select_frame (frame);
+}
@ -45,22 +47,23 @@ Jan
/* Evaluate a location description, starting at DATA and with length
SIZE, to find the current location of variable of TYPE in the
context of FRAME. BYTE_OFFSET is applied after the contents are
@@ -2318,6 +2327,11 @@ dwarf2_evaluate_loc_desc_full (struct ty
@@ -2318,6 +2327,12 @@
ctx = new_dwarf_expr_context ();
old_chain = make_cleanup_free_dwarf_expr_context (ctx);
+
+ make_cleanup (select_frame_cleanup, deprecated_safe_get_selected_frame ());
+ frame_id selected_frame_id (get_frame_id (deprecated_safe_get_selected_frame ()));
+ make_cleanup (select_frame_cleanup, &selected_frame_id);
+ if (frame != NULL)
+ select_frame (frame);
+
value_chain = make_cleanup_value_free_to_mark (value_mark ());
ctx->gdbarch = get_objfile_arch (objfile);
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
Index: gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 2015-05-31 16:14:05.844545344 +0200
+++ gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 2017-04-19 21:46:34.854754214 +0200
@@ -0,0 +1,24 @@
+! Copyright 2010 Free Software Foundation, Inc.
+!
@ -86,10 +89,10 @@ Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f9
+ real :: dummy
+ dummy = 1
+end subroutine bar
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
Index: gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp 2015-05-31 16:14:05.845545351 +0200
+++ gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp 2017-04-19 21:46:34.854754214 +0200
@@ -0,0 +1,39 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
@ -130,10 +133,10 @@ Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
+}
+
+gdb_test "bt" {foo \(string='hello'.*}
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
Index: gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 2015-05-31 16:14:05.845545351 +0200
+++ gdb-7.12.1/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 2017-04-19 21:46:34.855754220 +0200
@@ -0,0 +1,36 @@
+! Copyright 2010 Free Software Foundation, Inc.
+!

View File

@ -21,14 +21,14 @@ Name: %{?scl_prefix}gdb
%global snapsrc 20160801
# See timestamp of source gnulib installed into gdb/gnulib/ .
%global snapgnulib 20150822
%global tarname gdb-7.12.0.20170111
Version: 7.12
%global tarname gdb-%{version}
Version: 7.12.1
# 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: 37%{?dist}
Release: 48%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL
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
Group: Development/Debuggers
# Do not provide URL for snapshots as the file lasts there only for 2 days.
# ftp://sourceware.org/pub/gdb/releases/FIXME{tarname}.tar.xz
@ -71,10 +71,11 @@ Summary: A GNU source-level debugger for C, C++, Fortran, Go and other languages
Obsoletes: gdb64 < 5.3.91
%endif
%ifarch %{arm}
%global have_inproctrace 0
%ifarch %{ix86} x86_64
%else
%global have_inproctrace 1
%endif # %{ix86} x86_64
%endif
# gdb-add-index cannot be run even for SCL package on RHEL<=6.
%if 0%{!?rhel:1} || 0%{?rhel} > 6
@ -149,7 +150,7 @@ Source3: gdb-gstack.man
Source4: gdbinit
# libstdc++ pretty printers from GCC SVN.
%global libstdcxxpython gdb-libstdc++-v3-python-6.1.1-20160817
%global libstdcxxpython gdb-libstdc++-v3-python-6.3.1-20170212
Source5: %{libstdcxxpython}.tar.xz
# Provide gdbtui for RHEL-5 and RHEL-6 as it is removed upstream (BZ 797664).
@ -1493,7 +1494,8 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc COPYING3 COPYING COPYING.LIB README NEWS
%license COPYING3 COPYING COPYING.LIB COPYING3.LIB
%doc README NEWS
%{_bindir}/gdb
%{_bindir}/gcore
%{_mandir}/*/gcore.1*
@ -1583,6 +1585,30 @@ then
fi
%changelog
* Wed Apr 19 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-48.fc25
- Fix reported gdb-vla-intel-stringbt-fix.patch regression (SuSE).
* Wed Mar 8 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-47.fc25
- Fix EOL escape in multiline command segv (Pedro Alves, RH BZ 1429172).
* Wed Feb 15 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-46.fc25
- Fix <tab>-completion crash (Gary Benson, RH BZ 1398387).
* Tue Feb 14 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-45.fc25
- Release bump.
* Sun Feb 12 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-44.fc25
- [dts] Upgrade libstdc++-v3-python to 6.3.1-20170212.
* Wed Feb 8 2017 Stephen Gallagher <sgallagh@redhat.com> - 7.12.1-42.fc25
- Add missing %%license macro
* Sat Jan 21 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12.1-41.fc25
- Rebase to released FSF GDB 7.12.1.
* Tue Jan 17 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12-40.fc25
- Enable libinproctrace.so on all archs except arm32.
* Thu Jan 12 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.12-37.fc25
- [rhel6] Fix missing /usr/bin/realpath.

View File

@ -1,3 +1,3 @@
SHA512 (gdb-libstdc++-v3-python-6.1.1-20160817.tar.xz) = 2f3030ec6cf379dbfbdb4e515cc47dcb47f25327c046759ad8f117e290e0300eed58969a432552203966cd6b02e5279c95309a4b2228ed98d8cd63f0a4f5cfc4
SHA512 (gdb-libstdc++-v3-python-6.3.1-20170212.tar.xz) = 22ad4187d6bb9851ecf389c3ff4c68f33ccf5602d8f51bc337215c700d56c9073b3fb40ece3f58901315161f76a4fd1d6463c623650317ad96fd9e3f4aba7252
SHA512 (v1.5.tar.gz) = ea3e76291d5b077d5b42061898a1f70af6cbdbccb7d05c59904f322ca1c03f7596cac6a966b80b12d2c2d86212f17d6bde02b1daf92be62e49abcb234e2bacbd
SHA512 (gdb-7.12.0.20170111.tar.xz) = 8673b3614331306633939f3a744185e60405aa5382a06cc68ff189518d7b4d6adc761b63456d9a566a88d0a44174457882a603381d03175a353a65aa60d6db55
SHA512 (gdb-7.12.1.tar.xz) = 0ac8d0a495103611ef41167a08313a010dce6ca4c6d827cbe8558a0c1a1a8a6bfa53f1b7704251289cababbfaaf9e075550cdf741a54d6cd9ca3433d910efcd8