GDB (API)
/home/stan/gdb/src/gdb/linux-nat.h
Go to the documentation of this file.
00001 /* Native debugging support for GNU/Linux (LWP layer).
00002 
00003    Copyright (C) 2000-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "target.h"
00021 
00022 #include <signal.h>
00023 
00024 struct arch_lwp_info;
00025 
00026 /* Structure describing an LWP.  This is public only for the purposes
00027    of ALL_LWPS; target-specific code should generally not access it
00028    directly.  */
00029 
00030 struct lwp_info
00031 {
00032   /* The process id of the LWP.  This is a combination of the LWP id
00033      and overall process id.  */
00034   ptid_t ptid;
00035 
00036   /* Non-zero if this LWP is cloned.  In this context "cloned" means
00037      that the LWP is reporting to its parent using a signal other than
00038      SIGCHLD.  */
00039   int cloned;
00040 
00041   /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
00042      it back yet).  */
00043   int signalled;
00044 
00045   /* Non-zero if this LWP is stopped.  */
00046   int stopped;
00047 
00048   /* Non-zero if this LWP will be/has been resumed.  Note that an LWP
00049      can be marked both as stopped and resumed at the same time.  This
00050      happens if we try to resume an LWP that has a wait status
00051      pending.  We shouldn't let the LWP run until that wait status has
00052      been processed, but we should not report that wait status if GDB
00053      didn't try to let the LWP run.  */
00054   int resumed;
00055 
00056   /* The last resume GDB requested on this thread.  */
00057   enum resume_kind last_resume_kind;
00058 
00059   /* If non-zero, a pending wait status.  */
00060   int status;
00061 
00062   /* Non-zero if we were stepping this LWP.  */
00063   int step;
00064 
00065   /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
00066      watchpoint trap.  */
00067   int stopped_by_watchpoint;
00068 
00069   /* On architectures where it is possible to know the data address of
00070      a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and
00071      STOPPED_DATA_ADDRESS contains such data address.  Otherwise,
00072      STOPPED_DATA_ADDRESS_P is false, and STOPPED_DATA_ADDRESS is
00073      undefined.  Only valid if STOPPED_BY_WATCHPOINT is true.  */
00074   int stopped_data_address_p;
00075   CORE_ADDR stopped_data_address;
00076 
00077   /* Non-zero if we expect a duplicated SIGINT.  */
00078   int ignore_sigint;
00079 
00080   /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
00081      for this LWP's last event.  This may correspond to STATUS above,
00082      or to a local variable in lin_lwp_wait.  */
00083   struct target_waitstatus waitstatus;
00084 
00085   /* Signal wether we are in a SYSCALL_ENTRY or
00086      in a SYSCALL_RETURN event.
00087      Values:
00088      - TARGET_WAITKIND_SYSCALL_ENTRY
00089      - TARGET_WAITKIND_SYSCALL_RETURN */
00090   int syscall_state;
00091 
00092   /* The processor core this LWP was last seen on.  */
00093   int core;
00094 
00095   /* Arch-specific additions.  */
00096   struct arch_lwp_info *arch_private;
00097 
00098   /* Next LWP in list.  */
00099   struct lwp_info *next;
00100 };
00101 
00102 /* The global list of LWPs, for ALL_LWPS.  Unlike the threads list,
00103    there is always at least one LWP on the list while the GNU/Linux
00104    native target is active.  */
00105 extern struct lwp_info *lwp_list;
00106 
00107 /* Iterate over each active thread (light-weight process).  */
00108 #define ALL_LWPS(LP)                                                    \
00109   for ((LP) = lwp_list;                                                 \
00110        (LP) != NULL;                                                    \
00111        (LP) = (LP)->next)
00112 
00113 /* Attempt to initialize libthread_db.  */
00114 void check_for_thread_db (void);
00115 
00116 int thread_db_attach_lwp (ptid_t ptid);
00117 
00118 /* Return the set of signals used by the threads library.  */
00119 extern void lin_thread_get_thread_signals (sigset_t *mask);
00120 
00121 /* Find process PID's pending signal set from /proc/pid/status.  */
00122 void linux_proc_pending_signals (int pid, sigset_t *pending,
00123                                  sigset_t *blocked, sigset_t *ignored);
00124 
00125 extern int lin_lwp_attach_lwp (ptid_t ptid);
00126 
00127 extern void linux_stop_lwp (struct lwp_info *lwp);
00128 
00129 /* Iterator function for lin-lwp's lwp list.  */
00130 struct lwp_info *iterate_over_lwps (ptid_t filter,
00131                                     int (*callback) (struct lwp_info *,
00132                                                      void *), 
00133                                     void *data);
00134 
00135 /* Create a prototype generic GNU/Linux target.  The client can
00136    override it with local methods.  */
00137 struct target_ops * linux_target (void);
00138 
00139 /* Create a generic GNU/Linux target using traditional 
00140    ptrace register access.  */
00141 struct target_ops *
00142 linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
00143 
00144 /* Register the customized GNU/Linux target.  This should be used
00145    instead of calling add_target directly.  */
00146 void linux_nat_add_target (struct target_ops *);
00147 
00148 /* Register a method to call whenever a new thread is attached.  */
00149 void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *));
00150 
00151 
00152 /* Register a method to call whenever a new fork is attached.  */
00153 typedef void (linux_nat_new_fork_ftype) (struct lwp_info *parent,
00154                                          pid_t child_pid);
00155 void linux_nat_set_new_fork (struct target_ops *ops,
00156                              linux_nat_new_fork_ftype *fn);
00157 
00158 /* Register a method to call whenever a process is killed or
00159    detached.  */
00160 typedef void (linux_nat_forget_process_ftype) (pid_t pid);
00161 void linux_nat_set_forget_process (struct target_ops *ops,
00162                                    linux_nat_forget_process_ftype *fn);
00163 
00164 /* Call the method registered with the function above.  PID is the
00165    process to forget about.  */
00166 void linux_nat_forget_process (pid_t pid);
00167 
00168 /* Register a method that converts a siginfo object between the layout
00169    that ptrace returns, and the layout in the architecture of the
00170    inferior.  */
00171 void linux_nat_set_siginfo_fixup (struct target_ops *,
00172                                   int (*) (siginfo_t *,
00173                                            gdb_byte *,
00174                                            int));
00175 
00176 /* Register a method to call prior to resuming a thread.  */
00177 
00178 void linux_nat_set_prepare_to_resume (struct target_ops *,
00179                                       void (*) (struct lwp_info *));
00180 
00181 /* Update linux-nat internal state when changing from one fork
00182    to another.  */
00183 void linux_nat_switch_fork (ptid_t new_ptid);
00184 
00185 /* Store the saved siginfo associated with PTID in *SIGINFO.
00186    Return 1 if it was retrieved successfully, 0 otherwise (*SIGINFO is
00187    uninitialized in such case).  */
00188 int linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
00189 
00190 /* Set alternative SIGTRAP-like events recognizer.  */
00191 void linux_nat_set_status_is_event (struct target_ops *t,
00192                                     int (*status_is_event) (int status));
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines