GDB (API)
/home/stan/gdb/src/gdb/gdb_proc_service.h
Go to the documentation of this file.
00001 /* <proc_service.h> replacement for systems that don't have it.
00002    Copyright (C) 2000-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #ifndef GDB_PROC_SERVICE_H
00020 #define GDB_PROC_SERVICE_H
00021 
00022 #include <sys/types.h>
00023 
00024 #ifdef HAVE_PROC_SERVICE_H
00025 #include <proc_service.h>
00026 
00027 #else /* HAVE_PROC_SERVICE_H */
00028 
00029 /* The following fallback definitions have been imported and adjusted
00030    from glibc's proc_service.h  */
00031 
00032 /* Callback interface for libthread_db, functions users must define.
00033    Copyright (C) 1999,2002,2003 Free Software Foundation, Inc.
00034    This file is part of the GNU C Library.
00035 
00036    The GNU C Library is free software; you can redistribute it and/or
00037    modify it under the terms of the GNU Lesser General Public
00038    License as published by the Free Software Foundation; either
00039    version 2.1 of the License, or (at your option) any later version.
00040 
00041    The GNU C Library is distributed in the hope that it will be useful,
00042    but WITHOUT ANY WARRANTY; without even the implied warranty of
00043    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00044    Lesser General Public License for more details.
00045 
00046    You should have received a copy of the GNU Lesser General Public
00047    License along with the GNU C Library; if not, see
00048    <http://www.gnu.org/licenses/>.  */
00049 
00050 /* The definitions in this file must correspond to those in the debugger.  */
00051 
00052 #ifdef HAVE_SYS_PROCFS_H
00053 #include <sys/procfs.h>
00054 #endif
00055 
00056 #include "gregset.h"
00057 
00058 /* Functions in this interface return one of these status codes.  */
00059 typedef enum
00060 {
00061   PS_OK,                /* Generic "call succeeded".  */
00062   PS_ERR,               /* Generic error. */
00063   PS_BADPID,            /* Bad process handle.  */
00064   PS_BADLID,            /* Bad LWP identifier.  */
00065   PS_BADADDR,           /* Bad address.  */
00066   PS_NOSYM,             /* Could not find given symbol.  */
00067   PS_NOFREGS            /* FPU register set not available for given LWP.  */
00068 } ps_err_e;
00069 
00070 #ifndef HAVE_LWPID_T
00071 typedef unsigned int lwpid_t;
00072 #endif
00073 
00074 #ifndef HAVE_PSADDR_T
00075 typedef void *psaddr_t;
00076 #endif
00077 
00078 #ifndef HAVE_PRGREGSET_T
00079 typedef gdb_gregset_t prgregset_t;
00080 #endif
00081 
00082 #ifndef HAVE_PRFPREGSET_T
00083 typedef gdb_fpregset_t prfpregset_t;
00084 #endif
00085 
00086 /* This type is opaque in this interface.  It's defined by the user of
00087    libthread_db.  GDB's version is defined below.  */
00088 struct ps_prochandle;
00089 
00090 
00091 /* Read or write process memory at the given address.  */
00092 extern ps_err_e ps_pdread (struct ps_prochandle *,
00093                            psaddr_t, void *, size_t);
00094 extern ps_err_e ps_pdwrite (struct ps_prochandle *,
00095                             psaddr_t, const void *, size_t);
00096 extern ps_err_e ps_ptread (struct ps_prochandle *,
00097                            psaddr_t, void *, size_t);
00098 extern ps_err_e ps_ptwrite (struct ps_prochandle *,
00099                             psaddr_t, const void *, size_t);
00100 
00101 
00102 /* Get and set the given LWP's general or FPU register set.  */
00103 extern ps_err_e ps_lgetregs (struct ps_prochandle *,
00104                              lwpid_t, prgregset_t);
00105 extern ps_err_e ps_lsetregs (struct ps_prochandle *,
00106                              lwpid_t, const prgregset_t);
00107 extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
00108                                lwpid_t, prfpregset_t *);
00109 extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
00110                                lwpid_t, const prfpregset_t *);
00111 
00112 /* Return the PID of the process.  */
00113 extern pid_t ps_getpid (struct ps_prochandle *);
00114 
00115 /* Fetch the special per-thread address associated with the given LWP.
00116    This call is only used on a few platforms (most use a normal register).
00117    The meaning of the `int' parameter is machine-dependent.  */
00118 extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,
00119                                     lwpid_t, int, psaddr_t *);
00120 
00121 
00122 /* Look up the named symbol in the named DSO in the symbol tables
00123    associated with the process being debugged, filling in *SYM_ADDR
00124    with the corresponding run-time address.  */
00125 extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
00126                                    const char *object_name,
00127                                    const char *sym_name,
00128                                    psaddr_t *sym_addr);
00129 
00130 
00131 /* Stop or continue the entire process.  */
00132 extern ps_err_e ps_pstop (struct ps_prochandle *);
00133 extern ps_err_e ps_pcontinue (struct ps_prochandle *);
00134 
00135 /* Stop or continue the given LWP alone.  */
00136 extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t);
00137 extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
00138 
00139 /* The following are only defined in/called by Solaris.  */
00140 
00141 /* Get size of extra register set.  */
00142 extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
00143                                  lwpid_t lwpid, int *xregsize);
00144 /* Get extra register set.  */
00145 extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
00146                               caddr_t xregset);
00147 extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
00148                               caddr_t xregset);
00149 
00150 /* Log a message (sends to gdb_stderr).  */
00151 extern void ps_plog (const char *fmt, ...);
00152 
00153 #endif /* HAVE_PROC_SERVICE_H */
00154 
00155 /* Fix-up some broken systems.  */
00156 
00157 /* Unfortunately glibc 2.1.3 was released with a broken prfpregset_t
00158    type.  We let configure check for this lossage, and make
00159    appropriate typedefs here.  */
00160 
00161 #ifdef PRFPREGSET_T_BROKEN
00162 typedef gdb_fpregset_t gdb_prfpregset_t;
00163 #else
00164 typedef prfpregset_t gdb_prfpregset_t;
00165 #endif
00166 
00167 /* GDB specific structure that identifies the target process.  */
00168 struct ps_prochandle
00169 {
00170   /* The LWP we use for memory reads.  */
00171   ptid_t ptid;
00172 };
00173 
00174 #endif /* gdb_proc_service.h */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines