This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 02/18] New command_post observer


Just as the current language, or current inferior, or current thread,
affect some of the commands being issued by the user to the debugger,
with multi-partition systems, we now have a current partition (formerly
known as a Protection Domain, or PD).

What we are trying to do is to keep the user informed of the current
PD (which is identified by either PD ID or name, but we like to print
both).

The problem is that we cannot just print a message everytime the PD
gets switched, because many commands result in a temporary switch of
partition.  For instance, info threads will need to switch to the
associated PDs in order to get the PC and associated symbolic info.
We don't want to write the notification for each switch. However, we
do want to print that notification if we just hit a breakpoint for
some code living in a different partition...

The way we solved this is by remembering the PD ID before we issued
the last command.  At the end of a command execution, if the PD ID
changed, then we write a notification...

This patch introduces an observer (command_post) that gets triggered
at the end of a command execution...

gdb/ChangeLog:

        * doc/observer.texi (command_post): New observer.
        * top.c: #include "observer.h".
        (execute_command): Call observer_notify_command_post.
---
 gdb/doc/observer.texi |    4 ++++
 gdb/top.c             |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index d16c865..f136113 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -132,6 +132,10 @@ Called with @var{objfile} equal to @code{NULL} to indicate
 previously loaded symbol table data has now been invalidated.
 @end deftypefun
 
+@deftypefun void command_post (void)
+The debugger just finished executing a command.
+@end deftypefun
+
 @deftypefun void new_thread (struct thread_info *@var{t})
 The thread specified by @var{t} has been created.
 @end deftypefun
diff --git a/gdb/top.c b/gdb/top.c
index df2b163..a8d2e5a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -64,6 +64,7 @@
 #include <ctype.h>
 #include "ui-out.h"
 #include "cli-out.h"
+#include "observer.h"
 
 /* Default command line prompt.  This is overriden in some configs.  */
 
@@ -462,6 +463,9 @@ execute_command (char *p, int from_tty)
 	  warned = 1;
 	}
     }
+
+  /* Emit the "command_post" notification.  */
+  observer_notify_command_post ();
 }
 
 /* Run execute_command for P and FROM_TTY.  Capture its output into the
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]