GDB (API)
/home/stan/gdb/src/gdb/i386-nat.h
Go to the documentation of this file.
00001 /* Native-dependent code for the i386.
00002 
00003    Low level functions to implement Oeprating System specific
00004    code to manipulate I386 debug registers.
00005 
00006    Copyright (C) 2009-2013 Free Software Foundation, Inc.
00007 
00008    This file is part of GDB.
00009 
00010    This program is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 3 of the License, or
00013    (at your option) any later version.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00022 
00023 #ifndef I386_NAT_H
00024 #define I386_NAT_H 1
00025 
00026 /* Hardware-assisted breakpoints and watchpoints.  */
00027 
00028 /* Add watchpoint methods to the provided target_ops.  
00029    Targets using i386 family debug registers for watchpoints should call
00030    this.  */
00031 struct target_ops;
00032 extern void i386_use_watchpoints (struct target_ops *);
00033 
00034 /* Support for hardware watchpoints and breakpoints using the i386
00035    debug registers.
00036 
00037    This provides several functions for inserting and removing
00038    hardware-assisted breakpoints and watchpoints, testing if one or
00039    more of the watchpoints triggered and at what address, checking
00040    whether a given region can be watched, etc.
00041 
00042    In addition, each target should provide several low-level functions
00043    regrouped into i386_dr_low_type struct below.  These functions
00044    that will be called to insert watchpoints and hardware breakpoints
00045    into the inferior, remove them, and check their status.  These
00046    functions are:
00047 
00048       set_control              -- set the debug control (DR7)
00049                                   register to a given value for all LWPs
00050 
00051       set_addr                 -- put an address into one debug
00052                                   register for all LWPs
00053 
00054       get_addr                 -- return the address in a given debug
00055                                   register of the current LWP
00056 
00057       get_status               -- return the value of the debug
00058                                   status (DR6) register for current LWP
00059 
00060       get_control               -- return the value of the debug
00061                                   control (DR7) register for current LWP
00062 
00063    Additionally, the native file should set the debug_register_length
00064    field to 4 or 8 depending on the number of bytes used for
00065    deubg registers.  */
00066 
00067 struct i386_dr_low_type
00068   {
00069     void (*set_control) (unsigned long);
00070     void (*set_addr) (int, CORE_ADDR);
00071     CORE_ADDR (*get_addr) (int);
00072     unsigned long (*get_status) (void);
00073     unsigned long (*get_control) (void);
00074     int debug_register_length;
00075   };
00076 
00077 extern struct i386_dr_low_type i386_dr_low;
00078 
00079 /* Debug registers' indices.  */
00080 #define DR_FIRSTADDR 0
00081 #define DR_LASTADDR  3
00082 #define DR_NADDR     4  /* The number of debug address registers.  */
00083 #define DR_STATUS    6  /* Index of debug status register (DR6).  */
00084 #define DR_CONTROL   7  /* Index of debug control register (DR7).  */
00085 
00086 /* Global state needed to track h/w watchpoints.  */
00087 
00088 struct i386_debug_reg_state
00089 {
00090   /* Mirror the inferior's DRi registers.  We keep the status and
00091      control registers separated because they don't hold addresses.
00092      Note that since we can change these mirrors while threads are
00093      running, we never trust them to explain a cause of a trap.
00094      For that, we need to peek directly in the inferior registers.  */
00095   CORE_ADDR dr_mirror[DR_NADDR];
00096   unsigned dr_status_mirror, dr_control_mirror;
00097 
00098   /* Reference counts for each debug register.  */
00099   int dr_ref_count[DR_NADDR];
00100 };
00101 
00102 /* Use this function to set i386_dr_low debug_register_length field
00103    rather than setting it directly to check that the length is only
00104    set once.  It also enables the 'maint set/show show-debug-regs' 
00105    command.  */
00106 
00107 extern void i386_set_debug_register_length (int len);
00108 
00109 /* Use this function to reset the i386-nat.c debug register state.  */
00110 
00111 extern void i386_cleanup_dregs (void);
00112 
00113 /* Return a pointer to the local mirror of the debug registers of
00114    process PID.  */
00115 
00116 extern struct i386_debug_reg_state *i386_debug_reg_state (pid_t pid);
00117 
00118 /* Called whenever GDB is no longer debugging process PID.  It deletes
00119    data structures that keep track of debug register state.  */
00120 
00121 extern void i386_forget_process (pid_t pid);
00122 
00123 #endif /* I386_NAT_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines