user.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * gdbstub user-mode only APIs
  3. *
  4. * Copyright (c) 2022 Linaro Ltd
  5. *
  6. * SPDX-License-Identifier: LGPL-2.0-or-later
  7. */
  8. #ifndef GDBSTUB_USER_H
  9. #define GDBSTUB_USER_H
  10. #define MAX_SIGINFO_LENGTH 128
  11. /**
  12. * gdb_handlesig() - yield control to gdb
  13. * @cpu: CPU
  14. * @sig: if non-zero, the signal number which caused us to stop
  15. * @reason: stop reason for stop reply packet or NULL
  16. * @siginfo: target-specific siginfo struct
  17. * @siginfo_len: target-specific siginfo struct length
  18. *
  19. * This function yields control to gdb, when a user-mode-only target
  20. * needs to stop execution. If @sig is non-zero, then we will send a
  21. * stop packet to tell gdb that we have stopped because of this signal.
  22. *
  23. * This function will block (handling protocol requests from gdb)
  24. * until gdb tells us to continue target execution. When it does
  25. * return, the return value is a signal to deliver to the target,
  26. * or 0 if no signal should be delivered, ie the signal that caused
  27. * us to stop should be ignored.
  28. */
  29. int gdb_handlesig(CPUState *, int, const char *, void *, int);
  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. * gdbserver_fork_start() - inform gdb of the upcoming fork()
  38. */
  39. void gdbserver_fork_start(void);
  40. /**
  41. * gdbserver_fork_end() - inform gdb of the completed fork()
  42. * @cs: CPU
  43. * @pid: 0 if in child process, -1 if fork failed, child process pid otherwise
  44. */
  45. void gdbserver_fork_end(CPUState *cs, pid_t pid);
  46. /**
  47. * gdb_syscall_entry() - inform gdb of syscall entry and yield control to it
  48. * @cs: CPU
  49. * @num: syscall number
  50. */
  51. void gdb_syscall_entry(CPUState *cs, int num);
  52. /**
  53. * gdb_syscall_entry() - inform gdb of syscall return and yield control to it
  54. * @cs: CPU
  55. * @num: syscall number
  56. */
  57. void gdb_syscall_return(CPUState *cs, int num);
  58. #endif /* GDBSTUB_USER_H */