public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-oguz: Move stopped_thread attribute to stop_event.
@ 2010-12-21 19:47 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2010-12-21 19:47 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-oguz has been updated
       via  195ae91671c75c0dda34afbffb53e49df611076c (commit)
      from  fccac0ca730163f0b4fa01db2c11b2afc2aaeace (commit)

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

- Log -----------------------------------------------------------------
commit 195ae91671c75c0dda34afbffb53e49df611076c
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Dec 21 14:45:15 2010 -0500

    Move stopped_thread attribute to stop_event.
    
    also,
      Pass thread argument to signal event.
      Test that signals are thread specific in non-stop mode.

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

Summary of changes:
 gdb/python/py-event.c                          |    7 -------
 gdb/python/py-event.h                          |    1 -
 gdb/python/py-signalevent.c                    |    7 +++----
 gdb/python/py-stopevent.c                      |   19 +++++++++++++++++--
 gdb/python/py-stopevent.h                      |    4 +++-
 gdb/testsuite/gdb.python/py-events-threads.c   |    5 +++++
 gdb/testsuite/gdb.python/py-events-threads.exp |    8 ++++----
 gdb/testsuite/gdb.python/py-events.c           |    4 +---
 gdb/testsuite/gdb.python/py-events.exp         |    8 +-------
 gdb/testsuite/gdb.python/py-events.py          |    2 ++
 10 files changed, 36 insertions(+), 29 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index a4421a0..bae3ab3 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -40,13 +40,6 @@ create_event_object (PyTypeObject *py_type,
   if (!event_obj->dict)
     goto fail;
 
-  event_obj->inferior_thread = (PyObject *)inferior_thread;
-
-  if (evpy_add_attribute (event_obj,
-                          "inferior_thread",
-                          event_obj->inferior_thread) < 0)
-    goto fail;
-
   return event_obj;
 
  fail:
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 2e8dcd7..7e09ae6 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -94,7 +94,6 @@ typedef struct
   PyObject_HEAD
 
   PyObject *dict;
-  PyObject *inferior_thread;
 } event_object;
 
 extern int emit_stop_event (struct bpstats *bs, const char *stop_signal);
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index 11ed3c5..40fbe12 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -29,14 +29,13 @@ signal_evpy_dealloc (PyObject *self)
 }
 
 signal_event_object *
-create_signal_event_object (const char *stop_signal)
+create_signal_event_object (const char *stop_signal,
+                            thread_object *stopped_thread)
 {
   signal_event_object *signal_event_obj =
       (signal_event_object *)
       create_stop_event_object (&signal_event_object_type,
-                                //FIXME: Are signals thread specific
-                                //       escpecially in non-stop mode
-                                (thread_object *)Py_None);
+                                (thread_object *)stopped_thread);
 
   if (!signal_event_obj)
     goto fail;
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index 2fd14a7..5e4f46d 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -22,6 +22,7 @@
 void
 stop_evpy_dealloc (PyObject *self)
 {
+  Py_XDECREF (((stop_event_object *) self)->inferior_thread);
   evpy_dealloc (self);
 }
 
@@ -33,9 +34,23 @@ create_stop_event_object (PyTypeObject *py_type, thread_object *thread)
                                                  thread);
 
   if (!stop_event_obj)
-    return NULL;
+    goto fail;
+
+  stop_event_obj->inferior_thread = (PyObject *) thread;
+
+  if (evpy_add_attribute ((event_object *)stop_event_obj,
+                          "inferior_thread",
+                          stop_event_obj->inferior_thread) < 0)
+    goto fail;
+
 
   return stop_event_obj;
