Discussion:
[Bug python/23714] New: Command repetition stops working after gdb.execute
ossgoncalo at gmail dot com
2018-09-25 19:20:04 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

Bug ID: 23714
Summary: Command repetition stops working after gdb.execute
Product: gdb
Version: 8.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: ossgoncalo at gmail dot com
Target Milestone: ---

GDB Dashboard is an init configuration which provides a modular visual
interface for GDB using the Python scripting support.

In order to get some information it needs, it may call gdb.execute(command,
to_string=True) (which implies from_tty=False). Some of the commands that cause
the dashboard to redraw (which, in turn, makes it call gdb.execute), cannot be
repeated by just entering an empty line.

When disabling the components that call that function, the functionality is
restored.

A simpler reproduction is to enter "python gdb.execute('echo asd')" as a
command, and see that it is not repeated when entering empty lines. In prior
GDB versions, it will successfully print asd on each enter.

This bug was initially discussed here:
https://github.com/cyrus-and/gdb-dashboard/issues/128
--
You are receiving this mail because:
You are on the CC list for the bug.
benno.fuenfstueck at gmail dot com
2018-10-19 21:46:17 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

Benno Fünfstück <benno.fuenfstueck at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |benno.fuenfstueck at gmail dot com

--- Comment #1 from Benno Fünfstück <benno.fuenfstueck at gmail dot com> ---
This is similar to https://sourceware.org/bugzilla/show_bug.cgi?id=12216 and
regressed due to the recent changes to make gdb.execute support multi-line.

The following patch has a test and should fix the issue:

diff --git a/gdb/python/python.c b/gdb/python/python.c
index 8fbce78469..784b56cec5 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -583,6 +583,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;
@@ -612,7 +614,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/gdb.python/python.exp
b/gdb/testsuite/gdb.python/python.exp
index 0723507af3..cb76a0f8e6 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" "test that gdb.execute does not affect repeat history"

# Test post_event.
gdb_py_test_multiple "post event insertion" \
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-11-14 10:29:41 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Benno Fünfstück from comment #1)
Post by benno.fuenfstueck at gmail dot com
This is similar to https://sourceware.org/bugzilla/show_bug.cgi?id=12216 and
regressed due to the recent changes to make gdb.execute support multi-line.
Thanks for the patch.
gdb patches are reviewed on the mailing list; see
https://sourceware.org/gdb/wiki/ContributionChecklist
for the contribution guidelines. Would you mind sending it
to the list, following that checklist?
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-11-21 17:09:01 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pedro Alves <***@sourceware.org>:

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

commit 1c97054b87495b008c6028d697deff61c9fb0b6e
Author: Benno F�nfst�ck <***@gmail.com>
Date: Wed Nov 21 17:06:05 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.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-11-21 17:25:44 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.2-branch branch has been updated by Pedro Alves
<***@sourceware.org>:

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

commit 7d9e516326ff542b3c9c85a3c08be2622d9126b6
Author: Benno F�nfst�ck <***@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.
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-11-21 12:37:04 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23714

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |palves at redhat dot com
Resolution|--- |FIXED
Target Milestone|--- |8.2.1

--- Comment #5 from Pedro Alves <palves at redhat dot com> ---
Fix merged.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...