aboutsummaryrefslogtreecommitdiff
path: root/gdb/event-top.c
diff options
context:
space:
mode:
authorPhil Muldoon <pmuldoon@redhat.com>2011-07-22 09:22:50 +0000
committerPhil Muldoon <pmuldoon@redhat.com>2011-07-22 09:22:50 +0000
commit95298e7219e23ca184786a3192df7ab3767ce25a (patch)
tree9a6cab41de43472730cff069d4ed959c3835b6d5 /gdb/event-top.c
parent14d153035333735c0c62c7ee2e92f2b0e65953f8 (diff)
downloadgdb-95298e7219e23ca184786a3192df7ab3767ce25a.zip
gdb-95298e7219e23ca184786a3192df7ab3767ce25a.tar.gz
gdb-95298e7219e23ca184786a3192df7ab3767ce25a.tar.bz2
2011-07-22 Phil Muldoon <pmuldoon@redhat.com>
* event-top.c (cli_command_loop): Use get_prompt, get_suffix, get_prefix. (display_gdb_prompt): Likewise. (change_annotation_level): Likewise. (push_prompt): Likewise. (pop_prompt): Likewise. (handle_stop_sig): Use get_prompt with a level. * top.c (command_loop): Use get_prompt with a level. (set_async_annotation_level): Use set_prompt with a level. (get_prefix): New function. (set_prefix): Ditto. (set_suffix): Ditto. (get_suffix): Ditto. (get_prompt): Accept a level argument. (set_prompt): Accept a level argument. Free old prompts. Set new_async_prompt if level is 0. (init_main): Use set_prompt with a level. Do not set new_async_prompt. * event-top.h (PROMPT, SUFFIX, PREFIX): Move to top.c * top.h: Declare set_suffix, get_suffix, set_prefix, get_prefix. Modify set_prompt, get_prompt to account for levels. * tui/tui-interp.c (tui_command_loop): Use get_prompt with a level * python/python.c (before_prompt_hook): Use set_prompt.
Diffstat (limited to 'gdb/event-top.c')
-rw-r--r--gdb/event-top.c61
1 files changed, 29 insertions, 32 deletions
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 22f9440..37882728 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -191,17 +191,17 @@ cli_command_loop (void)
{
int length;
char *a_prompt;
- char *gdb_prompt = get_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 (PREFIX (0))
- + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
+ length = strlen (get_prefix (0))
+ + strlen (gdb_prompt) + strlen (get_suffix(0)) + 1;
a_prompt = (char *) alloca (length);
- strcpy (a_prompt, PREFIX (0));
+ strcpy (a_prompt, get_prefix (0));
strcat (a_prompt, gdb_prompt);
- strcat (a_prompt, SUFFIX (0));
+ strcat (a_prompt, get_suffix (0));
rl_callback_handler_install (a_prompt, input_handler);
}
else
@@ -276,10 +276,10 @@ display_gdb_prompt (char *new_prompt)
if (! new_prompt)
{
char *post_gdb_prompt = NULL;
- char *pre_gdb_prompt = xstrdup (get_prompt ());
+ char *pre_gdb_prompt = xstrdup (get_prompt (0));
observer_notify_before_prompt (pre_gdb_prompt);
- post_gdb_prompt = get_prompt ();
+ post_gdb_prompt = get_prompt (0);
/* If the observer changed the prompt, use that prompt. */
if (strcmp (pre_gdb_prompt, post_gdb_prompt) != 0)
@@ -317,18 +317,18 @@ display_gdb_prompt (char *new_prompt)
if (! new_prompt)
{
/* Just use the top of the prompt stack. */
- prompt_length = strlen (PREFIX (0)) +
- strlen (SUFFIX (0)) +
- strlen (get_prompt()) + 1;
+ prompt_length = strlen (get_prefix (0)) +
+ strlen (get_suffix (0)) +
+ strlen (get_prompt (0)) + 1;
actual_gdb_prompt = (char *) alloca (prompt_length);
/* Prefix needs to have new line at end. */
- strcpy (actual_gdb_prompt, PREFIX (0));
- strcat (actual_gdb_prompt, get_prompt());
+ strcpy (actual_gdb_prompt, get_prefix (0));
+ strcat (actual_gdb_prompt, get_prompt (0));
/* Suffix needs to have a new line at end and \032 \032 at
beginning. */
- strcat (actual_gdb_prompt, SUFFIX (0));
+ strcat (actual_gdb_prompt, get_suffix (0));
}
else
actual_gdb_prompt = new_prompt;;
@@ -361,7 +361,7 @@ change_annotation_level (void)
{
char *prefix, *suffix;
- if (!PREFIX (0) || !PROMPT (0) || !SUFFIX (0))
+ if (!get_prefix (0) || !get_prompt (0) || !get_suffix (0))
{
/* The prompt stack has not been initialized to "", we are
using gdb w/o the --async switch. */
@@ -371,7 +371,7 @@ change_annotation_level (void)
if (annotation_level > 1)
{
- if (!strcmp (PREFIX (0), "") && !strcmp (SUFFIX (0), ""))
+ if (!strcmp (get_prefix (0), "") && !strcmp (get_suffix (0), ""))
{
/* Push a new prompt if the previous annotation_level was not >1. */
prefix = (char *) alloca (strlen (async_annotation_suffix) + 10);
@@ -389,7 +389,7 @@ change_annotation_level (void)
}
else
{
- if (strcmp (PREFIX (0), "") && strcmp (SUFFIX (0), ""))
+ if (strcmp (get_prefix (0), "") && strcmp (get_suffix (0), ""))
{
/* Pop the top of the stack, we are going back to annotation < 1. */
pop_prompt ();
@@ -405,17 +405,17 @@ void
push_prompt (char *prefix, char *prompt, char *suffix)
{
the_prompts.top++;
- PREFIX (0) = xstrdup (prefix);
+ set_prefix (prefix, 0);
/* Note that this function is used by the set annotate 2
command. This is why we take care of saving the old prompt
in case a new one is not specified. */
if (prompt)
- PROMPT (0) = xstrdup (prompt);
+ set_prompt (prompt, 0);
else
- PROMPT (0) = xstrdup (PROMPT (-1));
+ set_prompt (get_prompt (-1), 0);
- SUFFIX (0) = xstrdup (suffix);
+ set_suffix (suffix, 0);
}
/* Pops the top of the prompt stack, and frees the memory allocated
@@ -425,20 +425,17 @@ pop_prompt (void)
{
/* If we are not during a 'synchronous' execution command, in which
case, the top prompt would be empty. */
- if (strcmp (PROMPT (0), ""))
+ if (strcmp (get_prompt (0), ""))
/* This is for the case in which the prompt is set while the
annotation level is 2. The top prompt will be changed, but when
we return to annotation level < 2, we want that new prompt to be
in effect, until the user does another 'set prompt'. */
- if (strcmp (PROMPT (0), PROMPT (-1)))
- {
- xfree (PROMPT (-1));
- PROMPT (-1) = xstrdup (PROMPT (0));
- }
-
- xfree (PREFIX (0));
- xfree (PROMPT (0));
- xfree (SUFFIX (0));
+ if (strcmp (get_prompt (0), get_prompt (-1)))
+ set_prompt (get_prompt (0), -1);
+
+ set_prefix (NULL, 0);
+ set_prompt (NULL, 0);
+ set_suffix (NULL, 0);
the_prompts.top--;
}
@@ -983,7 +980,7 @@ handle_stop_sig (int sig)
static void
async_stop_sig (gdb_client_data arg)
{
- char *prompt = get_prompt ();
+ char *prompt = get_prompt (0);
#if STOP_SIGNAL == SIGTSTP
signal (SIGTSTP, SIG_DFL);
@@ -1061,7 +1058,7 @@ set_async_annotation_level (char *args, int from_tty,
void
set_async_prompt (char *args, int from_tty, struct cmd_list_element *c)
{
- PROMPT (0) = xstrdup (new_async_prompt);
+ set_prompt (new_async_prompt, 0);
}
/* Set things up for readline to be invoked via the alternate