+
+  fail:
+   Py_XDECREF (stop_event_obj);
+   Py_XDECREF (stop_event_obj->inferior_thread);
+   return NULL;
+
 }
 
 /* Callback observers when a stop event occurs. This function will create a new
@@ -78,7 +93,7 @@ emit_stop_event (struct bpstats *bs, const char *stop_signal)
     {
       stop_event_obj =
 	  (stop_event_object *)
-	  create_signal_event_object (stop_signal);
+	  create_signal_event_object (stop_signal, stopped_thread);
       if (!stop_event_obj)
 	goto fail;
 
diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h
index 304782d..2d73d36 100644
--- a/gdb/python/py-stopevent.h
+++ b/gdb/python/py-stopevent.h
@@ -24,6 +24,7 @@
 
 typedef struct
 {
+  PyObject *inferior_thread;
   event_object event;
 } stop_event_object;
 
@@ -51,6 +52,7 @@ create_breakpoint_event_object (struct bpstats *bs,
                                 thread_object *stopped_thread);
 
 extern signal_event_object *
-create_signal_event_object (const char *stop_signal);
+create_signal_event_object (const char *stop_signal,
+                            thread_object *stopped_thread);
 
 #endif /* GDB_PY_STOPEVENT_H */
diff --git a/gdb/testsuite/gdb.python/py-events-threads.c b/gdb/testsuite/gdb.python/py-events-threads.c
index 2560bd7..63e27f9 100644
--- a/gdb/testsuite/gdb.python/py-events-threads.c
+++ b/gdb/testsuite/gdb.python/py-events-threads.c
@@ -27,6 +27,10 @@ void* thread3 (void* d)
 {
   int count3 = 0;
   count3++;
+
+  int *bad;
+  *bad = 1;
+
   return NULL;
 }
 
@@ -45,5 +49,6 @@ int main (){
   int count1 = 0; // stop1
   count1++;
 
+  pthread_join (thread3_id, NULL);
   return 12;
 }
diff --git a/gdb/testsuite/gdb.python/py-events-threads.exp b/gdb/testsuite/gdb.python/py-events-threads.exp
index 2b132d3..ed50d61 100644
--- a/gdb/testsuite/gdb.python/py-events-threads.exp
+++ b/gdb/testsuite/gdb.python/py-events-threads.exp
@@ -83,7 +83,7 @@ gdb_expect {
 	}
 }
 
-#test exited event.
-gdb_test "continue" ".*event type: continue.*
-.*event type: exit.*
-.*exit code: 12.*"
\ No newline at end of file
+gdb_test "continue -a" ".*event type: stop.*
+.*stop reason: signal.*
+.*stop signal: SIGSEGV.*
+.*thread num: 3.*"
diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c
index a2a1d3a..1a5f2de 100644
--- a/gdb/testsuite/gdb.python/py-events.c
+++ b/gdb/testsuite/gdb.python/py-events.c
@@ -17,9 +17,7 @@
 */
 
 int second(){
-  int *bad;
-  *bad = 1;
-  return 0;
+  return 12;
 }
 
 int first(){
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index abe8da3..52feb31 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -53,13 +53,7 @@ gdb_test "continue" ".*event type: continue.*
 .*breakpoint number: 2.*
 all threads stopped"
 
-#test signal event.
-gdb_test "continue" ".*event type: continue.*
-.*event type: stop.*
-.*stop reason: signal.*
-.*stop signal: SIGSEGV.*"
-
 #test exited event.
 gdb_test "continue" ".*event type: continue.*
 .*event type: exit.*
-.*exit code: .*"
+.*exit code: 12.*"
diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py
index ef59d4f..a12732a 100644
--- a/gdb/testsuite/gdb.python/py-events.py
+++ b/gdb/testsuite/gdb.python/py-events.py
@@ -23,6 +23,8 @@ def signal_stop_handler (event):
     if (isinstance (event, gdb.SignalEvent)):
         print "stop reason: signal"
         print "stop signal: %s" % (event.stop_signal)
+        if ( event.inferior_thread is not None) :
+            print "thread num: %s" % (event.inferior_thread.num);
 
 def breakpoint_stop_handler (event):
     if (isinstance (event, gdb.StopEvent)):


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


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

only message in thread, other threads:[~2010-12-21 19:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-21 19:47 [SCM] archer-swagiaal-oguz: Move stopped_thread attribute to stop_event 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).