public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-oguz: cleanups.
@ 2011-01-24 16:20 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2011-01-24 16:20 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-oguz has been updated
       via  307189b93a22c06d526a5685c815d68fdc7acbeb (commit)
       via  5672c3da169a2594298c2f93550a68ad2f77c5e6 (commit)
       via  a5d799bb2d93f4d3b93e83b648c5b65fcf25aa84 (commit)
       via  e257ab9c5627e6c3dfab00ab109c3d183b563d79 (commit)
       via  00fafec90d37cf43141d04e868e86b9f6fe4f93f (commit)
       via  84f161b0bf0c6ee952979635fa1105d59ea778fb (commit)
       via  f048f6c6c44f1b926866ee933d3e8bb481b8acc4 (commit)
       via  d69c9a449d0e15bd3d3e20a89ab5c84c60221f85 (commit)
       via  b042d24dfe46025145a868c814cc4adcce2843a6 (commit)
       via  4ea3b60667877b8e323899957f87bac66c37cd6f (commit)
       via  fab4c491f256e0f00aaab4b2455d9acc7538a705 (commit)
      from  bee9888c05a8a5a3531a9824749f6c31a7dbaba4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 307189b93a22c06d526a5685c815d68fdc7acbeb
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 16:21:34 2011 -0500

    cleanups.

commit 5672c3da169a2594298c2f93550a68ad2f77c5e6
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 15:08:48 2011 -0500

    update manual.

commit a5d799bb2d93f4d3b93e83b648c5b65fcf25aa84
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 14:54:45 2011 -0500

    Merge signal and breakpoint events into stop registry.

commit e257ab9c5627e6c3dfab00ab109c3d183b563d79
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 14:48:50 2011 -0500

    clean.

commit 00fafec90d37cf43141d04e868e86b9f6fe4f93f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 14:27:52 2011 -0500

    cleanup.

commit 84f161b0bf0c6ee952979635fa1105d59ea778fb
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 12:18:28 2011 -0500

    use PyObject* instead of event_obj*

commit f048f6c6c44f1b926866ee933d3e8bb481b8acc4
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 12:10:18 2011 -0500

    make callbascks PyObject*

commit d69c9a449d0e15bd3d3e20a89ab5c84c60221f85
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jan 21 12:03:15 2011 -0500

    manual.

commit b042d24dfe46025145a868c814cc4adcce2843a6
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Jan 20 15:15:02 2011 -0500

    Move NEWS entry.

commit 4ea3b60667877b8e323899957f87bac66c37cd6f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Jan 20 15:00:17 2011 -0500

    Remove individual c structs for events.

commit fab4c491f256e0f00aaab4b2455d9acc7538a705
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Jan 19 14:56:28 2011 -0500

    create and use inferior.exit_code.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                         |   15 +++--
 gdb/NEWS                              |   17 ++---
 gdb/doc/gdb.texinfo                   |  129 +++++++++++++++++++--------------
 gdb/inferior.c                        |    2 +
 gdb/inferior.h                        |    4 +
 gdb/infrun.c                          |    1 +
 gdb/python/py-bpevent.c               |   19 +----
 gdb/python/py-continueevent.c         |   20 +----
 gdb/python/py-event.c                 |   21 +++---
 gdb/python/py-event.h                 |   13 ++--
 gdb/python/py-events.h                |    4 +-
 gdb/python/py-evtregistry.c           |   24 ++-----
 gdb/python/py-evts.c                  |    6 --
 gdb/python/py-exitedevent.c           |   33 +++------
 gdb/python/py-inferior.c              |    8 +--
 gdb/python/py-signalevent.c           |   21 ++----
 gdb/python/py-stopevent.c             |   53 ++++----------
 gdb/python/py-stopevent.h             |   26 +------
 gdb/testsuite/ChangeLog               |    6 +-
 gdb/testsuite/gdb.python/py-events.py |    4 +-
 20 files changed, 170 insertions(+), 256 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7e80dd4..d24d0d0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,18 +1,21 @@
-2010-12-22  Sami Wagiaalla  <swagiaal@redhat.com>
+2011-01-21  Sami Wagiaalla  <swagiaal@redhat.com>
                 Oguz Kayral <oguzkayral@gmail.com>
 
