GDB (API)
|
00001 /* Copyright (C) 2009-2013 Free Software Foundation, Inc. 00002 00003 This file is part of GDB. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00017 00018 #ifndef MIPS_LINUX_WATCH_H 00019 #define MIPS_LINUX_WATCH_H 1 00020 00021 #ifdef GDBSERVER 00022 #include "server.h" 00023 #else 00024 #include "defs.h" 00025 #endif 00026 00027 #include <asm/ptrace.h> 00028 #include <stdint.h> 00029 00030 #include "break-common.h" 00031 00032 #define MAX_DEBUG_REGISTER 8 00033 00034 /* If macro PTRACE_GET_WATCH_REGS is not defined, kernel header doesn't 00035 have hardware watchpoint-related structures. Define them below. */ 00036 00037 #ifndef PTRACE_GET_WATCH_REGS 00038 # define PTRACE_GET_WATCH_REGS 0xd0 00039 # define PTRACE_SET_WATCH_REGS 0xd1 00040 00041 enum pt_watch_style { 00042 pt_watch_style_mips32, 00043 pt_watch_style_mips64 00044 }; 00045 00046 /* A value of zero in a watchlo indicates that it is available. */ 00047 00048 struct mips32_watch_regs 00049 { 00050 uint32_t watchlo[MAX_DEBUG_REGISTER]; 00051 /* Lower 16 bits of watchhi. */ 00052 uint16_t watchhi[MAX_DEBUG_REGISTER]; 00053 /* Valid mask and I R W bits. 00054 * bit 0 -- 1 if W bit is usable. 00055 * bit 1 -- 1 if R bit is usable. 00056 * bit 2 -- 1 if I bit is usable. 00057 * bits 3 - 11 -- Valid watchhi mask bits. 00058 */ 00059 uint16_t watch_masks[MAX_DEBUG_REGISTER]; 00060 /* The number of valid watch register pairs. */ 00061 uint32_t num_valid; 00062 /* There is confusion across gcc versions about structure alignment, 00063 so we force 8 byte alignment for these structures so they match 00064 the kernel even if it was build with a different gcc version. */ 00065 } __attribute__ ((aligned (8))); 00066 00067 struct mips64_watch_regs 00068 { 00069 uint64_t watchlo[MAX_DEBUG_REGISTER]; 00070 uint16_t watchhi[MAX_DEBUG_REGISTER]; 00071 uint16_t watch_masks[MAX_DEBUG_REGISTER]; 00072 uint32_t num_valid; 00073 } __attribute__ ((aligned (8))); 00074 00075 struct pt_watch_regs 00076 { 00077 enum pt_watch_style style; 00078 union 00079 { 00080 struct mips32_watch_regs mips32; 00081 struct mips64_watch_regs mips64; 00082 }; 00083 }; 00084 00085 #endif /* !PTRACE_GET_WATCH_REGS */ 00086 00087 #define W_BIT 0 00088 #define R_BIT 1 00089 #define I_BIT 2 00090 00091 #define W_MASK (1 << W_BIT) 00092 #define R_MASK (1 << R_BIT) 00093 #define I_MASK (1 << I_BIT) 00094 00095 #define IRW_MASK (I_MASK | R_MASK | W_MASK) 00096 00097 /* We keep list of all watchpoints we should install and calculate the 00098 watch register values each time the list changes. This allows for 00099 easy sharing of watch registers for more than one watchpoint. */ 00100 00101 struct mips_watchpoint 00102 { 00103 CORE_ADDR addr; 00104 int len; 00105 int type; 00106 struct mips_watchpoint *next; 00107 }; 00108 00109 uint32_t mips_linux_watch_get_num_valid (struct pt_watch_regs *regs); 00110 uint32_t mips_linux_watch_get_irw_mask (struct pt_watch_regs *regs, int n); 00111 CORE_ADDR mips_linux_watch_get_watchlo (struct pt_watch_regs *regs, int n); 00112 void mips_linux_watch_set_watchlo (struct pt_watch_regs *regs, int n, 00113 CORE_ADDR value); 00114 uint32_t mips_linux_watch_get_watchhi (struct pt_watch_regs *regs, int n); 00115 void mips_linux_watch_set_watchhi (struct pt_watch_regs *regs, int n, 00116 uint16_t value); 00117 int mips_linux_watch_try_one_watch (struct pt_watch_regs *regs, 00118 CORE_ADDR addr, int len, uint32_t irw); 00119 void mips_linux_watch_populate_regs (struct mips_watchpoint *current_watches, 00120 struct pt_watch_regs *regs); 00121 uint32_t mips_linux_watch_type_to_irw (int type); 00122 00123 int mips_linux_read_watch_registers (long lwpid, 00124 struct pt_watch_regs *watch_readback, 00125 int *watch_readback_valid, int force); 00126 #endif