xref: /openbmc/qemu/include/gdbstub/user.h (revision f6e33708)
1 /*
2  * gdbstub user-mode only APIs
3  *
4  * Copyright (c) 2022 Linaro Ltd
5  *
6  * SPDX-License-Identifier: LGPL-2.0+
7  */
8 
9 #ifndef GDBSTUB_USER_H
10 #define GDBSTUB_USER_H
11 
12 /**
13  * gdb_handlesig_reason() - yield control to gdb
14  * @cpu: CPU
15  * @sig: if non-zero, the signal number which caused us to stop
16  * @reason: stop reason for stop reply packet or NULL
17  *
18  * This function yields control to gdb, when a user-mode-only target
19  * needs to stop execution. If @sig is non-zero, then we will send a
20  * stop packet to tell gdb that we have stopped because of this signal.
21  *
22  * This function will block (handling protocol requests from gdb)
23  * until gdb tells us to continue target execution. When it does
24  * return, the return value is a signal to deliver to the target,
25  * or 0 if no signal should be delivered, ie the signal that caused
26  * us to stop should be ignored.
27  */
28 int gdb_handlesig_reason(CPUState *, int, const char *);
29 
30 /**
31  * gdb_handlesig() - yield control to gdb
32  * @cpu CPU
33  * @sig: if non-zero, the signal number which caused us to stop
34  * @see gdb_handlesig_reason()
35  */
36 static inline int gdb_handlesig(CPUState *cpu, int sig)
37 {
38     return gdb_handlesig_reason(cpu, sig, NULL);
39 }
40 
41 /**
42  * gdb_signalled() - inform remote gdb of sig exit
43  * @as: current CPUArchState
44  * @sig: signal number
45  */
46 void gdb_signalled(CPUArchState *as, int sig);
47 
48 /**
49  * gdbserver_fork() - disable gdb stub for child processes.
50  * @cs: CPU
51  */
52 void gdbserver_fork(CPUState *cs);
53 
54 /**
55  * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
56  * @cs: CPU
57  * @num: syscall number
58  */
59 void gdb_syscall_entry(CPUState *cs, int num);
60 
61 /**
62  * gdb_syscall_entry() - inform gdb of syscall return and yield control to it
63  * @cs: CPU
64  * @num: syscall number
65  */
66 void gdb_syscall_return(CPUState *cs, int num);
67 
68 #endif /* GDBSTUB_USER_H */
69