PR breakpoint/12803
[deliverable/binutils-gdb.git] / gdb / gdb_thread_db.h
index 5bb196344b121e7e893e43b325267f1d8e0fefae..e20b41506b25248df99d6af9a5109c5d0de3f6ae 100644 (file)
@@ -1,9 +1,26 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+#ifdef HAVE_THREAD_DB_H
+#include <thread_db.h>
+
+#ifndef LIBTHREAD_DB_SO
+#define LIBTHREAD_DB_SO "libthread_db.so.1"
+#endif
+
+#ifndef LIBTHREAD_DB_SEARCH_PATH
+/* $sdir appears before $pdir for some minimal security protection:
+   we trust the system libthread_db.so a bit more than some random
+   libthread_db associated with whatever libpthread the app is using.  */
+#define LIBTHREAD_DB_SEARCH_PATH "$sdir:$pdir"
+#endif
+
+#else
+
+/* Copyright (C) 1999, 2000, 2007, 2008, 2009, 2010, 2011
+Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
+   published by the Free Software Foundation; either version 3 of the
    License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _THREAD_DB_H
 #define _THREAD_DB_H   1
    modelled closely after the interface with same names in Solaris with
    the goal to share the same code in the debugger.  */
 #include <pthread.h>
-#include <stdint.h>
 #include <sys/types.h>
-/*#include <sys/ucontext.h>*/
+#include <sys/procfs.h>
 
 
 /* Error codes of the library.  */
 typedef enum
 {
-  TD_OK,       /* No error.  */
-  TD_ERR,      /* No further specified error.  */
-  TD_NOTHR,    /* No matching thread found.  */
-  TD_NOSV,     /* No matching synchronization handle found.  */
-  TD_NOLWP,    /* No matching light-weighted process found.  */
-  TD_BADPH,    /* Invalid process handle.  */
-  TD_BADTH,    /* Invalid thread handle.  */
-  TD_BADSH,    /* Invalid synchronization handle.  */
-  TD_BADTA,    /* Invalid thread agent.  */
-  TD_BADKEY,   /* Invalid key.  */
-  TD_NOMSG,    /* No event available.  */
-  TD_NOFPREGS, /* No floating-point register content available.  */
-  TD_NOLIBTHREAD,      /* Application not linked with thread library.  */
-  TD_NOEVENT,  /* Requested event is not supported.  */
-  TD_NOCAPAB,  /* Capability not available.  */
-  TD_DBERR,    /* Internal debug library error.  */
-  TD_NOAPLIC,  /* Operation is not applicable.  */
-  TD_NOTSD,    /* No thread-specific data available.  */
-  TD_MALLOC,   /* Out of memory.  */
-  TD_PARTIALREG,/* Not entire register set was read or written.  */
-  TD_NOXREGS   /* X register set not available for given thread.  */
+  TD_OK,         /* No error.  */
+  TD_ERR,        /* No further specified error.  */
+  TD_NOTHR,      /* No matching thread found.  */
+  TD_NOSV,       /* No matching synchronization handle found.  */
+  TD_NOLWP,      /* No matching light-weighted process found.  */
+  TD_BADPH,      /* Invalid process handle.  */
+  TD_BADTH,      /* Invalid thread handle.  */
+  TD_BADSH,      /* Invalid synchronization handle.  */
+  TD_BADTA,      /* Invalid thread agent.  */
+  TD_BADKEY,     /* Invalid key.  */
+  TD_NOMSG,      /* No event available.  */
+  TD_NOFPREGS,   /* No floating-point register content available.  */
+  TD_NOLIBTHREAD, /* Application not linked with thread library.  */
+  TD_NOEVENT,    /* Requested event is not supported.  */
+  TD_NOCAPAB,    /* Capability not available.  */
+  TD_DBERR,      /* Internal debug library error.  */
+  TD_NOAPLIC,    /* Operation is not applicable.  */
+  TD_NOTSD,      /* No thread-specific data available.  */
+  TD_MALLOC,     /* Out of memory.  */
+  TD_PARTIALREG,  /* Not entire register set was read or written.  */
+  TD_NOXREGS,    /* X register set not available for given thread.  */
+  TD_NOTALLOC    /* TLS memory not yet allocated.  */
 } td_err_e;
 
 
@@ -81,9 +96,6 @@ typedef enum
 
 /* Types of the debugging library.  */
 
-/* Addresses.  */
-/*typedef void *psaddr_t;*/
-
 /* Handle for a process.  This type is opaque.  */
 typedef struct td_thragent td_thragent_t;
 
@@ -102,17 +114,18 @@ typedef struct td_thrhandle
 
 
 #define TD_EVENTSIZE   2
-#define BT_UISHIFT     5 /* log base 2 of BT_NBIPUI, to extract word index */
-#define BT_NBIPUI      (1 << BT_UISHIFT)       /* n bits per uint */
-#define BT_UIMASK      (BT_NBIPUI - 1)         /* to extract bit index */
+#define BT_UISHIFT     5               /* log base 2 of BT_NBIPUI, to
+                                          extract word index.  */
+#define BT_NBIPUI      (1 << BT_UISHIFT)       /* n bits per uint.  */
+#define BT_UIMASK      (BT_NBIPUI - 1)         /* to extract bit index.  */
 
-/* Bitmask of enabled events. */
+/* Bitmask of enabled events.  */
 typedef struct td_thr_events
 {
   uint32_t event_bits[TD_EVENTSIZE];
 } td_thr_events_t;
 
-/* Event set manipulation macros. */
+/* Event set manipulation macros.  */
 #define __td_eventmask(n) \
   (UINT32_C (1) << (((n) - 1) & BT_UIMASK))
 #define __td_eventword(n) \
