1 # Copyright (C) 2010, 2011 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the GDB testsuite. It tests python pretty
20 def signal_stop_handler (event
):
21 if (isinstance (event
, gdb
.StopEvent
)):
22 print "event type: stop"
23 if (isinstance (event
, gdb
.SignalEvent
)):
24 print "stop reason: signal"
25 print "stop signal: %s" % (event
.stop_signal
)
26 if ( event
.inferior_thread
is not None) :
27 print "thread num: %s" % (event
.inferior_thread
.num
);
29 def breakpoint_stop_handler (event
):
30 if (isinstance (event
, gdb
.StopEvent
)):
31 print "event type: stop"
32 if (isinstance (event
, gdb
.BreakpointEvent
)):
33 print "stop reason: breakpoint"
34 print "breakpoint number: %s" % (event
.breakpoint
.number
)
35 if ( event
.inferior_thread
is not None) :
36 print "thread num: %s" % (event
.inferior_thread
.num
);
38 print "all threads stopped"
40 def exit_handler (event
):
41 if (isinstance (event
, gdb
.ExitedEvent
)):
42 print "event type: exit"
43 print "exit code: %d" % (event
.exit_code
)
45 def continue_handler (event
):
46 if (isinstance (event
, gdb
.ContinueEvent
)):
47 print "event type: continue"
48 if ( event
.inferior_thread
is not None) :
49 print "thread num: %s" % (event
.inferior_thread
.num
);
51 class test_events (gdb
.Command
):
55 gdb
.Command
.__init
__ (self
, "test_events", gdb
.COMMAND_STACK
)
57 def invoke (self
, arg
, from_tty
):
58 gdb
.events
.stop
.connect (signal_stop_handler
)
59 gdb
.events
.stop
.connect (breakpoint_stop_handler
)
60 gdb
.events
.exited
.connect (exit_handler
)
61 gdb
.events
.cont
.connect (continue_handler
)
62 print "Event testers registered."
This page took 0.031064 seconds and 4 git commands to generate.