public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Fix PR python/18984
@ 2016-05-18 23:37 Tom Tromey
  2016-05-20 19:48 ` Tom Tromey
  2016-06-02 18:05 ` Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2016-05-18 23:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes PR python/18984.

The bug is that gdbpy_solib_name uses GDB_PY_LL_ARG, whereas it should
use GDB_PY_LLU_ARG to avoid overflow.

Built and tested on x86-64 Fedora 23.

2016-05-18  Tom Tromey  <tom@tromey.com>

	PR python/18984:
	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.

2016-05-18  Tom Tromey  <tom@tromey.com>

	PR python/18984:
	* gdb.python/py-shared.exp: Add solib_name test.
---
 gdb/ChangeLog                          | 5 +++++
 gdb/python/python.c                    | 4 ++--
 gdb/testsuite/ChangeLog                | 5 +++++
 gdb/testsuite/gdb.python/py-shared.exp | 4 ++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 92024b6..57d9962 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-05-18  Tom Tromey  <tom@tromey.com>
 
+	PR python/18984:
+	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.
+
+2016-05-18  Tom Tromey  <tom@tromey.com>
+
 	* rust-lang.c (rust_subscript): Initialize "high".
 
 2016-05-17  Simon Marchi  <simon.marchi@ericsson.com>
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c706644..1f1fece 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -696,9 +696,9 @@ gdbpy_solib_name (PyObject *self, PyObject *args)
 {
   char *soname;
   PyObject *str_obj;
-  gdb_py_longest pc;
+  gdb_py_ulongest pc;
 
-  if (!PyArg_ParseTuple (args, GDB_PY_LL_ARG, &pc))
+  if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
     return NULL;
 
   soname = solib_name_from_address (current_program_space, pc);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a773c63..ac37598 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-18  Tom Tromey  <tom@tromey.com>
+
+	PR python/18984:
+	* gdb.python/py-shared.exp: Add solib_name test.
+
 2016-05-18  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* gdb.mi/mi-threads-interrupt.c: New file.
diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp
index 8673e54..4192354 100644
--- a/gdb/testsuite/gdb.python/py-shared.exp
+++ b/gdb/testsuite/gdb.python/py-shared.exp
@@ -66,3 +66,7 @@ gdb_test "python print (gdb.solib_name(long(func1)))" "py-shared-sl.sl" "test fu
 gdb_test "p &main" "" "main address"
 gdb_py_test_silent_cmd "python main = gdb.history(0)" "Aquire main address" 1
 gdb_test "python print (gdb.solib_name(long(main)))" "None" "test main solib location"
+
+if {[is_lp64_target]} {
+    gdb_test "python print len(\[gdb.solib_name(0xffffffffffffffff)\])" "1"
+}
-- 
2.5.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] Fix PR python/18984
  2016-05-18 23:37 [RFA] Fix PR python/18984 Tom Tromey
@ 2016-05-20 19:48 ` Tom Tromey
  2016-06-02 18:05 ` Tom Tromey
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2016-05-20 19:48 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom> +    gdb_test "python print len(\[gdb.solib_name(0xffffffffffffffff)\])" "1"

Apparently my build is using Python 2, so this slipped through.
I'll fix up the tests in these patches for Python 3 compatibility.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] Fix PR python/18984
  2016-05-18 23:37 [RFA] Fix PR python/18984 Tom Tromey
  2016-05-20 19:48 ` Tom Tromey
@ 2016-06-02 18:05 ` Tom Tromey
  2016-06-02 18:22   ` Joel Brobecker
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2016-06-02 18:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This fixes PR python/18984.
Tom> The bug is that gdbpy_solib_name uses GDB_PY_LL_ARG, whereas it should
Tom> use GDB_PY_LLU_ARG to avoid overflow.

Tom> Built and tested on x86-64 Fedora 23.

Tom> 2016-05-18  Tom Tromey  <tom@tromey.com>

Tom> 	PR python/18984:
Tom> 	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.

Ping.

This one bit me again today, and the fix is particularly simple.

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] Fix PR python/18984
  2016-06-02 18:05 ` Tom Tromey
