1 /* ide-debugger-types.h
2  *
3  * Copyright 2017-2019 Christian Hergert <chergert@redhat.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * SPDX-License-Identifier: GPL-3.0-or-later
19  */
20 
21 #pragma once
22 
23 #include <libide-core.h>
24 
25 G_BEGIN_DECLS
26 
27 /**
28  * IdeDebuggerStream:
29  * @IDE_DEBUGGER_TARGET: Logging from the inferior process
30  * @IDE_DEBUGGER_CONSOLE: Logging from the debugger console
31  * @IDE_DEBUGGER_EVENT_LOG: Internal event log from the debugger that can be
32  *   used to troubleshoot the debugger.
33  *
34  * The type of stream for the log message.
35  *
36  * Since: 3.32
37  */
38 typedef enum
39 {
40   IDE_DEBUGGER_TARGET,
41   IDE_DEBUGGER_CONSOLE,
42   IDE_DEBUGGER_EVENT_LOG,
43 } IdeDebuggerStream;
44 
45 #define IDE_TYPE_DEBUGGER_STREAM  (ide_debugger_stream_get_type())
46 #define IDE_IS_DEBUGGER_STREAM(s) (((gint)s >= 0) && ((gint)s <= IDE_DEBUGGER_EVENT_LOG))
47 
48 /**
49  * IdeDebuggerMovement:
50  * @IDE_DEBUGGER_MOVEMENT_START: Start or restart the application
51  * @IDE_DEBUGGER_MOVEMENT_CONTINUE: Continue until a breakpoint is reached
52  * @IDE_DEBUGGER_MOVEMENT_STEP_IN: Execute the next line of code, stepping into
53  *   any function.
54  * @IDE_DEBUGGER_MOVEMENT_STEP_OVER: Execute the next line of code, stepping over
55  *   any function.
56  * @IDE_DEBUGGER_MOVEMENT_FINISH: Run until the function returns.
57  *
58  * Describes the style of movement that should be performed by the debugger.
59  *
60  * Since: 3.32
61  */
62 typedef enum
63 {
64   IDE_DEBUGGER_MOVEMENT_START,
65   IDE_DEBUGGER_MOVEMENT_CONTINUE,
66   IDE_DEBUGGER_MOVEMENT_STEP_IN,
67   IDE_DEBUGGER_MOVEMENT_STEP_OVER,
68   IDE_DEBUGGER_MOVEMENT_FINISH,
69 } IdeDebuggerMovement;
70 
71 #define IDE_TYPE_DEBUGGER_MOVEMENT  (ide_debugger_movement_get_type())
72 #define IDE_IS_DEBUGGER_MOVEMENT(m) (((gint)m >= 0) && ((gint)m) <= IDE_DEBUGGER_MOVEMENT_FINISH)
73 
74 /**
75  * IdeDebuggerStopReason:
76  * @IDE_DEBUGGER_STOP_BREAKPOINT: The debugger stopped because of a breakpoing
77  * @IDE_DEBUGGER_STOP_EXITED_NORMALLY: The debugger stopped because the process exited
78  *    in a graceful fashion.
79  * @IDE_DEBUGGER_STOP_SIGNALED: The debugger stopped because the process
80  *    received a death signal.
81  *
82  * Represents the reason a process has stopped executing in the debugger.
83  *
84  * Since: 3.32
85  */
86 typedef enum
87 {
88   IDE_DEBUGGER_STOP_BREAKPOINT_HIT,
89   IDE_DEBUGGER_STOP_EXITED,
90   IDE_DEBUGGER_STOP_EXITED_NORMALLY,
91   IDE_DEBUGGER_STOP_EXITED_SIGNALED,
92   IDE_DEBUGGER_STOP_FUNCTION_FINISHED,
93   IDE_DEBUGGER_STOP_LOCATION_REACHED,
94   IDE_DEBUGGER_STOP_SIGNAL_RECEIVED,
95   /* I think this can be used for a variety of catch positions in gdb,
96    * and as a generic fallback for "this stopped, but not for the reason
97    * of a particular breakpoint". Alternatively, a backend could insert
98    * a transient breakpoint, stop on the breakpoint, and then remove it
99    * after the stop event.
100    */
101   IDE_DEBUGGER_STOP_CATCH,
102   IDE_DEBUGGER_STOP_UNKNOWN,
103 } IdeDebuggerStopReason;
104 
105 #define IDE_TYPE_DEBUGGER_STOP_REASON    (ide_debugger_stop_reason_get_type())
106 #define IDE_IS_DEBUGGER_STOP_REASON(r)   (((gint)r >= 0) && ((gint)r) <= IDE_DEBUGGER_STOP_UNKNOWN)
107 #define IDE_DEBUGGER_STOP_IS_TERMINAL(r) (((r) == IDE_DEBUGGER_STOP_EXITED) || \
108                                           ((r) == IDE_DEBUGGER_STOP_EXITED_NORMALLY) || \
109                                           ((r) == IDE_DEBUGGER_STOP_EXITED_SIGNALED))
110 
111 /**
112  * IdeDebuggerBreakMode:
113  * @IDE_DEBUGGER_BREAK_NONE: No breakpoint is set
114  * @IDE_DEBUGGER_BREAK_BREAKPOINT: A simple breakpoint that stops the debugger
115  *   when reaching a given location.
116  * @IDE_DEBUGGER_BREAK_COUNTPOINT: A counter that is incremented when the
117  *   debugger reaches a breakpoint.
118  * @IDE_DEBUGGER_BREAK_WATCHPOINT: A breakpoint that is conditional on the
119  *   specification matching.
120  *
121  * The type of breakpoint.
122  *
123  * Since: 3.32
124  */
125 typedef enum
126 {
127   IDE_DEBUGGER_BREAK_NONE = 0,
128   IDE_DEBUGGER_BREAK_BREAKPOINT,
129   IDE_DEBUGGER_BREAK_COUNTPOINT,
130   IDE_DEBUGGER_BREAK_WATCHPOINT,
131 } IdeDebuggerBreakMode;
132 
133 #define IDE_TYPE_DEBUGGER_BREAK_MODE  (ide_debugger_break_mode_get_type())
134 #define IDE_IS_DEBUGGER_BREAK_MODE(m) (((gint)m >= 0) && ((gint)m) <= IDE_DEBUGGER_BREAK_WATCHPOINT)
135 
136 
137 /**
138  * IdeDebuggerBreakpointChange:
139  * @IDE_DEBUGGER_BREAKPOINT_CHANGE_ENABLED: change the enabled state
140  *
141  * Describes the type of modification to perform on a breakpoint.
142  *
143  * Since: 3.32
144  */
145 typedef enum
146 {
147   IDE_DEBUGGER_BREAKPOINT_CHANGE_ENABLED = 1,
148 } IdeDebuggerBreakpointChange;
149 
150 #define IDE_TYPE_DEBUGGER_BREAKPOINT_CHANGE  (ide_debugger_breakpoint_change_get_type())
151 #define IDE_IS_DEBUGGER_BREAKPOINT_CHANGE(c) (((gint)c > 0) && ((gint)c) <= IDE_DEBUGGER_BREAKPOINT_CHANGE_ENABLED)
152 
153 
154 /**
155  * IdeDebuggerDisposition:
156  * @IDE_DEBUGGER_DISPOSITION_KEEP: the breakpoint will be kept after
157  *   the next stop. This generally means the breakpoint is persistent until
158  *   removed by the user.
159  * @IDE_DEBUGGER_DISPOSITION_DELETE_NEXT_HIT: The breakpoint will be removed
160  *   after the next time it is hit.
161  * @IDE_DEBUGGER_DISPOSITION_DELETE_NEXT_STOP: The breakpoint will be removed
162  *   the next time the debugger stops, even if not hit.
163  * @IDE_DEBUGGER_DISPOSITION_DISABLE: The breakpoint is currently disabled.
164  *
165  * The disposition determines what should happen to the breakpoint at the next
166  * stop of the debugger.
167  *
168  * Since: 3.32
169  */
170 typedef enum
171 {
172   IDE_DEBUGGER_DISPOSITION_KEEP,
173   IDE_DEBUGGER_DISPOSITION_DISABLE,
174   IDE_DEBUGGER_DISPOSITION_DELETE_NEXT_HIT,
175   IDE_DEBUGGER_DISPOSITION_DELETE_NEXT_STOP,
176 } IdeDebuggerDisposition;
177 
178 #define IDE_TYPE_DEBUGGER_DISPOSITION  (ide_debugger_disposition_get_type())
179 #define IDE_IS_DEBUGGER_DISPOSITION(d) (((gint)d >= 0) && ((gint)d) <= IDE_DEBUGGER_DISPOSITION_DELETE_NEXT_STOP)
180 
181 
182 typedef guint64 IdeDebuggerAddress;
183 
184 #define IDE_DEBUGGER_ADDRESS_INVALID (0)
185 
186 IDE_AVAILABLE_IN_3_32
187 IdeDebuggerAddress ide_debugger_address_parse (const gchar *string);
188 
189 typedef struct
190 {
191   IdeDebuggerAddress from;
192   IdeDebuggerAddress to;
193 } IdeDebuggerAddressRange;
194 
195 #define IDE_TYPE_DEBUGGER_ADDRESS_RANGE (ide_debugger_address_range_get_type())
196 
197 
198 IDE_AVAILABLE_IN_3_32
199 GType ide_debugger_stream_get_type            (void);
200 IDE_AVAILABLE_IN_3_32
201 GType ide_debugger_movement_get_type          (void);
202 IDE_AVAILABLE_IN_3_32
203 GType ide_debugger_stop_reason_get_type       (void);
204 IDE_AVAILABLE_IN_3_32
205 GType ide_debugger_break_mode_get_type        (void);
206 IDE_AVAILABLE_IN_3_32
207 GType ide_debugger_disposition_get_type       (void);
208 IDE_AVAILABLE_IN_3_32
209 GType ide_debugger_address_range_get_type     (void);
210 IDE_AVAILABLE_IN_3_32
211 GType ide_debugger_breakpoint_change_get_type (void);
212 
213 
214 IDE_AVAILABLE_IN_3_32
215 IdeDebuggerAddressRange *ide_debugger_address_range_copy (const IdeDebuggerAddressRange *range);
216 IDE_AVAILABLE_IN_3_32
217 void                     ide_debugger_address_range_free (IdeDebuggerAddressRange       *range);
218 
219 
220 G_END_DECLS
221