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 2/3] observer, gcore: add corefile notes generation observers


Add two observers around corefile generation:

  - gcore_start
  - gcore_end

2014-05-22  Markus Metzger  <markus.t.metzger@intel.com>

	* gcore.c: Include "observer.h".
	(write_gcore_file): Rename to ...
	(write_gcore_file_1): ...this.
	(write_gcore_file): Call gcore notifiers.

doc/
	* observer.texi (GDB Observers): Add gcore_start and gcore_end.
---
 gdb/doc/observer.texi |  7 +++++++
 gdb/gcore.c           | 28 +++++++++++++++++++++++-----
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index 61acbb2..d1056bd 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -258,3 +258,10 @@ This observer is used for internal testing.  Do not use.
 See testsuite/gdb.gdb/observer.exp.
 @end deftypefun
 
+@deftypefun void gcore_start (void)
+Called before generating a core file.
+@end deftypefun
+
+@deftypefun void gcore_end (void)
+Called after generating a core file.
+@end deftypefun
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 7a4ded7..b4a5ff1 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -35,6 +35,7 @@
 #include "regset.h"
 #include "gdb_bfd.h"
 #include "readline/tilde.h"
+#include "observer.h"
 
 /* The largest amount of memory to read from the target at once.  We
    must throttle it to limit the amount of memory used by GDB during
@@ -61,12 +62,10 @@ create_gcore_bfd (const char *filename)
   return obfd;
 }
 
-/* write_gcore_file -- helper for gcore_command (exported).
-   Compose and write the corefile data to the core file.  */
-
+/* write_gcore_file_1 -- do the actual work of write_gcore_file.  */
 
-void
-write_gcore_file (bfd *obfd)
+static void
+write_gcore_file_1 (bfd *obfd)
 {
   struct cleanup *cleanup;
   void *note_data = NULL;
@@ -111,6 +110,25 @@ write_gcore_file (bfd *obfd)
   do_cleanups (cleanup);
 }
 
+/* write_gcore_file -- helper for gcore_command (exported).
+   Compose and write the corefile data to the core file.  */
+
+void
+write_gcore_file (bfd *obfd)
+{
+  volatile struct gdb_exception except;
+
+  observer_notify_gcore_start ();
+
+  TRY_CATCH (except, RETURN_MASK_ALL)
+    write_gcore_file_1 (obfd);
+
+  observer_notify_gcore_end ();
+
+  if (except.reason < 0)
+    throw_exception (except);
+}
+
 static void
 do_bfd_delete_cleanup (void *arg)
 {
-- 
1.8.3.1


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