blob: 654986d483b1adc2682ed39c51a8ce6036fdbdc3 [file] [log] [blame]
Alex Bennéed96bf492023-03-02 18:57:47 -08001/*
2 * gdbstub user-mode only APIs
3 *
4 * Copyright (c) 2022 Linaro Ltd
5 *
Philippe Mathieu-Daudéb14d0642024-09-11 17:12:04 +02006 * SPDX-License-Identifier: LGPL-2.0-or-later
Alex Bennéed96bf492023-03-02 18:57:47 -08007 */
8
9#ifndef GDBSTUB_USER_H
10#define GDBSTUB_USER_H
11
Gustavo Romerof84e3132024-03-09 03:08:59 +000012#define MAX_SIGINFO_LENGTH 128
13
Alex Bennéed96bf492023-03-02 18:57:47 -080014/**
Gustavo Romerob6617e92024-03-09 03:08:57 +000015 * gdb_handlesig() - yield control to gdb
Alex Bennéed96bf492023-03-02 18:57:47 -080016 * @cpu: CPU
17 * @sig: if non-zero, the signal number which caused us to stop
Ilya Leoshkevich8b7fcb82024-02-07 16:38:09 +000018 * @reason: stop reason for stop reply packet or NULL
Gustavo Romerof84e3132024-03-09 03:08:59 +000019 * @siginfo: target-specific siginfo struct
20 * @siginfo_len: target-specific siginfo struct length
Alex Bennéed96bf492023-03-02 18:57:47 -080021 *
22 * This function yields control to gdb, when a user-mode-only target
23 * needs to stop execution. If @sig is non-zero, then we will send a
24 * stop packet to tell gdb that we have stopped because of this signal.
25 *
26 * This function will block (handling protocol requests from gdb)
27 * until gdb tells us to continue target execution. When it does
28 * return, the return value is a signal to deliver to the target,
29 * or 0 if no signal should be delivered, ie the signal that caused
30 * us to stop should be ignored.
31 */
Gustavo Romerof84e3132024-03-09 03:08:59 +000032int gdb_handlesig(CPUState *, int, const char *, void *, int);
Alex Bennéed96bf492023-03-02 18:57:47 -080033
34/**
35 * gdb_signalled() - inform remote gdb of sig exit
36 * @as: current CPUArchState
37 * @sig: signal number
38 */
39void gdb_signalled(CPUArchState *as, int sig);
40
41/**
Ilya Leoshkevich3d6ed982024-03-05 12:09:41 +000042 * gdbserver_fork_start() - inform gdb of the upcoming fork()
43 */
44void gdbserver_fork_start(void);
45
46/**
Ilya Leoshkevich6604b052024-03-05 12:09:44 +000047 * gdbserver_fork_end() - inform gdb of the completed fork()
Alex Bennéed96bf492023-03-02 18:57:47 -080048 * @cs: CPU
Ilya Leoshkevich6604b052024-03-05 12:09:44 +000049 * @pid: 0 if in child process, -1 if fork failed, child process pid otherwise
Alex Bennéed96bf492023-03-02 18:57:47 -080050 */
Ilya Leoshkevich6604b052024-03-05 12:09:44 +000051void gdbserver_fork_end(CPUState *cs, pid_t pid);
Alex Bennéed96bf492023-03-02 18:57:47 -080052
Ilya Leoshkevich0a0d87c2024-02-07 16:38:10 +000053/**
54 * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
55 * @cs: CPU
56 * @num: syscall number
57 */
58void gdb_syscall_entry(CPUState *cs, int num);
59
60/**
61 * gdb_syscall_entry() - inform gdb of syscall return and yield control to it
62 * @cs: CPU
63 * @num: syscall number
64 */
65void gdb_syscall_return(CPUState *cs, int num);
Alex Bennéed96bf492023-03-02 18:57:47 -080066
67#endif /* GDBSTUB_USER_H */