+	* infrun.c (handle_inferior_event): Set exit_code.
+	* inferior.h (struct inferior): Added new attribute exit_code.
+	* inferior.c (add_inferior_silent): Initialize exit_code.
 	* python/py-inferior.c (python_on_normal_stop): New function.
 	(python_on_resume): New function.
 	(python_inferior_exit): New function.
 	(gdbpy_initialize_inferior): Add normal_stop, target_resumed, and
 	inferior_exit observers.
-	* python/py-eventregistry.c: New file.
+	* python/py-evtregistry.c: New file.
 	* python/py-event.c: New file.
-	* python/py-events.c: New file.
+	* python/py-evts.c: New file.
 	* python/py-continueevent.c: New file.
-	* python/py-breakpointevent.c : New file.
-	* python/py-signalevent.c : New file.
-	* python/py-exetiedevent.c : New file.
+	* python/py-bpevent.c: New file.
+	* python/py-signalevent.c: New file.
+	* python/py-exetiedevent.c: New file.
 	* python/py-breakpoint.c (gdbpy_breakpoint_from_bpstats): New function.
 	Move struct breakpoint_object from here...
 	* python/python-internal.h: ... to here.
diff --git a/gdb/NEWS b/gdb/NEWS
index a51740e..d5bae34 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,15 +3,6 @@
 
 *** Changes since GDB 7.2
 
-* Python Support for Inferior events.
-  Python scripts can add observers to be notified of events
-  occurring the in process being debugged.
-  The following events are currently supported:
-  - gdb.events.breakpoint Breakpoint hit event.
-  - gdb.events.cont Continue event.
-  - gdb.events.signal Signal received event.
-  - gdb.events.exited Inferior exited event.
-
 * New command line options
 
 -data-directory DIR	Specify DIR as the "data-directory".
@@ -49,6 +40,14 @@
 
   ** gdb.parameter("directories") is now available.
 
+  ** Python Support for Inferior events.
+     Python scripts can add observers to be notified of events
+     occurring the in process being debugged.
+     The following events are currently supported:
+     - gdb.events.cont Continue event.
+     - gdb.events.exited Inferior exited event.
+     - gdb.events.stop Signal received, and Breakpoint hit events.
+
 * C++ Improvements:
 
   ** GDB now puts template parameters in scope when debugging in an
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 31dea4c..b899370 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20700,7 +20700,7 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown.
 * Selecting Pretty-Printers::   How GDB chooses a pretty-printer.
 * Writing a Pretty-Printer::    Writing a Pretty-Printer.
 * Inferiors In Python::         Python representation of inferiors (processes)
-* Inferior Events In Python::   Listening for events from the process being debugged.
+* Events In Python::            Listening for events from GDB.
 * Threads In Python::           Accessing inferior threads from Python.
 * Commands In Python::          Implementing new commands in Python.
 * Parameters In Python::        Adding new @value{GDBN} parameters.
@@ -21864,68 +21864,108 @@ the pattern could not be found.
 @end defmethod
 @end table
 
-@node Inferior Events In Python
-@subsubsection Inferior Events In Python
+@node Events In Python
+@subsubsection Events In Python
 @cindex inferior events in python
 
-The Python API allows scripts to listen for events coming from the inferior process
-and its threads. In order to listen for events the script must register an observer
-by connecting it to the appropriate event registry. Event registries can be accessed
-through the @code{gdb.events} module.
+GDB provides a general event facility so that Python code can be
+notified of various state changes, particularly changes that occur in
+the inferior.
+
+An @dfn{event} is just an object that describes some state change.  The
+type of the object and its attributes will vary depending on the details
+of the change.  All the existing events are described below.
+
+In order to be notified of an event, you must register an event handler
+with an event registry.  An @dfn{event registry} is an object in the
+@code{gdb.events} module which dispatches particular events.  A registry
+provides methods to register and unregister event handlers:
+
+@table @code
+@defmethod EventRegistry connect callable
+Add the given callable object to the registry.  This object will be called
+when an event corresponding to this registry occurs.
+@end defmethod
+
+@defmethod EventRegistry disconnect callable
+Remove the given object from the registry.  Once removed the object will no
+longer receive notifications of events.
+@end defmethod
+@end table
 
 Here is an example:
 
 @smallexample
 def exit_handler (event):
