aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.python/py-events.c3
-rw-r--r--gdb/testsuite/gdb.python/py-events.exp26
-rw-r--r--gdb/testsuite/gdb.python/py-events.py20
3 files changed, 44 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c
index 665ca51..c20cc84 100644
--- a/gdb/testsuite/gdb.python/py-events.c
+++ b/gdb/testsuite/gdb.python/py-events.c
@@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+extern void do_nothing (void);
+
int second(){
fork() ;
return 12;
@@ -26,5 +28,6 @@ int first(){
}
int main (){
+ do_nothing();
return first();
}
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index 18419fa..e420389 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -19,23 +19,39 @@ if $tracelevel then {
load_lib gdb-python.exp
+set libfile "py-events-shlib"
+set libsrc $srcdir/$subdir/$libfile.c
+set lib_sl $objdir/$subdir/$libfile.so
+set lib_opts debug
+
set testfile "py-events"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
+set exec_opts [list debug shlib=$lib_sl]
set pyfile ${srcdir}/${subdir}/${testfile}.py
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+if [get_compiler_info ${binfile}] {
return -1
}
+if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
+ || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
+ untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
+ return -1
+}
+
+# Start with a fresh gdb.
+clean_restart ${testfile}
+
if { [skip_python_tests] } { continue }
gdb_test_no_output "python execfile ('${pyfile}')" ""
-if ![runto_main ] then {
- fail "Can't run to main"
- return -1
-}
+gdb_test "Test_Newobj_Events" "New ObjectFile Event tester registered." "Register new objfile event handler"
+
+gdb_breakpoint "main" {temporary}
+
+gdb_test "run" ".*event type: new_objfile.*new objfile name.*" "New objfile notification"
gdb_test_no_output "set detach-on-fork off" ""
diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py
index 6bdd935..ab549c4 100644
--- a/gdb/testsuite/gdb.python/py-events.py
+++ b/gdb/testsuite/gdb.python/py-events.py
@@ -51,6 +51,14 @@ def continue_handler (event):
if ( event.inferior_thread is not None) :
print "thread num: %s" % (event.inferior_thread.num);
+def new_objfile_handler (event):
+ if (isinstance (event, gdb.NewObjFileEvent)):
+ print "event type: new_objfile"
+ if (event.new_objfile is not None):
+ print "new objfile name: %s" % (event.new_objfile.filename)
+ else:
+ print "new objfile is None"
+
class test_events (gdb.Command):
"""Test events."""
@@ -65,3 +73,15 @@ class test_events (gdb.Command):
print "Event testers registered."
test_events ()
+
+class test_newobj_events (gdb.Command):
+ """NewObj events."""
+
+ def __init__ (self):
+ gdb.Command.__init__ (self, "test_newobj_events", gdb.COMMAND_STACK)
+
+ def invoke (self, arg, from_tty):
+ gdb.events.new_objfile.connect (new_objfile_handler)
+ print "New ObjectFile Event tester registered."
+
+test_newobj_events ()