public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Fix valgrind error from gdb.decode_line
Date: Wed, 15 Jan 2020 04:55:00 -0000	[thread overview]
Message-ID: <ff47f4f06d296b672337e2c7363a745cd2725f58@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT ff47f4f06d296b672337e2c7363a745cd2725f58 ***

commit ff47f4f06d296b672337e2c7363a745cd2725f58
Author:     Tom Tromey <tom@tromey.com>
AuthorDate: Sat Dec 21 09:51:05 2019 -0700
Commit:     Tom Tromey <tom@tromey.com>
CommitDate: Tue Jan 14 17:57:52 2020 -0700

    Fix valgrind error from gdb.decode_line
    
    PR symtab/12535 points out that gdb.decode_line("") will cause a
    valgrind report.
    
    I think the empty linespec does not really make sense.  So, this patch
    changes gdb.decode_line to treat a whitespace-only linespec the same
    as a non-existing argument.
    
    gdb/ChangeLog
    2020-01-14  Tom Tromey  <tom@tromey.com>
    
            PR symtab/12535:
            * python/python.c (gdbpy_decode_line): Treat empty string the same
            as no argument.
    
    gdb/testsuite/ChangeLog
    2020-01-14  Tom Tromey  <tom@tromey.com>
    
            PR symtab/12535:
            * gdb.python/python.exp: Test decode_line with empty string
            argument.
    
    Change-Id: I1d95812b4b7a21d69a3e9afd05b9e3141a931897

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 213f2d0395..d348abbf58 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-14  Tom Tromey  <tom@tromey.com>
+
+	PR symtab/12535:
+	* python/python.c (gdbpy_decode_line): Treat empty string the same
+	as no argument.
+
 2020-01-14  Tom Tromey  <tom@tromey.com>
 
 	* Makefile.in (CLIBS): Remove second use of $(LIBIBERTY).
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e0c05f1d06..d6f7f99c45 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -810,6 +810,15 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
   if (! PyArg_ParseTuple (args, "|s", &arg))
     return NULL;
 
+  /* Treat a string consisting of just whitespace the same as
+     NULL.  */
+  if (arg != NULL)
+    {
+      arg = skip_spaces (arg);
+      if (*arg == '\0')
+	arg = NULL;
+    }
+
   if (arg != NULL)
     location = string_to_event_location_basic (&arg, python_language,
 					       symbol_name_match_type::WILD);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4c1e6040d6..fd9ba7ea61 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-14  Tom Tromey  <tom@tromey.com>
+
+	PR symtab/12535:
+	* gdb.python/python.exp: Test decode_line with empty string
+	argument.
+
 2020-01-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
 	* gdb.base/skip-inline.exp: Extend test.
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index f002497e9d..a50a7b43e2 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -234,6 +234,10 @@ gdb_test "python print (len(symtab))" "2" "test decode_line current location"
 gdb_test "python print (symtab\[0\])" "None" "test decode_line expression parse"
 gdb_test "python print (len(symtab\[1\]))" "1" "test decode_line current location"
 
+# Test that decode_line with an empty string argument does not crash.
+gdb_py_test_silent_cmd "python symtab2 = gdb.decode_line('')" \
+    "test decode_line with empty string" 1
+
 if { [is_remote host] } {
     set python_c [string_to_regexp "python.c"]
 } else {


             reply	other threads:[~2020-01-15  4:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15  4:55 gdb-buildbot [this message]
2020-01-15  4:53 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot
2020-01-15  5:09 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-01-17  4:09 ` *** COMPILATION FAILED *** Failures on Fedora-i686, branch master *** BREAKAGE *** gdb-buildbot
2020-01-17  4:35 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-01-17  4:39 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-01-17  4:41 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot
2020-01-17  4:42 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-w64-mingw32, " gdb-buildbot
2020-01-17  4:42 ` Failures on Fedora-x86_64-m32, branch master gdb-buildbot
2020-01-17  4:51 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-native-gdbserver-m64, branch master *** BREAKAGE *** gdb-buildbot
2020-01-17  5:04 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master gdb-buildbot
2020-01-17  5:06 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff47f4f06d296b672337e2c7363a745cd2725f58@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).