-    if (isinstance (event, gdb.ExitedEvent)):
-        print "event type: exit"
-        print "exit code: %d" % (event.exit_code)
+    print "event type: exit"
+    print "exit code: %d" % (event.exit_code)
 
 gdb.events.exited.connect (exit_handler)
 @end smallexample
 
-The following is a listing of the event registries that are available and details
-of the events they emit:
+In the above example we connect our handler @code{exit_handler} to the
+registry @code{events.exited}.  Once connected @code{exit_handler} receives
+notifications of exited events.  The argument @dfn{event} in this example is
+of type @code{gdb.ExitedEvent}.  As you can see in the example the
+@code{ExitedEvent} object has an attribute which indicates the exit code of
+the inferior.
+
+The following is a listing of the event registries that are available and
+details of the events they emit:
 
 @table @code
-@item events.breakpoint
+
 @item events.cont
+Emits @code{gdb.ContinueEvent}
+Indicates that the inferior has been continued.
+
 @item events.exited
-@item events.signal
+Emits @code{events.ExitedEvent} which indicates that the inferior has exited.
+@code{events.ExitedEvent} as one attribute:
+@table @code
+@defivar ExitedEvent exit_code
+An integer representing the exit code which the inferior has returned.
+@end defivar
 @end table
 
-These registries emit the following events in respective order:
+@item events.stop
+Emits @code{gdb.SignalEvent} which indicates that the inferior or one of its
+threads has received as signal.  @code{gdb.SignalEvent} has the following
+attributes:
+
+@table @code
+@defivar SignalEvent inferior_thread
+In non-stop mode this attribute will be set to the specific thread that
+received the signal and @code{None} otherwise.
+@end defivar
+@defivar SignalEvent stop_signal
+A string representing the signal received by the inferior.  A list of possible
+signal values can be obtained by running the command @code{info signals} in
+the @value{GDBN} command prompt.
+@end defivar
+
+Also emits  @code{gdb.BreakpointEvent} which indicates that a breakpoint has
+been hit.  A @code{BreakpointEvent} object as the following attributes:
 
 @table @code
-@item events.BreakpointEvent
-Indicates that a breakpoint was hit and has the following attributes
 @defivar BreakpointEvent breakpoint
 Reference to the breakpoint of type @code{gdb.Breakpoint} that was hit.
 @xref{Breakpoints In Python}, for details of the @code{gdb.Breakpoint}
 object.
 @end defivar
+
 @defivar BreakpointEvent inferior_thread
-In non-stop mode breakpoints only stop the thread that has hit them. If
+In non-stop mode breakpoints only stop the thread that has hit them.  If
 @value{GDBN} is running in non-stop mode this attribute will hold a reference
-to the thread that has stopped. This object will be of type @code{gdb.InferiorThread}
+to the thread that has stopped.  This object will be of type
+@code{gdb.InferiorThread}
 @xref{Threads In Python}, for details of the @code{gdb.Breakpoint} object.
 If all threads are stopped the value of this attribute will be @code{None}.
 @end defivar
-@item events.ContinueEvent
-Indicates that the inferior has been continued.
-@item events.ExitedEvent
-Indicates that the inferior has exited.
-@defivar ExitedEvent exit_code
-The exit code that the inferior has returned.
-@end defivar
-@item events.SignalEvent
-@defivar SignalEvent inferior_thread
-In non-stop mode this attribute will be set to the specific thread that received the signal
-and @code{None} otherwise.
-@end defivar
-@defivar SignalEvent stop_signal
-The signal received by the inferior
-@end defivar
+@end table
+
+@end table
+
 @end table
 
 @node Threads In Python
@@ -23321,31 +23361,10 @@ top of the source tree to the source search path.
 @value{GDBN} comes with a module to assist writing Python code.
 
 @menu
-* gdb.events::         Registering observers to listen to inferior events.
 * gdb.printing::       Building and registering pretty-printers.
 * gdb.types::          Utilities for working with types.
 @end menu
 
-@node gdb.events
-@subsubsection gdb.events
-@cindex gdb.events
-
-This module provides access to inferior event registries. Add observers
-to these registries to receive notification about inferior events.
-
-The available registries are:
-
-@table @code
-@item events.breakpoint
-Notifies listeners of breakpoints being hit.
-@item events.cont
-Notifies listeners whenever the inferior, or one of its threads, is continued.
-@item events.exited
-Notifies listeners when the inferior exits.
-@item events.signal
-Notifies listeners of the inferior, or one of its threads,receiving a signal.
-@end table
-
 @node gdb.printing
 @subsubsection gdb.printing
 @cindex gdb.printing
