From: Matt Rice <ratmice@gmail.com>
To: gdb-patches@sourceware.org
Subject: [patch] python prompt additions at first prompt.
Date: Sat, 30 Jul 2011 22:20:00 -0000 [thread overview]
Message-ID: <CACTLOFrL0opOKGAiE3j5yPyGL6Dg5TT+vW3nqg0mX1Z0krZbsQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]
little bug with the new python prompt stuff, the prompt_hook doesn't
take effect until the second prompt.
I couldn't for the life of me figure out how to do a testcase for this...
using gdb.mi/mi-async.exp as an example of using -ex it still didn't
want to work,
there was also the need to match the very first prompt.
and command line python stuff seems to go awry of how skip_python_tests works.
sorry.
before:
gdb/gdb -quiet -ex 'set prompt (foo) ' -ex 'python def prompt(x):
return "(bar) "' -ex 'python gdb.prompt_hook = prompt'
(foo)
(bar) quit
~/git/gdb/gdb/gdb -quiet -ex 'python def prompt(x): return "(bar) "'
-ex 'python gdb.prompt_hook = prompt'
(gdb)
(bar) quit
after:
gdb/gdb -quiet -ex 'set prompt (foo) ' -ex 'python def prompt(x):
return "(bar) "' -ex 'python gdb.prompt_hook = prompt'
(bar)
(bar) quit
gdb/gdb -quiet -ex 'python def prompt(x): return "(bar) "' -ex 'python
gdb.prompt_hook = prompt'
(bar)
(bar) quit
ran the above things with --enable-tui --disable-tui plus gdb --interpreter=tui
and ran the testsuite with --enable-tui and --disable-tui.
didn't see anything but what looked like tests that fail randomly.
I think it's ok anyways, the 'if (async_command_editing_p)' case in
display_gdb_prompt seems to cover it,
with the addition of rl_callback_handler_remove() which afaict seemed
ok to call before a handler is installed
otherwise, there is a workaround
calling gdb.execute("set prompt " + prompt("foo"))
Thanks.
2011-07-30 Matt Rice <ratmice@gmail.com>
* event-top.c (cli_command_loop): Remove code redundant to
display_gdb_prompt.
* tui/tui-interp.c (tui_command_loop): Ditto.
[-- Attachment #2: foo.diff --]
[-- Type: text/x-patch, Size: 2351 bytes --]
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 37882728..fb0478f 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -185,27 +185,7 @@ rl_callback_read_char_wrapper (gdb_client_data client_data)
void
cli_command_loop (void)
{
- /* If we are using readline, set things up and display the first
- prompt, otherwise just print the prompt. */
- if (async_command_editing_p)
- {
- int length;
- char *a_prompt;
- char *gdb_prompt = get_prompt (0);
-
- /* Tell readline what the prompt to display is and what function
- it will need to call after a whole line is read. This also
- displays the first prompt. */
- length = strlen (get_prefix (0))
- + strlen (gdb_prompt) + strlen (get_suffix(0)) + 1;
- a_prompt = (char *) alloca (length);
- strcpy (a_prompt, get_prefix (0));
- strcat (a_prompt, gdb_prompt);
- strcat (a_prompt, get_suffix (0));
- rl_callback_handler_install (a_prompt, input_handler);
- }
- else
- display_gdb_prompt (0);
+ display_gdb_prompt (0);
/* Now it's time to start the event loop. */
start_event_loop ();
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 919d1ac..9e34412 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -139,27 +139,7 @@ tui_exec (void *data, const char *command_str)
static void
tui_command_loop (void *data)
{
- /* If we are using readline, set things up and display the first
- prompt, otherwise just print the prompt. */
- if (async_command_editing_p)
- {
- int length;
- char *a_prompt;
- char *gdb_prompt = get_prompt (0);
-
- /* Tell readline what the prompt to display is and what function
- it will need to call after a whole line is read. This also
- displays the first prompt. */
- length = strlen (get_prefix (0))
- + strlen (gdb_prompt) + strlen (get_suffix (0)) + 1;
- a_prompt = (char *) alloca (length);
- strcpy (a_prompt, get_prefix (0));
- strcat (a_prompt, gdb_prompt);
- strcat (a_prompt, get_suffix (0));
- rl_callback_handler_install (a_prompt, input_handler);
- }
- else
- display_gdb_prompt (0);
+ display_gdb_prompt (0);
/* Loop until there is nothing to do. This is the entry point to the
event loop engine. gdb_do_one_event, called via catch_errors()
next reply other threads:[~2011-07-30 14:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-30 22:20 Matt Rice [this message]
2011-08-01 9:51 ` Phil Muldoon
2011-08-01 14:08 ` Matt Rice
2011-08-01 14:13 ` Phil Muldoon
2011-08-01 17:44 ` Matt Rice
2011-08-02 9:07 ` Phil Muldoon
2011-08-02 17:59 ` Matt Rice
2011-08-02 20:37 ` Phil Muldoon
2011-08-03 18:08 ` Tom Tromey
2011-08-09 0:20 ` Matt Rice
2011-08-09 0:25 ` Matt Rice
2011-08-10 15:21 ` Tom Tromey
2011-08-11 12:03 ` Matt Rice
2011-08-12 13:10 ` Matt Rice
2011-08-12 14:44 ` Pedro Alves
2011-08-12 15:07 ` Matt Rice
2011-08-29 16:23 ` Matt Rice
2011-08-29 16:39 ` Pedro Alves
2011-09-02 14:31 ` Pedro Alves
2011-09-02 21:41 ` Matt Rice
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=CACTLOFrL0opOKGAiE3j5yPyGL6Dg5TT+vW3nqg0mX1Z0krZbsQ@mail.gmail.com \
--to=ratmice@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