1 /* Python interface to inferior stop events.
3 Copyright (C) 2009-2017 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "py-stopevent.h"
24 create_stop_event_object (PyTypeObject
*py_type
)
26 return create_thread_event_object (py_type
);
29 /* Callback observers when a stop event occurs. This function will create a
30 new Python stop event object. If only a specific thread is stopped the
31 thread object of the event will be set to that thread. Otherwise, if all
32 threads are stopped thread object will be set to None.
33 return 0 if the event was created and emitted successfully otherwise
37 emit_stop_event (struct bpstats
*bs
, enum gdb_signal stop_signal
)
39 gdbpy_ref stop_event_obj
;
41 PyObject
*first_bp
= NULL
;
42 struct bpstats
*current_bs
;
44 if (evregpy_no_listeners_p (gdb_py_events
.stop
))
47 /* Add any breakpoint set at this location to the list. */
48 for (current_bs
= bs
; current_bs
!= NULL
; current_bs
= current_bs
->next
)
50 if (current_bs
->breakpoint_at
51 && current_bs
->breakpoint_at
->py_bp_object
)
53 PyObject
*current_py_bp
=
54 (PyObject
*) current_bs
->breakpoint_at
->py_bp_object
;
58 list
.reset (PyList_New (0));
63 if (PyList_Append (list
.get (), current_py_bp
))
67 first_bp
= current_py_bp
;
73 stop_event_obj
.reset (create_breakpoint_event_object (list
.get (),
75 if (stop_event_obj
== NULL
)
79 /* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */
80 if (stop_signal
!= GDB_SIGNAL_0
81 && stop_signal
!= GDB_SIGNAL_TRAP
)
83 stop_event_obj
.reset (create_signal_event_object (stop_signal
));
84 if (stop_event_obj
== NULL
)
88 /* If all fails emit an unknown stop event. All event types should
89 be known and this should eventually be unused. */
90 if (stop_event_obj
== NULL
)
92 stop_event_obj
.reset (create_stop_event_object (&stop_event_object_type
));
93 if (stop_event_obj
== NULL
)
97 return evpy_emit_event (stop_event_obj
.get (), gdb_py_events
.stop
);
100 GDBPY_NEW_EVENT_TYPE (stop
,
103 "GDB stop event object",
104 thread_event_object_type
);
This page took 0.030684 seconds and 4 git commands to generate.