diff --git a/gdb/inferior.c b/gdb/inferior.c
index cad7e55..3137128 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -133,6 +133,8 @@ add_inferior_silent (int pid)
   inf->environment = make_environ ();
   init_environ (inf->environment);
 
+  inf->exit_code = -1;
+
   inferior_alloc_data (inf);
 
   observer_notify_inferior_added (inf);
diff --git a/gdb/inferior.h b/gdb/inferior.h
index f80ecb5..62f4ea1 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -522,6 +522,10 @@ struct inferior
      if any catching is necessary.  */
   int total_syscalls_count;
 
+  /* If this inferior object represents an inferior that has just exited
+     this value will contain the exit code, otherwise this will be -1.  */
+  LONGEST exit_code;
+
   /* Per inferior data-pointers required by other GDB modules.  */
   void **data;
   unsigned num_data;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 1bc00a4..96c7d18 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3202,6 +3202,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       target_terminal_ours ();	/* Must do this before mourn anyway */
       print_exited_reason (ecs->ws.value.integer);
 
+      current_inferior ()->exit_code = (LONGEST) ecs->ws.value.integer;
       /* Record the exit code in the convenience variable $_exitcode, so
          that the user can inspect this again later.  */
       set_internalvar_integer (lookup_internalvar ("_exitcode"),
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c
index 7dbef53..daeb1f0 100644
--- a/gdb/python/py-bpevent.c
+++ b/gdb/python/py-bpevent.c
@@ -21,33 +21,22 @@
 
 static PyTypeObject breakpoint_event_object_type;
 
-static void
-breakpoint_evpy_dealloc (PyObject *self)
-{
-  Py_XDECREF (((breakpoint_event_object *) self)->breakpoint);
-  stop_evpy_dealloc (self);
-}
-
 /* Create and initialize a BreakpointEvent object.  */
 
-breakpoint_event_object *
+PyObject *
 create_breakpoint_event_object (struct bpstats *bs,
                                 PyObject *stopped_thread)
 {
-  breakpoint_event_object *breakpoint_event_obj =
-      (breakpoint_event_object *)
+  PyObject *breakpoint_event_obj =
       create_stop_event_object (&breakpoint_event_object_type,
                                 stopped_thread);
 
   if (!breakpoint_event_obj)
     goto fail;
 
-  breakpoint_event_obj->breakpoint = gdbpy_breakpoint_from_bpstats (bs);
-  Py_INCREF (breakpoint_event_obj->breakpoint);
-
-  if (evpy_add_attribute ((event_object *) breakpoint_event_obj,
+  if (evpy_add_attribute (breakpoint_event_obj,
                           "breakpoint",
-                          breakpoint_event_obj->breakpoint) < 0)
+                          gdbpy_breakpoint_from_bpstats (bs)) < 0)
     goto fail;
 
   return breakpoint_event_obj;
diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c
index 320c969..2a00630 100644
--- a/gdb/python/py-continueevent.c
+++ b/gdb/python/py-continueevent.c
@@ -21,22 +21,10 @@
 
 static PyTypeObject continue_event_object_type;
 
-typedef struct
-{
-  event_object event;
-} continue_event_object;
-
-static void
-continue_evpy_dealloc (PyObject *self)
-{
-  evpy_dealloc (self);
-}
-
-continue_event_object *
+PyObject *
 create_continue_event_object (void)
 {
-  return (continue_event_object *)
-      create_event_object (&continue_event_object_type);
+  return create_event_object (&continue_event_object_type);
 }
 
 /* Callback function which notifies observers when a continue event occurs.
@@ -46,12 +34,12 @@ create_continue_event_object (void)
 int
 emit_continue_event (ptid_t ptid)
 {
-  event_object *event;
+  PyObject *event;
 
   if (evregpy_no_listeners_p (gdb_py_events.cont))
     return 0;
 
-  event = (event_object *) create_continue_event_object ();
+  event = create_continue_event_object ();
   if (event)
     return evpy_emit_event (event, gdb_py_events.cont);
   return -1;
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 99dd7bc..88f8db6 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -26,7 +26,7 @@ evpy_dealloc (PyObject *self)
   self->ob_type->tp_free (self);
 }
 
-event_object *
+PyObject *
 create_event_object (PyTypeObject *py_type)
 {
   event_object *event_obj;
@@ -39,7 +39,7 @@ create_event_object (PyTypeObject *py_type)
   if (!event_obj->dict)
     goto fail;
 
-  return event_obj;
+  return (PyObject*) event_obj;
 
  fail:
   Py_XDECREF (event_obj);
@@ -51,9 +51,9 @@ create_event_object (PyTypeObject *py_type)
    returns 0 if the operation succeeds and -1 otherwise.  */
 
 int
-evpy_add_attribute (event_object *event, char *name, PyObject *attr)
+evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
 {
-  return PyObject_SetAttrString ((PyObject *) event, name, attr);
+  return PyObject_SetAttrString (event, name, attr);
 }
 
 /* Initialize the Python event code.  */
@@ -92,20 +92,17 @@ gdbpy_initialize_event_generic (PyTypeObject *type,
    returns 0 if emit is successful -1 otherwise.  */
 
 int
-evpy_emit_event (event_object *event,
+evpy_emit_event (PyObject *event,
                  eventregistry_object *registry)
 {
-  PyObject *callback_list, *event_obj = (PyObject *) event;
   PyObject *callback_list_copy = NULL;
   Py_ssize_t i;
 
-  callback_list = (PyObject *) registry->callbacks;
-
   /* Create a copy of call back list and use that for
      notifying listeners to avoid skipping callbacks
      in the case of a callback being disconnected during
      a notification.  */
-  callback_list_copy = PySequence_List (callback_list);
+  callback_list_copy = PySequence_List (registry->callbacks);
   if (!callback_list_copy)
     goto fail;
 
@@ -116,7 +113,7 @@ evpy_emit_event (event_object *event,
       if (func == NULL)
 	goto fail;
 
-      if (!PyObject_CallFunctionObjArgs (func, event_obj, NULL))
+      if (!PyObject_CallFunctionObjArgs (func, event, NULL))
 	{
 	  /* Print the trace here, but keep going -- we want to try to
 	     call all of the callbacks even if one is broken.  */
@@ -125,13 +122,13 @@ evpy_emit_event (event_object *event,
     }
 
   Py_XDECREF (callback_list_copy);
-  Py_XDECREF (event_obj);
+  Py_XDECREF (event);
   return 0;
 
  fail:
   gdbpy_print_stack ();
   Py_XDECREF (callback_list_copy);
-  Py_XDECREF (event_obj);
+  Py_XDECREF (event);
   return -1;
 }
 
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 8d7af2a..cca19c5 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -52,9 +52,9 @@
       PyObject_HEAD_INIT (NULL) \
       0,                                          /* ob_size */ \
       py_path,                                    /* tp_name */ \
-      sizeof (name##_event_object),               /* tp_basicsize */ \
+      sizeof (event_object),                      /* tp_basicsize */ \
       0,                                          /* tp_itemsize */ \
-      name##_evpy_dealloc,                        /* tp_dealloc */ \
+      evpy_dealloc,                               /* tp_dealloc */ \
       0,                                          /* tp_print */ \
       0,                                          /* tp_getattr */ \
       0,                                          /* tp_setattr */ \
@@ -103,15 +103,14 @@ typedef struct
   PyObject *dict;
 } event_object;
 
-extern int emit_stop_event (struct bpstats *bs, enum target_signal stop_signal);
 extern int emit_continue_event (ptid_t ptid);
-extern int emit_exited_event (LONGEST *exit_code);
+extern int emit_exited_event (LONGEST exit_code);
 
-extern int evpy_emit_event (event_object *event,
+extern int evpy_emit_event (PyObject *event,
                             eventregistry_object *registry);
-extern event_object * create_event_object (PyTypeObject *py_type);
+extern PyObject *create_event_object (PyTypeObject *py_type);
 extern void evpy_dealloc (PyObject *self);
-extern int evpy_add_attribute (event_object *event,
+extern int evpy_add_attribute (PyObject *event,
                                char *name, PyObject *attr);
 int gdbpy_initialize_event_generic (PyTypeObject *type, char *name);
 
diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h
index 31e5604..8dbe12e 100644


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-24 16:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24 16:20 [SCM] archer-swagiaal-oguz: cleanups swagiaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).