From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [RFC/WIP PATCH 07/14] Expand %ITSET% in the prompt to the current I/T set.
Date: Mon, 28 Nov 2011 15:40:00 -0000 [thread overview]
Message-ID: <20111128153931.17761.19802.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111128153742.17761.21459.stgit@localhost6.localdomain6>
This adds a simple hook that allows expanding "%ITSET%" in the prompt
to the current set.
Here's how I use it currently:
$ gdb -q -nx -ex "set prompt %ITSET%> " ~/gdb/tests/threads
[all]> info threads
Id Target Id Frame
3 Thread 0x7ffff7028700 (LWP 6890) "threads" 0x00007ffff7bcc78e in __lll_lock_wait_private () from /lib/x86_64-linux-gnu/libpthread.so.0
* 2 Thread 0x7ffff7829700 (LWP 6889) "threads" thread_function0 (arg=0x0) at threads.c:63
1 Thread 0x7ffff7fcb720 (LWP 6884) "threads" 0x00007ffff7910011 in clone () from /lib/x86_64-linux-gnu/libc.so.6
[all]> itfocus [1.1]
New focus: Current inferior is 1.
[1.1]>
Not sure this is the way to go, or whether we'll only support this
through python. This was simple enough to make sure I could work on
the rest of the stuff without getting lost. I'll also make use of
this in all examples in this series.
---
gdb/event-top.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index a276690..de040cb 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -23,6 +23,7 @@
#include "defs.h"
#include "top.h"
#include "inferior.h"
+#include "itset.h"
#include "target.h"
#include "terminal.h" /* for job_control */
#include "event-loop.h"
@@ -36,6 +37,7 @@
#include "observer.h"
#include "continuations.h"
#include "gdbcmd.h" /* for dont_repeat() */
+#include "gdb_obstack.h"
/* readline include files. */
#include "readline/readline.h"
@@ -215,6 +217,38 @@ change_line_handler (void)
}
}
+static char *
+expand_gdb_prompt (char *prompt)
+{
+ struct obstack obstack;
+ char *p;
+
+ obstack_init (&obstack);
+
+ p = prompt;
+ while (*p)
+ {
+ if (CONST_STRNEQ (p, "%ITSET%"))
+ {
+ obstack_grow_str (&obstack, "[");
+ if (itset_name (current_itset) != NULL)
+ obstack_grow_str (&obstack, itset_name (current_itset));
+ else
+ obstack_grow_str (&obstack, itset_spec (current_itset));
+ obstack_grow_str (&obstack, "]");
+ p += sizeof ("%ITSET%") - 1;
+ continue;
+ }
+
+ obstack_1grow (&obstack, *p);
+ p++;
+ }
+
+ obstack_1grow (&obstack, '\0');
+
+ return xstrdup (obstack_finish (&obstack));
+}
+
/* Displays the prompt. If the argument NEW_PROMPT is NULL, the
prompt that is displayed is the current top level prompt.
Otherwise, it displays whatever NEW_PROMPT is as a local/secondary
@@ -276,8 +310,12 @@ display_gdb_prompt (char *new_prompt)
}
else
{
+ char *top;
+
/* Display the top level prompt. */
- actual_gdb_prompt = top_level_prompt ();
+ top = top_level_prompt ();
+ actual_gdb_prompt = expand_gdb_prompt (top);
+ xfree (top);
}
}
else
next prev parent reply other threads:[~2011-11-28 15:39 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 15:39 [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 05/14] Add a small helper to get at a thread's inferior Pedro Alves
2011-11-29 21:19 ` Tom Tromey
2011-11-28 15:39 ` [RFC/WIP PATCH 01/14] Breakpoints always-inserted and the record target Pedro Alves
2011-11-29 21:09 ` Tom Tromey
2011-12-05 17:04 ` Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 03/14] Flip to set target-async on by default Pedro Alves
2011-11-29 21:18 ` Tom Tromey
2011-12-02 19:16 ` Marc Khouzam
2011-11-28 15:39 ` [RFC/WIP PATCH 02/14] Mask software breakpoints from memory writes too Pedro Alves
2011-12-06 20:40 ` Pedro Alves
2011-12-13 21:26 ` Andreas Schwab
2011-12-13 21:38 ` Pedro Alves
2011-12-14 2:08 ` Andreas Schwab
2011-12-14 12:53 ` Pedro Alves
2011-12-14 12:53 ` Andreas Schwab
2011-12-14 15:06 ` Pedro Alves
2011-12-14 15:38 ` Joel Brobecker
2011-11-28 15:40 ` [RFC/WIP PATCH 08/14] Add support for the '@' core operator Pedro Alves
2011-11-30 17:29 ` Tom Tromey
2011-11-28 15:40 ` [RFC/WIP PATCH 13/14] Make "thread apply all" only loop over threads in the current set Pedro Alves
2011-11-28 18:40 ` Eli Zaretskii
2011-11-28 18:56 ` Pedro Alves
2011-11-29 21:47 ` Tom Tromey
2011-12-16 18:47 ` Pedro Alves
2011-11-28 15:40 ` Pedro Alves [this message]
2011-11-29 21:22 ` [RFC/WIP PATCH 07/14] Expand %ITSET% in the prompt to the current I/T set Tom Tromey
2011-12-16 19:07 ` Pedro Alves
2011-12-16 19:09 ` Tom Tromey
2011-12-16 19:38 ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 09/14] I/T set support for breakpoints - trigger set, and stop set Pedro Alves
2011-11-29 22:02 ` Tom Tromey
2011-11-30 19:38 ` Tom Tromey
2011-12-16 19:29 ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 10/14] Comment out new info breakpoints output, in order to not break the test suite Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 04/14] Implement all-stop on top of a target running non-stop mode Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 12/14] Fix deref of stale pointer Pedro Alves
2011-11-28 15:45 ` [RFC/WIP PATCH 06/14] Add base itsets support Pedro Alves
2011-11-28 18:47 ` Eli Zaretskii
2011-11-28 18:56 ` Pedro Alves
2011-11-29 22:07 ` Tom Tromey
2011-11-30 18:54 ` Tom Tromey
2011-12-16 17:26 ` Pedro Alves
2011-11-28 15:45 ` [RFC/WIP PATCH 14/14] Fix manythreads.exp test Pedro Alves
2011-11-28 15:46 ` [RFC/WIP PATCH 11/14] Add I/T set support to most execution commands Pedro Alves
2011-11-30 19:27 ` Tom Tromey
2011-11-28 18:10 ` [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-30 19:35 ` Tom Tromey
2011-12-16 19:40 ` Pedro Alves
2012-02-09 7:51 ` Tomas Östlund
2012-02-09 8:19 ` [RFC/WIP PATCH 00/14] I/T sets (resend) Tomas Östlund
2012-02-09 14:36 ` Pedro Alves
2012-02-15 9:48 ` Tomas Östlund
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=20111128153931.17761.19802.stgit@localhost6.localdomain6 \
--to=pedro@codesourcery.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