@ 2016-06-02 18:22   ` Joel Brobecker
  2016-06-02 19:24     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2016-06-02 18:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hey Tom,

> Tom> This fixes PR python/18984.
> Tom> The bug is that gdbpy_solib_name uses GDB_PY_LL_ARG, whereas it should
> Tom> use GDB_PY_LLU_ARG to avoid overflow.
> 
> Tom> Built and tested on x86-64 Fedora 23.
> 
> Tom> 2016-05-18  Tom Tromey  <tom@tromey.com>
> 
> Tom> 	PR python/18984:
> Tom> 	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.
> 
> Ping.
> 
> This one bit me again today, and the fix is particularly simple.

Sorry about the delay. The code patch looks good to me. For the testcase
patch, you said you'd be adjusting it for Python 3 as well? Just for
the avoidance of doubt, you're pre-approved on that as well. If there
are comments on it, we can address those later, as it wouldn't break
GDB anyways.

Thanks!
-- 
Joel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA] Fix PR python/18984
  2016-06-02 18:22   ` Joel Brobecker
@ 2016-06-02 19:24     ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2016-06-02 19:24 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

Joel> Sorry about the delay. The code patch looks good to me. For the
Joel> testcase patch, you said you'd be adjusting it for Python 3 as
Joel> well?

Yes.  Here's the final patch.  The difference is just adding the parens
needed by the Python 3 'print'.

I tested this against both Python 3 and Python 2.7.

Tom

commit 1b40ec0559f4b24ccdf6b073610c526c4aa33c4d
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Sep 19 17:45:47 2015 -0600

    Fix PR python/18984
    
    This fixes PR python/18984.
    
    The bug is that gdbpy_solib_name uses GDB_PY_LL_ARG, whereas it should
    use GDB_PY_LLU_ARG to avoid overflow.
    
    Built and tested on x86-64 Fedora 23.
    
    2016-06-02  Tom Tromey  <tom@tromey.com>
    
    	PR python/18984:
    	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.
    
    2016-06-02  Tom Tromey  <tom@tromey.com>
    
    	PR python/18984:
    	* gdb.python/py-shared.exp: Add solib_name test.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 18261a7..82d14b3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-02  Tom Tromey  <tom@tromey.com>
+
+	PR python/18984:
+	* python/python.c (gdbpy_solib_name): Use GDB_PY_LLU_ARG.
+
 2016-06-01  Pedro Alves  <palves@redhat.com>
 
 	* remote-fileio.c (remote_fio_ctrl_c_flag, remote_fio_sa)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c706644..1f1fece 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -696,9 +696,9 @@ gdbpy_solib_name (PyObject *self, PyObject *args)
 {
   char *soname;
   PyObject *str_obj;
-  gdb_py_longest pc;
+  gdb_py_ulongest pc;
 
-  if (!PyArg_ParseTuple (args, GDB_PY_LL_ARG, &pc))
+  if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
     return NULL;
 
   soname = solib_name_from_address (current_program_space, pc);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 733dd3c..3b305a6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-02  Tom Tromey  <tom@tromey.com>
+
+	PR python/18984:
+	* gdb.python/py-shared.exp: Add solib_name test.
+
 2016-06-02  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* gdb.mi/mi-memory-changed.exp: Fix filename passed to untested.
diff --git a/gdb/testsuite/gdb.python/py-shared.exp b/gdb/testsuite/gdb.python/py-shared.exp
index 8673e54..4a0c738 100644
--- a/gdb/testsuite/gdb.python/py-shared.exp
+++ b/gdb/testsuite/gdb.python/py-shared.exp
@@ -66,3 +66,7 @@ gdb_test "python print (gdb.solib_name(long(func1)))" "py-shared-sl.sl" "test fu
 gdb_test "p &main" "" "main address"
 gdb_py_test_silent_cmd "python main = gdb.history(0)" "Aquire main address" 1
 gdb_test "python print (gdb.solib_name(long(main)))" "None" "test main solib location"
+
+if {[is_lp64_target]} {
+    gdb_test "python print (len(\[gdb.solib_name(0xffffffffffffffff)\]))" "1"
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-02 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 23:37 [RFA] Fix PR python/18984 Tom Tromey
2016-05-20 19:48 ` Tom Tromey
2016-06-02 18:05 ` Tom Tromey
2016-06-02 18:22   ` Joel Brobecker
2016-06-02 19:24     ` Tom Tromey

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).