Summary: | Command repetition stops working after gdb.execute | ||
---|---|---|---|
Product: | gdb | Reporter: | Gonçalo Santos <ossgoncalo> |
Component: | python | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | benno.fuenfstueck, pedro, tromey |
Priority: | P2 | ||
Version: | 8.2 | ||
Target Milestone: | 8.2.1 | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Gonçalo Santos
2018-09-25 19:20:04 UTC
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" \ (In reply to Benno Fünfstück from comment #1) > 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: 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? The master branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c97054b87495b008c6028d697deff61c9fb0b6e commit 1c97054b87495b008c6028d697deff61c9fb0b6e Author: Benno F�nfst�ck <benno.fuenfstueck@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. The gdb-8.2-branch branch has been updated by Pedro Alves <palves@sourceware.org>: 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. Fix merged. |