• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1======
2Ptrace
3======
4
5GDB intends to support the following hardware debug features of BookE
6processors:
7
84 hardware breakpoints (IAC)
92 hardware watchpoints (read, write and read-write) (DAC)
102 value conditions for the hardware watchpoints (DVC)
11
12For that, we need to extend ptrace so that GDB can query and set these
13resources. Since we're extending, we're trying to create an interface
14that's extendable and that covers both BookE and server processors, so
15that GDB doesn't need to special-case each of them. We added the
16following 3 new ptrace requests.
17
181. PTRACE_PPC_GETHWDEBUGINFO
19============================
20
21Query for GDB to discover the hardware debug features. The main info to
22be returned here is the minimum alignment for the hardware watchpoints.
23BookE processors don't have restrictions here, but server processors have
24an 8-byte alignment restriction for hardware watchpoints. We'd like to avoid
25adding special cases to GDB based on what it sees in AUXV.
26
27Since we're at it, we added other useful info that the kernel can return to
28GDB: this query will return the number of hardware breakpoints, hardware
29watchpoints and whether it supports a range of addresses and a condition.
30The query will fill the following structure provided by the requesting process::
31
32  struct ppc_debug_info {
33       unit32_t version;
34       unit32_t num_instruction_bps;
35       unit32_t num_data_bps;
36       unit32_t num_condition_regs;
37       unit32_t data_bp_alignment;
38       unit32_t sizeof_condition; /* size of the DVC register */
39       uint64_t features; /* bitmask of the individual flags */
40  };
41
42features will have bits indicating whether there is support for::
43
44  #define PPC_DEBUG_FEATURE_INSN_BP_RANGE		0x1
45  #define PPC_DEBUG_FEATURE_INSN_BP_MASK		0x2
46  #define PPC_DEBUG_FEATURE_DATA_BP_RANGE		0x4
47  #define PPC_DEBUG_FEATURE_DATA_BP_MASK		0x8
48  #define PPC_DEBUG_FEATURE_DATA_BP_DAWR		0x10
49
502. PTRACE_SETHWDEBUG
51
52Sets a hardware breakpoint or watchpoint, according to the provided structure::
53
54  struct ppc_hw_breakpoint {
55        uint32_t version;
56  #define PPC_BREAKPOINT_TRIGGER_EXECUTE  0x1
57  #define PPC_BREAKPOINT_TRIGGER_READ     0x2
58 #define PPC_BREAKPOINT_TRIGGER_WRITE    0x4
59        uint32_t trigger_type;       /* only some combinations allowed */
60  #define PPC_BREAKPOINT_MODE_EXACT               0x0
61  #define PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE     0x1
62  #define PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE     0x2
63  #define PPC_BREAKPOINT_MODE_MASK                0x3
64        uint32_t addr_mode;          /* address match mode */
65
66  #define PPC_BREAKPOINT_CONDITION_MODE   0x3
67  #define PPC_BREAKPOINT_CONDITION_NONE   0x0
68  #define PPC_BREAKPOINT_CONDITION_AND    0x1
69  #define PPC_BREAKPOINT_CONDITION_EXACT  0x1	/* different name for the same thing as above */
70  #define PPC_BREAKPOINT_CONDITION_OR     0x2
71  #define PPC_BREAKPOINT_CONDITION_AND_OR 0x3
72  #define PPC_BREAKPOINT_CONDITION_BE_ALL 0x00ff0000	/* byte enable bits */
73  #define PPC_BREAKPOINT_CONDITION_BE(n)  (1<<((n)+16))
74        uint32_t condition_mode;     /* break/watchpoint condition flags */
75
76        uint64_t addr;
77        uint64_t addr2;
78        uint64_t condition_value;
79  };
80
81A request specifies one event, not necessarily just one register to be set.
82For instance, if the request is for a watchpoint with a condition, both the
83DAC and DVC registers will be set in the same request.
84
85With this GDB can ask for all kinds of hardware breakpoints and watchpoints
86that the BookE supports. COMEFROM breakpoints available in server processors
87are not contemplated, but that is out of the scope of this work.
88
89ptrace will return an integer (handle) uniquely identifying the breakpoint or
90watchpoint just created. This integer will be used in the PTRACE_DELHWDEBUG
91request to ask for its removal. Return -ENOSPC if the requested breakpoint
92can't be allocated on the registers.
93
94Some examples of using the structure to:
95
96- set a breakpoint in the first breakpoint register::
97
98    p.version         = PPC_DEBUG_CURRENT_VERSION;
99    p.trigger_type    = PPC_BREAKPOINT_TRIGGER_EXECUTE;
100    p.addr_mode       = PPC_BREAKPOINT_MODE_EXACT;
101    p.condition_mode  = PPC_BREAKPOINT_CONDITION_NONE;
102    p.addr            = (uint64_t) address;
103    p.addr2           = 0;
104    p.condition_value = 0;
105
106- set a watchpoint which triggers on reads in the second watchpoint register::
107
108    p.version         = PPC_DEBUG_CURRENT_VERSION;
109    p.trigger_type    = PPC_BREAKPOINT_TRIGGER_READ;
110    p.addr_mode       = PPC_BREAKPOINT_MODE_EXACT;
111    p.condition_mode  = PPC_BREAKPOINT_CONDITION_NONE;
112    p.addr            = (uint64_t) address;
113    p.addr2           = 0;
114    p.condition_value = 0;
115
116- set a watchpoint which triggers only with a specific value::
117
118    p.version         = PPC_DEBUG_CURRENT_VERSION;
119    p.trigger_type    = PPC_BREAKPOINT_TRIGGER_READ;
120    p.addr_mode       = PPC_BREAKPOINT_MODE_EXACT;
121    p.condition_mode  = PPC_BREAKPOINT_CONDITION_AND | PPC_BREAKPOINT_CONDITION_BE_ALL;
122    p.addr            = (uint64_t) address;
123    p.addr2           = 0;
124    p.condition_value = (uint64_t) condition;
125
126- set a ranged hardware breakpoint::
127
128    p.version         = PPC_DEBUG_CURRENT_VERSION;
129    p.trigger_type    = PPC_BREAKPOINT_TRIGGER_EXECUTE;
130    p.addr_mode       = PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE;
131    p.condition_mode  = PPC_BREAKPOINT_CONDITION_NONE;
132    p.addr            = (uint64_t) begin_range;
133    p.addr2           = (uint64_t) end_range;
134    p.condition_value = 0;
135
136- set a watchpoint in server processors (BookS)::
137
138    p.version         = 1;
139    p.trigger_type    = PPC_BREAKPOINT_TRIGGER_RW;
140    p.addr_mode       = PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE;
141    or
142    p.addr_mode       = PPC_BREAKPOINT_MODE_EXACT;
143
144    p.condition_mode  = PPC_BREAKPOINT_CONDITION_NONE;
145    p.addr            = (uint64_t) begin_range;
146    /* For PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE addr2 needs to be specified, where
147     * addr2 - addr <= 8 Bytes.
148     */
149    p.addr2           = (uint64_t) end_range;
150    p.condition_value = 0;
151
1523. PTRACE_DELHWDEBUG
153
154Takes an integer which identifies an existing breakpoint or watchpoint
155(i.e., the value returned from PTRACE_SETHWDEBUG), and deletes the
156corresponding breakpoint or watchpoint..
157