proc_service.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Callback interface for libthread_db, functions users must define.
  2. Copyright (C) 1999-2020 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _PROC_SERVICE_H
  16. #define _PROC_SERVICE_H 1
  17. /* The definitions in this file must correspond to those in the debugger. */
  18. #include <sys/procfs.h>
  19. __BEGIN_DECLS
  20. /* Functions in this interface return one of these status codes. */
  21. typedef enum
  22. {
  23. PS_OK, /* Generic "call succeeded". */
  24. PS_ERR, /* Generic error. */
  25. PS_BADPID, /* Bad process handle. */
  26. PS_BADLID, /* Bad LWP identifier. */
  27. PS_BADADDR, /* Bad address. */
  28. PS_NOSYM, /* Could not find given symbol. */
  29. PS_NOFREGS /* FPU register set not available for given LWP. */
  30. } ps_err_e;
  31. /* This type is opaque in this interface.
  32. It's defined by the user of libthread_db. */
  33. struct ps_prochandle;
  34. /* Read or write process memory at the given address. */
  35. extern ps_err_e ps_pdread (struct ps_prochandle *,
  36. psaddr_t, void *, size_t);
  37. extern ps_err_e ps_pdwrite (struct ps_prochandle *,
  38. psaddr_t, const void *, size_t);
  39. extern ps_err_e ps_ptread (struct ps_prochandle *,
  40. psaddr_t, void *, size_t);
  41. extern ps_err_e ps_ptwrite (struct ps_prochandle *,
  42. psaddr_t, const void *, size_t);
  43. /* Get and set the given LWP's general or FPU register set. */
  44. extern ps_err_e ps_lgetregs (struct ps_prochandle *,
  45. lwpid_t, prgregset_t);
  46. extern ps_err_e ps_lsetregs (struct ps_prochandle *,
  47. lwpid_t, const prgregset_t);
  48. extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
  49. lwpid_t, prfpregset_t *);
  50. extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
  51. lwpid_t, const prfpregset_t *);
  52. /* Return the PID of the process. */
  53. extern pid_t ps_getpid (struct ps_prochandle *);
  54. /* Fetch the special per-thread address associated with the given LWP.
  55. This call is only used on a few platforms (most use a normal register).
  56. The meaning of the `int' parameter is machine-dependent. */
  57. extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
  58. lwpid_t, int, psaddr_t *);
  59. /* Look up the named symbol in the named DSO in the symbol tables
  60. associated with the process being debugged, filling in *SYM_ADDR
  61. with the corresponding run-time address. */
  62. extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
  63. const char *object_name,
  64. const char *sym_name,
  65. psaddr_t *sym_addr);
  66. /* Stop or continue the entire process. */
  67. extern ps_err_e ps_pstop (struct ps_prochandle *);
  68. extern ps_err_e ps_pcontinue (struct ps_prochandle *);
  69. /* Stop or continue the given LWP alone. */
  70. extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
  71. extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
  72. __END_DECLS
  73. #endif /* proc_service.h */