@@ -150,7 +163,7 @@ typedef enum
 {
   TD_ALL_EVENTS,                /* Pseudo-event number.  */
   TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context.  */
-  TD_READY,                     /* Is executable now. */
+  TD_READY,                     /* Is executable now.  */
   TD_SLEEP,                     /* Blocked in a synchronization obj.  */
   TD_SWITCHTO,                  /* Now assigned to a process.  */
   TD_SWITCHFROM,                /* Not anymore assigned to a process.  */
@@ -172,7 +185,8 @@ typedef enum
 /* Values representing the different ways events are reported.  */
 typedef enum
 {
-  NOTIFY_BPT,                  /* User must insert breakpoint at u.bptaddr. */
+  NOTIFY_BPT,                  /* User must insert breakpoint at
+                                  u.bptaddr.  */
   NOTIFY_AUTOBPT,              /* Breakpoint at u.bptaddr is automatically
                                   inserted.  */
   NOTIFY_SYSCALL               /* System call u.syscallno will be invoked.  */
@@ -189,6 +203,16 @@ typedef struct td_notify
   } u;
 } td_notify_t;
 
+/* Some people still have libc5 or old glibc with no uintptr_t.
+   They lose.  glibc 2.1.3 was released on 2000-02-25, and it has
+   uintptr_t, so it's reasonable to force these people to upgrade.  */
+
+#ifndef HAVE_UINTPTR_T
+#error No uintptr_t available; your C library is too old.
+/* Inhibit further compilation errors after this error.  */
+#define uintptr_t void *
+#endif
+
 /* Structure used to report event.  */
 typedef struct td_event_msg
 {
@@ -196,13 +220,21 @@ typedef struct td_event_msg
   const td_thrhandle_t *th_p;  /* Thread reporting the event.  */
   union
   {
-# if 0
+#if 0
     td_synchandle_t *sh;       /* Handle of synchronization object.  */
 #endif
     uintptr_t data;            /* Event specific data.  */
   } msg;
 } td_event_msg_t;
 
+/* Structure containing event data available in each thread structure.  */
+typedef struct
+{
+  td_thr_events_t eventmask;   /* Mask of enabled events.  */
+  td_event_e eventnum;         /* Number of last event.  */
+  void *eventdata;             /* Data associated with event.  */
+} td_eventbuf_t;
+
 
 /* Gathered statistics about the process.  */
 typedef struct td_ta_stats
@@ -229,26 +261,18 @@ typedef struct td_ta_stats
 typedef pthread_t thread_t;
 typedef pthread_key_t thread_key_t;
 
-/* Linux has different names for the register set types.  */
-/*typedef gregset_t prgregset_t;*/
-/*typedef fpregset_t prfpregset_t;*/
-
 
 /* Callback for iteration over threads.  */
-typedef int td_thr_iter_f __P ((const td_thrhandle_t *, void *));
+typedef int td_thr_iter_f (const td_thrhandle_t *, void *);
 
 /* Callback for iteration over thread local data.  */
-typedef int td_key_iter_f __P ((thread_key_t, void (*) (void *), void *));
+typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
 
 
 
 /* Forward declaration.  This has to be defined by the user.  */
 struct ps_prochandle;
 
-/* We don't have any differences between processes and threads, therefore
-   have only one PID type.  */
-/*typedef pid_t lwpid_t;*/
-
 
 /* Information about the thread.  */
 typedef struct td_thrinfo
@@ -265,14 +289,15 @@ typedef struct td_thrinfo
   psaddr_t ti_ro_area;                 /* Unused.  */
   int ti_ro_size;                      /* Unused.  */
   td_thr_state_e ti_state;             /* Thread state.  */
-  unsigned char ti_db_suspended;       /* Nonzero if suspended by debugger. */
+  unsigned char ti_db_suspended;       /* Nonzero if suspended by
+                                          debugger.  */
   td_thr_type_e ti_type;               /* Type of the thread (system vs
                                           user thread).  */
   intptr_t ti_pc;                      /* Unused.  */
   intptr_t ti_sp;                      /* Unused.  */
   short int ti_flags;                  /* Unused.  */
   int ti_pri;                          /* Thread priority.  */
-  lwpid_t ti_lid;                      /* Unused.  */
+  lwpid_t ti_lid;                      /* Kernel pid for this thread.  */
   sigset_t ti_sigmask;                 /* Signal mask.  */
   unsigned char ti_traceme;            /* Nonzero if event reporting
                                           enabled.  */
@@ -334,6 +359,18 @@ extern td_err_e td_ta_tsd_iter (const td_thragent_t *__ta, td_key_iter_f *__ki,
 extern td_err_e td_ta_event_addr (const td_thragent_t *__ta,
                                  td_event_e __event, td_notify_t *__ptr);
 
+/* Enable EVENT in global mask.  */
+extern td_err_e td_ta_set_event (const td_thragent_t *__ta,
+                                td_thr_events_t *__event);
+
+/* Disable EVENT in global mask.  */
+extern td_err_e td_ta_clear_event (const td_thragent_t *__ta,
+                                  td_thr_events_t *__event);
+
+/* Return information about last event.  */
+extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta,
+                                   td_event_msg_t *msg);
+
 
 /* Set suggested concurrency level for process associated with TA.  */
 extern td_err_e td_ta_setconcurrency (const td_thragent_t *__ta, int __level);
@@ -425,3 +462,5 @@ extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
 extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
 
 #endif /* thread_db.h */
+
+#endif /* HAVE_THREAD_DB_H */
This page took 0.027279 seconds and 4 git commands to generate.