gdb/gdb_proc_service.h - gdb

Data types defined

Macros defined

Source code

  1. /* <proc_service.h> replacement for systems that don't have it.
  2.    Copyright (C) 2000-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program 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
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef GDB_PROC_SERVICE_H
  15. #define GDB_PROC_SERVICE_H

  16. #include <sys/types.h>

  17. #ifdef HAVE_PROC_SERVICE_H
  18. #include <proc_service.h>

  19. #else /* HAVE_PROC_SERVICE_H */

  20. /* The following fallback definitions have been imported and adjusted
  21.    from glibc's proc_service.h  */

  22. /* Callback interface for libthread_db, functions users must define.
  23.    Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
  24.    This file is part of the GNU C Library.

  25.    The GNU C Library is free software; you can redistribute it and/or
  26.    modify it under the terms of the GNU Lesser General Public
  27.    License as published by the Free Software Foundation; either
  28.    version 2.1 of the License, or (at your option) any later version.

  29.    The GNU C Library is distributed in the hope that it will be useful,
  30.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  31.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  32.    Lesser General Public License for more details.

  33.    You should have received a copy of the GNU Lesser General Public
  34.    License along with the GNU C Library; if not, see
  35.    <http://www.gnu.org/licenses/>.  */

  36. /* The definitions in this file must correspond to those in the debugger.  */

  37. #ifdef HAVE_SYS_PROCFS_H
  38. #include <sys/procfs.h>
  39. #endif

  40. #include "gregset.h"

  41. /* Functions in this interface return one of these status codes.  */
  42. typedef enum
  43. {
  44.   PS_OK,                /* Generic "call succeeded".  */
  45.   PS_ERR,                /* Generic error. */
  46.   PS_BADPID,                /* Bad process handle.  */
  47.   PS_BADLID,                /* Bad LWP identifier.  */
  48.   PS_BADADDR,                /* Bad address.  */
  49.   PS_NOSYM,                /* Could not find given symbol.  */
  50.   PS_NOFREGS                /* FPU register set not available for given LWP.  */
  51. } ps_err_e;

  52. #ifndef HAVE_LWPID_T
  53. typedef unsigned int lwpid_t;
  54. #endif

  55. #ifndef HAVE_PSADDR_T
  56. typedef void *psaddr_t;
  57. #endif

  58. #ifndef HAVE_PRGREGSET_T
  59. typedef gdb_gregset_t prgregset_t;
  60. #endif

  61. #ifndef HAVE_PRFPREGSET_T
  62. typedef gdb_fpregset_t prfpregset_t;
  63. #endif

  64. /* This type is opaque in this interface.  It's defined by the user of
  65.    libthread_db.  GDB's version is defined below.  */
  66. struct ps_prochandle;


  67. /* Read or write process memory at the given address.  */
  68. extern ps_err_e ps_pdread (struct ps_prochandle *,
  69.                            psaddr_t, void *, size_t);
  70. extern ps_err_e ps_pdwrite (struct ps_prochandle *,
  71.                             psaddr_t, const void *, size_t);
  72. extern ps_err_e ps_ptread (struct ps_prochandle *,
  73.                            psaddr_t, void *, size_t);
  74. extern ps_err_e ps_ptwrite (struct ps_prochandle *,
  75.                             psaddr_t, const void *, size_t);


  76. /* Get and set the given LWP's general or FPU register set.  */
  77. extern ps_err_e ps_lgetregs (struct ps_prochandle *,
  78.                              lwpid_t, prgregset_t);
  79. extern ps_err_e ps_lsetregs (struct ps_prochandle *,
  80.                              lwpid_t, const prgregset_t);
  81. extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
  82.                                lwpid_t, prfpregset_t *);
  83. extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
  84.                                lwpid_t, const prfpregset_t *);

  85. /* Return the PID of the process.  */
  86. extern pid_t ps_getpid (struct ps_prochandle *);

  87. /* Fetch the special per-thread address associated with the given LWP.
  88.    This call is only used on a few platforms (most use a normal register).
  89.    The meaning of the `int' parameter is machine-dependent.  */
  90. extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,
  91.                                     lwpid_t, int, psaddr_t *);


  92. /* Look up the named symbol in the named DSO in the symbol tables
  93.    associated with the process being debugged, filling in *SYM_ADDR
  94.    with the corresponding run-time address.  */
  95. extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
  96.                                    const char *object_name,
  97.                                    const char *sym_name,
  98.                                    psaddr_t *sym_addr);


  99. /* Stop or continue the entire process.  */
  100. extern ps_err_e ps_pstop (struct ps_prochandle *);
  101. extern ps_err_e ps_pcontinue (struct ps_prochandle *);

  102. /* Stop or continue the given LWP alone.  */
  103. extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
  104. extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);

  105. /* The following are only defined in/called by Solaris.  */

  106. /* Get size of extra register set.  */
  107. extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
  108.                                  lwpid_t lwpid, int *xregsize);
  109. /* Get extra register set.  */
  110. extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
  111.                               caddr_t xregset);
  112. extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
  113.                               caddr_t xregset);

  114. /* Log a message (sends to gdb_stderr).  */
  115. extern void ps_plog (const char *fmt, ...);

  116. #endif /* HAVE_PROC_SERVICE_H */

  117. /* Fix-up some broken systems.  */

  118. /* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
  119.    type.  We let configure check for this lossage, and make
  120.    appropriate typedefs here.  */

  121. #ifdef PRFPREGSET_T_BROKEN
  122. typedef gdb_fpregset_t gdb_prfpregset_t;
  123. #else
  124. typedef prfpregset_t gdb_prfpregset_t;
  125. #endif

  126. /* GDB specific structure that identifies the target process.  */
  127. struct ps_prochandle
  128. {
  129.   /* The LWP we use for memory reads.  */
  130.   ptid_t ptid;
  131. };

  132. #endif /* gdb_proc_service.h */