Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * gdbstub user-mode only APIs |
| 3 | * |
| 4 | * Copyright (c) 2022 Linaro Ltd |
| 5 | * |
Philippe Mathieu-Daudé | b14d064 | 2024-09-11 17:12:04 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: LGPL-2.0-or-later |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef GDBSTUB_USER_H |
| 10 | #define GDBSTUB_USER_H |
| 11 | |
Gustavo Romero | f84e313 | 2024-03-09 03:08:59 +0000 | [diff] [blame] | 12 | #define MAX_SIGINFO_LENGTH 128 |
| 13 | |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 14 | /** |
Gustavo Romero | b6617e9 | 2024-03-09 03:08:57 +0000 | [diff] [blame] | 15 | * gdb_handlesig() - yield control to gdb |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 16 | * @cpu: CPU |
| 17 | * @sig: if non-zero, the signal number which caused us to stop |
Ilya Leoshkevich | 8b7fcb8 | 2024-02-07 16:38:09 +0000 | [diff] [blame] | 18 | * @reason: stop reason for stop reply packet or NULL |
Gustavo Romero | f84e313 | 2024-03-09 03:08:59 +0000 | [diff] [blame] | 19 | * @siginfo: target-specific siginfo struct |
| 20 | * @siginfo_len: target-specific siginfo struct length |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 21 | * |
| 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 Romero | f84e313 | 2024-03-09 03:08:59 +0000 | [diff] [blame] | 32 | int gdb_handlesig(CPUState *, int, const char *, void *, int); |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * gdb_signalled() - inform remote gdb of sig exit |
| 36 | * @as: current CPUArchState |
| 37 | * @sig: signal number |
| 38 | */ |
| 39 | void gdb_signalled(CPUArchState *as, int sig); |
| 40 | |
| 41 | /** |
Ilya Leoshkevich | 3d6ed98 | 2024-03-05 12:09:41 +0000 | [diff] [blame] | 42 | * gdbserver_fork_start() - inform gdb of the upcoming fork() |
| 43 | */ |
| 44 | void gdbserver_fork_start(void); |
| 45 | |
| 46 | /** |
Ilya Leoshkevich | 6604b05 | 2024-03-05 12:09:44 +0000 | [diff] [blame] | 47 | * gdbserver_fork_end() - inform gdb of the completed fork() |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 48 | * @cs: CPU |
Ilya Leoshkevich | 6604b05 | 2024-03-05 12:09:44 +0000 | [diff] [blame] | 49 | * @pid: 0 if in child process, -1 if fork failed, child process pid otherwise |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 50 | */ |
Ilya Leoshkevich | 6604b05 | 2024-03-05 12:09:44 +0000 | [diff] [blame] | 51 | void gdbserver_fork_end(CPUState *cs, pid_t pid); |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 52 | |
Ilya Leoshkevich | 0a0d87c | 2024-02-07 16:38:10 +0000 | [diff] [blame] | 53 | /** |
| 54 | * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it |
| 55 | * @cs: CPU |
| 56 | * @num: syscall number |
| 57 | */ |
| 58 | void 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 | */ |
| 65 | void gdb_syscall_return(CPUState *cs, int num); |
Alex Bennée | d96bf49 | 2023-03-02 18:57:47 -0800 | [diff] [blame] | 66 | |
| 67 | #endif /* GDBSTUB_USER_H */ |