Home | History | Annotate | Line # | Download | only in gdb
linux-nat.h revision 1.1
      1  1.1  christos /* Native debugging support for GNU/Linux (LWP layer).
      2  1.1  christos 
      3  1.1  christos    Copyright (C) 2000-2014 Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    This file is part of GDB.
      6  1.1  christos 
      7  1.1  christos    This program is free software; you can redistribute it and/or modify
      8  1.1  christos    it under the terms of the GNU General Public License as published by
      9  1.1  christos    the Free Software Foundation; either version 3 of the License, or
     10  1.1  christos    (at your option) any later version.
     11  1.1  christos 
     12  1.1  christos    This program is distributed in the hope that it will be useful,
     13  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  1.1  christos    GNU General Public License for more details.
     16  1.1  christos 
     17  1.1  christos    You should have received a copy of the GNU General Public License
     18  1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19  1.1  christos 
     20  1.1  christos #include "target.h"
     21  1.1  christos 
     22  1.1  christos #include <signal.h>
     23  1.1  christos 
     24  1.1  christos struct arch_lwp_info;
     25  1.1  christos 
     26  1.1  christos /* Structure describing an LWP.  This is public only for the purposes
     27  1.1  christos    of ALL_LWPS; target-specific code should generally not access it
     28  1.1  christos    directly.  */
     29  1.1  christos 
     30  1.1  christos struct lwp_info
     31  1.1  christos {
     32  1.1  christos   /* The process id of the LWP.  This is a combination of the LWP id
     33  1.1  christos      and overall process id.  */
     34  1.1  christos   ptid_t ptid;
     35  1.1  christos 
     36  1.1  christos   /* Non-zero if this LWP is cloned.  In this context "cloned" means
     37  1.1  christos      that the LWP is reporting to its parent using a signal other than
     38  1.1  christos      SIGCHLD.  */
     39  1.1  christos   int cloned;
     40  1.1  christos 
     41  1.1  christos   /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
     42  1.1  christos      it back yet).  */
     43  1.1  christos   int signalled;
     44  1.1  christos 
     45  1.1  christos   /* Non-zero if this LWP is stopped.  */
     46  1.1  christos   int stopped;
     47  1.1  christos 
     48  1.1  christos   /* Non-zero if this LWP will be/has been resumed.  Note that an LWP
     49  1.1  christos      can be marked both as stopped and resumed at the same time.  This
     50  1.1  christos      happens if we try to resume an LWP that has a wait status
     51  1.1  christos      pending.  We shouldn't let the LWP run until that wait status has
     52  1.1  christos      been processed, but we should not report that wait status if GDB
     53  1.1  christos      didn't try to let the LWP run.  */
     54  1.1  christos   int resumed;
     55  1.1  christos 
     56  1.1  christos   /* The last resume GDB requested on this thread.  */
     57  1.1  christos   enum resume_kind last_resume_kind;
     58  1.1  christos 
     59  1.1  christos   /* If non-zero, a pending wait status.  */
     60  1.1  christos   int status;
     61  1.1  christos 
     62  1.1  christos   /* Non-zero if we were stepping this LWP.  */
     63  1.1  christos   int step;
     64  1.1  christos 
     65  1.1  christos   /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
     66  1.1  christos      watchpoint trap.  */
     67  1.1  christos   int stopped_by_watchpoint;
     68  1.1  christos 
     69  1.1  christos   /* On architectures where it is possible to know the data address of
     70  1.1  christos      a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and
     71  1.1  christos      STOPPED_DATA_ADDRESS contains such data address.  Otherwise,
     72  1.1  christos      STOPPED_DATA_ADDRESS_P is false, and STOPPED_DATA_ADDRESS is
     73  1.1  christos      undefined.  Only valid if STOPPED_BY_WATCHPOINT is true.  */
     74  1.1  christos   int stopped_data_address_p;
     75  1.1  christos   CORE_ADDR stopped_data_address;
     76  1.1  christos 
     77  1.1  christos   /* Non-zero if we expect a duplicated SIGINT.  */
     78  1.1  christos   int ignore_sigint;
     79  1.1  christos 
     80  1.1  christos   /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
     81  1.1  christos      for this LWP's last event.  This may correspond to STATUS above,
     82  1.1  christos      or to a local variable in lin_lwp_wait.  */
     83  1.1  christos   struct target_waitstatus waitstatus;
     84  1.1  christos 
     85  1.1  christos   /* Signal wether we are in a SYSCALL_ENTRY or
     86  1.1  christos      in a SYSCALL_RETURN event.
     87  1.1  christos      Values:
     88  1.1  christos      - TARGET_WAITKIND_SYSCALL_ENTRY
     89  1.1  christos      - TARGET_WAITKIND_SYSCALL_RETURN */
     90  1.1  christos   int syscall_state;
     91  1.1  christos 
     92  1.1  christos   /* The processor core this LWP was last seen on.  */
     93  1.1  christos   int core;
     94  1.1  christos 
     95  1.1  christos   /* Arch-specific additions.  */
     96  1.1  christos   struct arch_lwp_info *arch_private;
     97  1.1  christos 
     98  1.1  christos   /* Next LWP in list.  */
     99  1.1  christos   struct lwp_info *next;
    100  1.1  christos };
    101  1.1  christos 
    102  1.1  christos /* The global list of LWPs, for ALL_LWPS.  Unlike the threads list,
    103  1.1  christos    there is always at least one LWP on the list while the GNU/Linux
    104  1.1  christos    native target is active.  */
    105  1.1  christos extern struct lwp_info *lwp_list;
    106  1.1  christos 
    107  1.1  christos /* Iterate over each active thread (light-weight process).  */
    108  1.1  christos #define ALL_LWPS(LP)							\
    109  1.1  christos   for ((LP) = lwp_list;							\
    110  1.1  christos        (LP) != NULL;							\
    111  1.1  christos        (LP) = (LP)->next)
    112  1.1  christos 
    113  1.1  christos /* Attempt to initialize libthread_db.  */
    114  1.1  christos void check_for_thread_db (void);
    115  1.1  christos 
    116  1.1  christos int thread_db_attach_lwp (ptid_t ptid);
    117  1.1  christos 
    118  1.1  christos /* Return the set of signals used by the threads library.  */
    119  1.1  christos extern void lin_thread_get_thread_signals (sigset_t *mask);
    120  1.1  christos 
    121  1.1  christos /* Find process PID's pending signal set from /proc/pid/status.  */
    122  1.1  christos void linux_proc_pending_signals (int pid, sigset_t *pending,
    123  1.1  christos 				 sigset_t *blocked, sigset_t *ignored);
    124  1.1  christos 
    125  1.1  christos extern int lin_lwp_attach_lwp (ptid_t ptid);
    126  1.1  christos 
    127  1.1  christos extern void linux_stop_lwp (struct lwp_info *lwp);
    128  1.1  christos 
    129  1.1  christos /* Iterator function for lin-lwp's lwp list.  */
    130  1.1  christos struct lwp_info *iterate_over_lwps (ptid_t filter,
    131  1.1  christos 				    int (*callback) (struct lwp_info *,
    132  1.1  christos 						     void *),
    133  1.1  christos 				    void *data);
    134  1.1  christos 
    135  1.1  christos /* Create a prototype generic GNU/Linux target.  The client can
    136  1.1  christos    override it with local methods.  */
    137  1.1  christos struct target_ops * linux_target (void);
    138  1.1  christos 
    139  1.1  christos /* Create a generic GNU/Linux target using traditional
    140  1.1  christos    ptrace register access.  */
    141  1.1  christos struct target_ops *
    142  1.1  christos linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
    143  1.1  christos 
    144  1.1  christos /* Register the customized GNU/Linux target.  This should be used
    145  1.1  christos    instead of calling add_target directly.  */
    146  1.1  christos void linux_nat_add_target (struct target_ops *);
    147  1.1  christos 
    148  1.1  christos /* Register a method to call whenever a new thread is attached.  */
    149  1.1  christos void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *));
    150  1.1  christos 
    151  1.1  christos 
    152  1.1  christos /* Register a method to call whenever a new fork is attached.  */
    153  1.1  christos typedef void (linux_nat_new_fork_ftype) (struct lwp_info *parent,
    154  1.1  christos 					 pid_t child_pid);
    155  1.1  christos void linux_nat_set_new_fork (struct target_ops *ops,
    156  1.1  christos 			     linux_nat_new_fork_ftype *fn);
    157  1.1  christos 
    158  1.1  christos /* Register a method to call whenever a process is killed or
    159  1.1  christos    detached.  */
    160  1.1  christos typedef void (linux_nat_forget_process_ftype) (pid_t pid);
    161  1.1  christos void linux_nat_set_forget_process (struct target_ops *ops,
    162  1.1  christos 				   linux_nat_forget_process_ftype *fn);
    163  1.1  christos 
    164  1.1  christos /* Call the method registered with the function above.  PID is the
    165  1.1  christos    process to forget about.  */
    166  1.1  christos void linux_nat_forget_process (pid_t pid);
    167  1.1  christos 
    168  1.1  christos /* Register a method that converts a siginfo object between the layout
    169  1.1  christos    that ptrace returns, and the layout in the architecture of the
    170  1.1  christos    inferior.  */
    171  1.1  christos void linux_nat_set_siginfo_fixup (struct target_ops *,
    172  1.1  christos 				  int (*) (siginfo_t *,
    173  1.1  christos 					   gdb_byte *,
    174  1.1  christos 					   int));
    175  1.1  christos 
    176  1.1  christos /* Register a method to call prior to resuming a thread.  */
    177  1.1  christos 
    178  1.1  christos void linux_nat_set_prepare_to_resume (struct target_ops *,
    179  1.1  christos 				      void (*) (struct lwp_info *));
    180  1.1  christos 
    181  1.1  christos /* Update linux-nat internal state when changing from one fork
    182  1.1  christos    to another.  */
    183  1.1  christos void linux_nat_switch_fork (ptid_t new_ptid);
    184  1.1  christos 
    185  1.1  christos /* Store the saved siginfo associated with PTID in *SIGINFO.
    186  1.1  christos    Return 1 if it was retrieved successfully, 0 otherwise (*SIGINFO is
    187  1.1  christos    uninitialized in such case).  */
    188  1.1  christos int linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
    189  1.1  christos 
    190  1.1  christos /* Set alternative SIGTRAP-like events recognizer.  */
    191  1.1  christos void linux_nat_set_status_is_event (struct target_ops *t,
    192  1.1  christos 				    int (*status_is_event) (int status));
    193