public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-oguz: gdbpy_selected_thread: Added check for pid == 0.
@ 2010-12-02 20:58 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2010-12-02 20:58 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-oguz has been updated
       via  b1c0beba3bf927d0f22c4db603f4223834dff305 (commit)
       via  40575c1a1d675b785ba979dac3ef508fd2bb2fca (commit)
      from  4cad63d916d773b33ccd5cb2f2e6091988b09c45 (commit)

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

- Log -----------------------------------------------------------------
commit b1c0beba3bf927d0f22c4db603f4223834dff305
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 2 15:57:11 2010 -0500

    gdbpy_selected_thread: Added check for pid == 0.
    
    2010-12-02  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* python/py-infthread.c (gdbpy_selected_thread): Added check for
    	pid == 0.

commit 40575c1a1d675b785ba979dac3ef508fd2bb2fca
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 2 15:52:08 2010 -0500

    Add test case.
    
    Converted sample scripts provided by Oguz to a test case.
    
    2010-12-02  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.python/py-events.exp: New test.
    	* gdb.python/py-events.c: New test file.
    	* gdb.python/py-events.py: New test file.

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

Summary of changes:
 gdb/python/py-infthread.c              |   10 ++++-
 gdb/testsuite/gdb.python/py-events.c   |   31 +++++++++++++++
 gdb/testsuite/gdb.python/py-events.exp |   67 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.python/py-events.py  |   51 ++++++++++++++++++++++++
 4 files changed, 157 insertions(+), 2 deletions(-)
 create mode 100644 gdb/testsuite/gdb.python/py-events.c
 create mode 100644 gdb/testsuite/gdb.python/py-events.exp
 create mode 100644 gdb/testsuite/gdb.python/py-events.py

First 500 lines of diff:
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 6ac6f1f..69b4a01 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -240,11 +240,19 @@ thpy_is_exited (PyObject *self, PyObject *args)
 
 /* Implementation of gdb.selected_thread () -> gdb.InferiorThread.
    Returns the selected thread object.  */
+
 PyObject *
 gdbpy_selected_thread (PyObject *self, PyObject *args)
 {
   PyObject *thread_obj;
 
+  if (inferior_ptid.pid == 0)
+    {
+      PyErr_SetString (PyExc_RuntimeError,
+                       _("No thread is currently selected."));
+      return NULL;
+    }
+
   thread_obj = (PyObject *) find_thread_object (inferior_ptid);
   if (thread_obj)
     {
@@ -255,8 +263,6 @@ gdbpy_selected_thread (PyObject *self, PyObject *args)
   Py_RETURN_NONE;
 }
 
-
-
 void
 gdbpy_initialize_thread (void)
 {
diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c
new file mode 100644
index 0000000..a2a1d3a
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-events.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see  <http://www.gnu.org/licenses/>.
+*/
+
+int second(){
+  int *bad;
+  *bad = 1;
+  return 0;
+}
+
+int first(){
+  return second();
+}
+
+int main (){
+  return first();
+}
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
new file mode 100644
index 0000000..12fa9c0
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -0,0 +1,67 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.  It tests Python-based
+# pretty-printing for the CLI.
+
+# Skip all tests if Python scripting is not enabled.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+load_lib gdb-python.exp
+
+set testfile "py-events"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+set pyfile ${srcdir}/${subdir}/${testfile}.py
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if { [skip_python_tests] } { continue }
+
+# Ensure sys.path, et.al. are initialized properly.
+gdb_check_python_config
+
+gdb_test_no_output "python execfile ('${pyfile}')" ""
+
+if ![runto_main ] then {
+    fail "Can't run to main"
+    return -1
+}
+
+gdb_test "Test_Events" "Event testers registered."
+
+gdb_breakpoint "first"
+
+# Test continue event and breakpoint stop event
+gdb_test "continue" ".*event type: continue.*
+.*event type: stop.*
+.*stop reason: breakpoint.*
+.*breakpoint number: 2.*"
+
+#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: .*"
diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py
new file mode 100644
index 0000000..0800700
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-events.py
@@ -0,0 +1,51 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.  It tests python pretty
+# printers.
+import gdb
+
+def signal_stop_handler (event):
+    print "event type: %s" % (event.event_type)
+    print "stop reason: %s" % (event.stop_reason)
+    print "stop signal: %s" % (event.stop_signal)
+
+def breakpoint_stop_handler (event):
+    print "event type: %s" % (event.event_type)
+    print "stop reason: %s" % (event.stop_reason)
+    print "breakpoint number: %s" % (event.breakpoint.number)
+
+def exit_handler (event):
+    print "event type: %s" % (event.event_type)
+    print "exit code: %d" % (event.exit_code)
+
+def continue_handler (event):
+    print "event type: %s" % (event.event_type)
+
+class test_events (gdb.Command):
+    """Test events."""
+
+    def __init__ (self):
+        gdb.Command.__init__ (self, "test_events", gdb.COMMAND_STACK)
+
+    def invoke (self, arg, from_tty):
+        gdb.selected_thread().signal_stop_event.connect (signal_stop_handler)
+        gdb.selected_thread().breakpoint_stop_event.connect (breakpoint_stop_handler)
+        gdb.selected_thread().exited_event.connect (exit_handler)
+        gdb.selected_thread().continue_event.connect (continue_handler)
+
+        print "Event testers registered."
+
+test_events ()


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


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

only message in thread, other threads:[~2010-12-02 20:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-02 20:58 [SCM] archer-swagiaal-oguz: gdbpy_selected_thread: Added check for pid == 0 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).