[binutils-gdb/gdb-8.2-branch] Make command-repeat work after gdb.execute

Pedro Alves palves@sourceware.org
Wed Nov 21 17:25:00 GMT 2018


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7d9e516326ff542b3c9c85a3c08be2622d9126b6

commit 7d9e516326ff542b3c9c85a3c08be2622d9126b6
Author: Benno Fünfstück <benno.fuenfstueck@gmail.com>
Date:   Wed Nov 21 17:16:25 2018 +0000

    Make command-repeat work after gdb.execute
    
    Since commit
    
      56bcdbea2bed ("Let gdb.execute handle multi-line commands")
    
    command repetition after using the `gdb.execute` Python function
    fails (the previous command is not repeated anymore). This happens
    because read_command_lines_1 sets dont_repeat, but the call to
    prevent_dont_repeat in execute_gdb_command is later.
    
    The fix is to move the call to prevent_dont_repeat to the beginning of
    the function.
    
    Tested on my laptop (ArchLinux-x86_64).
    
    gdb/ChangeLog:
    
    	PR python/23714
    	* gdb/python/python.c (execute_gdb_command): Call
    	prevent_dont_repeat earlier to avoid affecting dont_repeat.
    
    gdb/testuite/ChangeLog:
    
    	PR python/23714
    	* gdb.python/python.exp: Test command repetition after
    	gdb.execute.

Diff:
---
 gdb/ChangeLog                       | 6 ++++++
 gdb/python/python.c                 | 3 ++-
 gdb/testsuite/ChangeLog             | 6 ++++++
 gdb/testsuite/gdb.python/python.exp | 1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 01fc8fa..22d9e77 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-21  Benno Fünfstück  <benno.fuenfstueck@gmail.com>
+
+	PR python/23714
+	* gdb/python/python.c (execute_gdb_command): Call
+	prevent_dont_repeat earlier to avoid affecting dont_repeat.
+
 2018-11-08  Tom Tromey  <tom@tromey.com>
 
 	PR gdb/23555:
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 55119cc..bc9f4e0 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -584,6 +584,8 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 
   std::string to_string_res;
 
+  scoped_restore preventer = prevent_dont_repeat ();
+
   TRY
     {
       struct interp *interp;
@@ -611,7 +613,6 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
       interp = interp_lookup (current_ui, "console");
       current_uiout = interp->interp_ui_out ();
 
-      scoped_restore preventer = prevent_dont_repeat ();
       if (to_string)
 	to_string_res = execute_control_commands_to_string (lines.get (),
 							    from_tty);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 65557f4..a5e0a4f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-21  Benno Fünfstück  <benno.fuenfstueck@gmail.com>
+
+	PR python/23714
+	* gdb.python/python.exp: Test command repetition after
+	gdb.execute.
+
 2018-11-19  Pedro Alves  <palves@redhat.com>
 
 	* gdb.base/warning.exp: Don't override INTERNAL_FLAGS.  Use
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index a37113c..fca9ab0 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -121,6 +121,7 @@ gdb_test "python print (x)" "23"
 
 gdb_test "python gdb.execute('echo 2\\necho 3\\\\n\\n')" "23" \
     "multi-line execute"
+gdb_test " " "23" "gdb.execute does not affect repeat history"
 
 # Test post_event.
 gdb_py_test_multiple "post event insertion" \



More information about the Gdb-cvs mailing list