Commit | Line | Data |
---|---|---|
aaee2056 YQ |
1 | /* Copyright (C) 2009-2013 Free Software Foundation, Inc. |
2 | ||
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #ifndef MIPS_LINUX_WATCH_H | |
19 | #define MIPS_LINUX_WATCH_H 1 | |
20 | ||
21 | #ifdef GDBSERVER | |
22 | #include "server.h" | |
23 | #else | |
24 | #include "defs.h" | |
25 | #endif | |
26 | ||
27 | #include <asm/ptrace.h> | |
28 | #include <stdint.h> | |
29 | ||
30 | #include "break-common.h" | |
31 | ||
32 | #define MAX_DEBUG_REGISTER 8 | |
33 | ||
34 | /* If macro PTRACE_GET_WATCH_REGS is not defined, kernel header doesn't | |
35 | have hardware watchpoint-related structures. Define them below. */ | |
36 | ||
37 | #ifndef PTRACE_GET_WATCH_REGS | |
38 | # define PTRACE_GET_WATCH_REGS 0xd0 | |
39 | # define PTRACE_SET_WATCH_REGS 0xd1 | |
40 | ||
41 | enum pt_watch_style { | |
42 | pt_watch_style_mips32, | |
43 | pt_watch_style_mips64 | |
44 | }; | |
45 | ||
46 | /* A value of zero in a watchlo indicates that it is available. */ | |
47 | ||
48 | struct mips32_watch_regs | |
49 | { | |
50 | uint32_t watchlo[MAX_DEBUG_REGISTER]; | |
51 | /* Lower 16 bits of watchhi. */ | |
52 | uint16_t watchhi[MAX_DEBUG_REGISTER]; | |
53 | /* Valid mask and I R W bits. | |
54 | * bit 0 -- 1 if W bit is usable. | |
55 | * bit 1 -- 1 if R bit is usable. | |
56 | * bit 2 -- 1 if I bit is usable. | |
57 | * bits 3 - 11 -- Valid watchhi mask bits. | |
58 | */ | |
59 | uint16_t watch_masks[MAX_DEBUG_REGISTER]; | |
60 | /* The number of valid watch register pairs. */ | |
61 | uint32_t num_valid; | |
62 | /* There is confusion across gcc versions about structure alignment, | |
63 | so we force 8 byte alignment for these structures so they match | |
64 | the kernel even if it was build with a different gcc version. */ | |
65 | } __attribute__ ((aligned (8))); | |
66 | ||
67 | struct mips64_watch_regs | |
68 | { | |
69 | uint64_t watchlo[MAX_DEBUG_REGISTER]; | |
70 | uint16_t watchhi[MAX_DEBUG_REGISTER]; | |
71 | uint16_t watch_masks[MAX_DEBUG_REGISTER]; | |
72 | uint32_t num_valid; | |
73 | } __attribute__ ((aligned (8))); | |
74 | ||
75 | struct pt_watch_regs | |
76 | { | |
77 | enum pt_watch_style style; | |
78 | union | |
79 | { | |
80 | struct mips32_watch_regs mips32; | |
81 | struct mips64_watch_regs mips64; | |
82 | }; | |
83 | }; | |
84 | ||
85 | #endif /* !PTRACE_GET_WATCH_REGS */ | |
86 | ||
87 | #define W_BIT 0 | |
88 | #define R_BIT 1 | |
89 | #define I_BIT 2 | |
90 | ||
91 | #define W_MASK (1 << W_BIT) | |
92 | #define R_MASK (1 << R_BIT) | |
93 | #define I_MASK (1 << I_BIT) | |
94 | ||
95 | #define IRW_MASK (I_MASK | R_MASK | W_MASK) | |
96 | ||
97 | /* We keep list of all watchpoints we should install and calculate the | |
98 | watch register values each time the list changes. This allows for | |
99 | easy sharing of watch registers for more than one watchpoint. */ | |
100 | ||
101 | struct mips_watchpoint | |
102 | { | |
103 | CORE_ADDR addr; | |
104 | int len; | |
105 | int type; | |
106 | struct mips_watchpoint *next; | |
107 | }; | |
108 | ||
109 | uint32_t mips_linux_watch_get_num_valid (struct pt_watch_regs *regs); | |
110 | uint32_t mips_linux_watch_get_irw_mask (struct pt_watch_regs *regs, int n); | |
111 | CORE_ADDR mips_linux_watch_get_watchlo (struct pt_watch_regs *regs, int n); | |
112 | void mips_linux_watch_set_watchlo (struct pt_watch_regs *regs, int n, | |
113 | CORE_ADDR value); | |
114 | uint32_t mips_linux_watch_get_watchhi (struct pt_watch_regs *regs, int n); | |
115 | void mips_linux_watch_set_watchhi (struct pt_watch_regs *regs, int n, | |
116 | uint16_t value); | |
117 | int mips_linux_watch_try_one_watch (struct pt_watch_regs *regs, | |
118 | CORE_ADDR addr, int len, uint32_t irw); | |
119 | void mips_linux_watch_populate_regs (struct mips_watchpoint *current_watches, | |
120 | struct pt_watch_regs *regs); | |
121 | uint32_t mips_linux_watch_type_to_irw (int type); | |
122 | ||
123 | int mips_linux_read_watch_registers (long lwpid, | |
124 | struct pt_watch_regs *watch_readback, | |
125 | int *watch_readback_valid, int force); | |
126 | #endif |