xref: /qemu/include/gdbstub/user.h (revision b6617e93)
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() - 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(CPUState *, int, const char *);
29 
30 /**
31  * gdb_signalled() - inform remote gdb of sig exit
32  * @as: current CPUArchState
33  * @sig: signal number
34  */
35 void gdb_signalled(CPUArchState *as, int sig);
36 
37 /**
38  * gdbserver_fork_start() - inform gdb of the upcoming fork()
39  */
40 void gdbserver_fork_start(void);
41 
42 /**
43  * gdbserver_fork_end() - inform gdb of the completed fork()
44  * @cs: CPU
45  * @pid: 0 if in child process, -1 if fork failed, child process pid otherwise
46  */
47 void gdbserver_fork_end(CPUState *cs, pid_t pid);
48 
49 /**
50  * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
51  * @cs: CPU
52  * @num: syscall number
53  */
54 void gdb_syscall_entry(CPUState *cs, int num);
55 
56 /**
57  * gdb_syscall_entry() - inform gdb of syscall return and yield control to it
58  * @cs: CPU
59  * @num: syscall number
60  */
61 void gdb_syscall_return(CPUState *cs, int num);
62 
63 #endif /* GDBSTUB_USER_H */
64