* gas/config/tc-avr.c: Change ISA for devices with USB support to
[external/binutils.git] / gdb / testsuite / gdb.python / py-events.py
1 # Copyright (C) 2010-2013 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # This file is part of the GDB testsuite.  It tests python pretty
17 # printers.
18 import gdb
19
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))
28
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 ("first breakpoint number: %s" % (event.breakpoint.number))
35         for bp in event.breakpoints:
36                 print ("breakpoint number: %s" % (bp.number))
37         if ( event.inferior_thread is not None) :
38             print ("thread num: %s" % (event.inferior_thread.num))
39         else:
40             print ("all threads stopped")
41
42 def exit_handler (event):
43     if (isinstance (event, gdb.ExitedEvent)):
44         print ("event type: exit")
45     print ("exit code: %d" % (event.exit_code))
46     print ("exit inf: %d" % (event.inferior.num))
47     print ("dir ok: %s" % str('exit_code' in dir(event)))
48
49 def continue_handler (event):
50     if (isinstance (event, gdb.ContinueEvent)):
51         print ("event type: continue")
52     if ( event.inferior_thread is not None) :
53         print ("thread num: %s" % (event.inferior_thread.num))
54
55 def new_objfile_handler (event):
56     if (isinstance (event, gdb.NewObjFileEvent)):
57         print ("event type: new_objfile")
58     if (event.new_objfile is not None):
59         print ("new objfile name: %s" % (event.new_objfile.filename))
60     else:
61         print ("new objfile is None")
62
63 class test_events (gdb.Command):
64     """Test events."""
65
66     def __init__ (self):
67         gdb.Command.__init__ (self, "test_events", gdb.COMMAND_STACK)
68
69     def invoke (self, arg, from_tty):
70         gdb.events.stop.connect (signal_stop_handler)
71         gdb.events.stop.connect (breakpoint_stop_handler)
72         gdb.events.exited.connect (exit_handler)
73         gdb.events.cont.connect (continue_handler)
74         print ("Event testers registered.")
75
76 test_events ()
77
78 class test_newobj_events (gdb.Command):
79     """NewObj events."""
80
81     def __init__ (self):
82         gdb.Command.__init__ (self, "test_newobj_events", gdb.COMMAND_STACK)
83
84     def invoke (self, arg, from_tty):
85         gdb.events.new_objfile.connect (new_objfile_handler)
86         print ("New ObjectFile Event tester registered.")
87
88 test_newobj_events ()