From: "Benno Fünfstück" <benno.fuenfstueck@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH][PR python/23714] Make command-repeat work after gdb.execute
Date: Wed, 21 Nov 2018 14:50:00 -0000 [thread overview]
Message-ID: <CALpAkBMOACHJ-UdN1VW5RTfbVFf8NoHcgh7wKhk3bXiS3n_xKw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 858 bytes --]
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 gdb.execute("show commands").
---
gdb/python/python.c | 3 ++-
gdb/testsuite/gdb.python/python.exp | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
[-- Attachment #2: 0001-python-Make-command-repeat-work-after-gdb.execute.patch --]
[-- Type: text/x-patch, Size: 2333 bytes --]
From a173a1a58cf842540c01e8a303b3f44045fdfd4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Benno=20F=C3=BCnfst=C3=BCck?= <benno.fuenfstueck@gmail.com>
Date: Wed, 21 Nov 2018 15:28:00 +0100
Subject: [PATCH] python: 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 gdb.execute("show commands").
---
gdb/python/python.c | 3 ++-
gdb/testsuite/gdb.python/python.exp | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index a37ed10bcf..d6453e786c 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" \
--
2.19.1
next reply other threads:[~2018-11-21 14:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 14:50 Benno Fünfstück [this message]
2018-11-21 17:12 ` Pedro Alves
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=CALpAkBMOACHJ-UdN1VW5RTfbVFf8NoHcgh7wKhk3bXiS3n_xKw@mail.gmail.com \
--to=benno.fuenfstueck@gmail.com \
--cc=gdb-patches@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).