[PATCH 2/3] Add a frame_changed observer

Maxime Coste
2013-04-26T19:03:37Z

---
gdb/doc/observer.texi | 4 ++++
gdb/frame.c | 6 ++++++
2 files changed, 10 insertions(+)

diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index adb7085..9653d6b 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -105,6 +105,10 @@ been modified since being loaded by the debugger (by being recompiled,
for instance).
@end deftypefun

+@deftypefun void frame_changed (struct frame_info *@var{frame})
+the selected frame has changed;
+@end deftypefun
+
@deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
@value{GDBN} has just connected to an inferior. For @samp{run},
@value{GDBN} calls this observer while the inferior is still stopped
diff --git a/gdb/frame.c b/gdb/frame.c
index 0a0acda..0e21e33 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1414,6 +1414,9 @@ deprecated_safe_get_selected_frame (void)
void
select_frame (struct frame_info *fi, enum select_frame_reason reason)
{
+ int changed = (reason == REASON_USER || reason == REASON_STOP)
+ && (fi != selected_frame);
+
selected_frame = fi;
/* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
frame is being invalidated. */
@@ -1453,6 +1456,9 @@ select_frame (struct frame_info *fi, enum select_frame_reason reason)
set_language (s->language);
}
}
+
+ if (changed)
+ observer_notify_frame_changed (fi);
}

/* Create an arbitrary (i.e. address specified by user) or innermost frame.
--
1.8.2.1