Home | History | Annotate | Line # | Download | only in gdb
linux-nat.h revision 1.1.1.2
      1      1.1  christos /* Native debugging support for GNU/Linux (LWP layer).
      2      1.1  christos 
      3  1.1.1.2  christos    Copyright (C) 2000-2015 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.1.2  christos /* Reasons an LWP last stopped.  */
     27  1.1.1.2  christos 
     28  1.1.1.2  christos enum lwp_stop_reason
     29  1.1.1.2  christos {
     30  1.1.1.2  christos   /* Either not stopped, or stopped for a reason that doesn't require
     31  1.1.1.2  christos      special tracking.  */
     32  1.1.1.2  christos   LWP_STOPPED_BY_NO_REASON,
     33  1.1.1.2  christos 
     34  1.1.1.2  christos   /* Stopped by a software breakpoint.  */
     35  1.1.1.2  christos   LWP_STOPPED_BY_SW_BREAKPOINT,
     36  1.1.1.2  christos 
     37  1.1.1.2  christos   /* Stopped by a hardware breakpoint.  */
     38  1.1.1.2  christos   LWP_STOPPED_BY_HW_BREAKPOINT,
     39  1.1.1.2  christos 
     40  1.1.1.2  christos   /* Stopped by a watchpoint.  */
     41  1.1.1.2  christos   LWP_STOPPED_BY_WATCHPOINT
     42  1.1.1.2  christos };
     43  1.1.1.2  christos 
     44      1.1  christos /* Structure describing an LWP.  This is public only for the purposes
     45      1.1  christos    of ALL_LWPS; target-specific code should generally not access it
     46      1.1  christos    directly.  */
     47      1.1  christos 
     48      1.1  christos struct lwp_info
     49      1.1  christos {
     50      1.1  christos   /* The process id of the LWP.  This is a combination of the LWP id
     51      1.1  christos      and overall process id.  */
     52      1.1  christos   ptid_t ptid;
     53      1.1  christos 
     54  1.1.1.2  christos   /* If this flag is set, we need to set the event request flags the
     55  1.1.1.2  christos      next time we see this LWP stop.  */
     56  1.1.1.2  christos   int must_set_ptrace_flags;
     57  1.1.1.2  christos 
     58      1.1  christos   /* Non-zero if this LWP is cloned.  In this context "cloned" means
     59      1.1  christos      that the LWP is reporting to its parent using a signal other than
     60      1.1  christos      SIGCHLD.  */
     61      1.1  christos   int cloned;
     62      1.1  christos 
     63      1.1  christos   /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
     64      1.1  christos      it back yet).  */
     65      1.1  christos   int signalled;
     66      1.1  christos 
     67      1.1  christos   /* Non-zero if this LWP is stopped.  */
     68      1.1  christos   int stopped;
     69      1.1  christos 
     70      1.1  christos   /* Non-zero if this LWP will be/has been resumed.  Note that an LWP
     71      1.1  christos      can be marked both as stopped and resumed at the same time.  This
     72      1.1  christos      happens if we try to resume an LWP that has a wait status
     73      1.1  christos      pending.  We shouldn't let the LWP run until that wait status has
     74      1.1  christos      been processed, but we should not report that wait status if GDB
     75      1.1  christos      didn't try to let the LWP run.  */
     76      1.1  christos   int resumed;
     77      1.1  christos 
     78      1.1  christos   /* The last resume GDB requested on this thread.  */
     79      1.1  christos   enum resume_kind last_resume_kind;
     80      1.1  christos 
     81      1.1  christos   /* If non-zero, a pending wait status.  */
     82      1.1  christos   int status;
     83      1.1  christos 
     84  1.1.1.2  christos   /* When 'stopped' is set, this is where the lwp last stopped, with
     85  1.1.1.2  christos      decr_pc_after_break already accounted for.  If the LWP is
     86  1.1.1.2  christos      running, and stepping, this is the address at which the lwp was
     87  1.1.1.2  christos      resumed (that is, it's the previous stop PC).  If the LWP is
     88  1.1.1.2  christos      running and not stepping, this is 0.  */
     89  1.1.1.2  christos   CORE_ADDR stop_pc;
     90  1.1.1.2  christos 
     91      1.1  christos   /* Non-zero if we were stepping this LWP.  */
     92      1.1  christos   int step;
     93      1.1  christos 
     94  1.1.1.2  christos   /* The reason the LWP last stopped, if we need to track it
     95  1.1.1.2  christos      (breakpoint, watchpoint, etc.)  */
     96  1.1.1.2  christos   enum lwp_stop_reason stop_reason;
     97      1.1  christos 
     98      1.1  christos   /* On architectures where it is possible to know the data address of
     99      1.1  christos      a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and
    100      1.1  christos      STOPPED_DATA_ADDRESS contains such data address.  Otherwise,
    101      1.1  christos      STOPPED_DATA_ADDRESS_P is false, and STOPPED_DATA_ADDRESS is
    102      1.1  christos      undefined.  Only valid if STOPPED_BY_WATCHPOINT is true.  */
    103      1.1  christos   int stopped_data_address_p;
    104      1.1  christos   CORE_ADDR stopped_data_address;
    105      1.1  christos 
    106      1.1  christos   /* Non-zero if we expect a duplicated SIGINT.  */
    107      1.1  christos   int ignore_sigint;
    108      1.1  christos 
    109      1.1  christos   /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
    110      1.1  christos      for this LWP's last event.  This may correspond to STATUS above,
    111      1.1  christos      or to a local variable in lin_lwp_wait.  */
    112      1.1  christos   struct target_waitstatus waitstatus;
    113      1.1  christos 
    114      1.1  christos   /* Signal wether we are in a SYSCALL_ENTRY or
    115      1.1  christos      in a SYSCALL_RETURN event.
    116      1.1  christos      Values:
    117      1.1  christos      - TARGET_WAITKIND_SYSCALL_ENTRY
    118      1.1  christos      - TARGET_WAITKIND_SYSCALL_RETURN */
    119      1.1  christos   int syscall_state;
    120      1.1  christos 
    121      1.1  christos   /* The processor core this LWP was last seen on.  */
    122      1.1  christos   int core;
    123      1.1  christos 
    124      1.1  christos   /* Arch-specific additions.  */
    125      1.1  christos   struct arch_lwp_info *arch_private;
    126      1.1  christos 
    127      1.1  christos   /* Next LWP in list.  */
    128      1.1  christos   struct lwp_info *next;
    129      1.1  christos };
    130      1.1  christos 
    131      1.1  christos /* The global list of LWPs, for ALL_LWPS.  Unlike the threads list,
    132      1.1  christos    there is always at least one LWP on the list while the GNU/Linux
    133      1.1  christos    native target is active.  */
    134      1.1  christos extern struct lwp_info *lwp_list;
    135      1.1  christos 
    136      1.1  christos /* Iterate over each active thread (light-weight process).  */
    137      1.1  christos #define ALL_LWPS(LP)							\
    138      1.1  christos   for ((LP) = lwp_list;							\
    139      1.1  christos        (LP) != NULL;							\
    140      1.1  christos        (LP) = (LP)->next)
    141      1.1  christos 
    142      1.1  christos /* Attempt to initialize libthread_db.  */
    143      1.1  christos void check_for_thread_db (void);
    144      1.1  christos 
    145      1.1  christos int thread_db_attach_lwp (ptid_t ptid);
    146      1.1  christos 
    147      1.1  christos /* Return the set of signals used by the threads library.  */
    148      1.1  christos extern void lin_thread_get_thread_signals (sigset_t *mask);
    149      1.1  christos 
    150      1.1  christos /* Find process PID's pending signal set from /proc/pid/status.  */
    151      1.1  christos void linux_proc_pending_signals (int pid, sigset_t *pending,
    152      1.1  christos 				 sigset_t *blocked, sigset_t *ignored);
    153      1.1  christos 
    154      1.1  christos extern int lin_lwp_attach_lwp (ptid_t ptid);
    155      1.1  christos 
    156      1.1  christos extern void linux_stop_lwp (struct lwp_info *lwp);
    157      1.1  christos 
    158      1.1  christos /* Iterator function for lin-lwp's lwp list.  */
    159      1.1  christos struct lwp_info *iterate_over_lwps (ptid_t filter,
    160      1.1  christos 				    int (*callback) (struct lwp_info *,
    161      1.1  christos 						     void *),
    162      1.1  christos 				    void *data);
    163      1.1  christos 
    164      1.1  christos /* Create a prototype generic GNU/Linux target.  The client can
    165      1.1  christos    override it with local methods.  */
    166      1.1  christos struct target_ops * linux_target (void);
    167      1.1  christos 
    168      1.1  christos /* Create a generic GNU/Linux target using traditional
    169      1.1  christos    ptrace register access.  */
    170      1.1  christos struct target_ops *
    171      1.1  christos linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
    172      1.1  christos 
    173      1.1  christos /* Register the customized GNU/Linux target.  This should be used
    174      1.1  christos    instead of calling add_target directly.  */
    175      1.1  christos void linux_nat_add_target (struct target_ops *);
    176      1.1  christos 
    177      1.1  christos /* Register a method to call whenever a new thread is attached.  */
    178      1.1  christos void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *));
    179      1.1  christos 
    180      1.1  christos 
    181      1.1  christos /* Register a method to call whenever a new fork is attached.  */
    182      1.1  christos typedef void (linux_nat_new_fork_ftype) (struct lwp_info *parent,
    183      1.1  christos 					 pid_t child_pid);
    184      1.1  christos void linux_nat_set_new_fork (struct target_ops *ops,
    185      1.1  christos 			     linux_nat_new_fork_ftype *fn);
    186      1.1  christos 
    187      1.1  christos /* Register a method to call whenever a process is killed or
    188      1.1  christos    detached.  */
    189      1.1  christos typedef void (linux_nat_forget_process_ftype) (pid_t pid);
    190      1.1  christos void linux_nat_set_forget_process (struct target_ops *ops,
    191      1.1  christos 				   linux_nat_forget_process_ftype *fn);
    192      1.1  christos 
    193      1.1  christos /* Call the method registered with the function above.  PID is the
    194      1.1  christos    process to forget about.  */
    195      1.1  christos void linux_nat_forget_process (pid_t pid);
    196      1.1  christos 
    197      1.1  christos /* Register a method that converts a siginfo object between the layout
    198      1.1  christos    that ptrace returns, and the layout in the architecture of the
    199      1.1  christos    inferior.  */
    200      1.1  christos void linux_nat_set_siginfo_fixup (struct target_ops *,
    201      1.1  christos 				  int (*) (siginfo_t *,
    202      1.1  christos 					   gdb_byte *,
    203      1.1  christos 					   int));
    204      1.1  christos 
    205      1.1  christos /* Register a method to call prior to resuming a thread.  */
    206      1.1  christos 
    207      1.1  christos void linux_nat_set_prepare_to_resume (struct target_ops *,
    208      1.1  christos 				      void (*) (struct lwp_info *));
    209      1.1  christos 
    210      1.1  christos /* Update linux-nat internal state when changing from one fork
    211      1.1  christos    to another.  */
    212      1.1  christos void linux_nat_switch_fork (ptid_t new_ptid);
    213      1.1  christos 
    214      1.1  christos /* Store the saved siginfo associated with PTID in *SIGINFO.
    215      1.1  christos    Return 1 if it was retrieved successfully, 0 otherwise (*SIGINFO is
    216      1.1  christos    uninitialized in such case).  */
    217      1.1  christos int linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo);
    218      1.1  christos 
    219      1.1  christos /* Set alternative SIGTRAP-like events recognizer.  */
    220      1.1  christos void linux_nat_set_status_is_event (struct target_ops *t,
    221      1.1  christos 				    int (*status_is_event) (int status));
    222