]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/watchpoint.c
4 * Since using watchpoints can be very slow, we have to take some pains to
5 * ensure that we don't run too long with them enabled or we run the risk
6 * of having the test timeout. To help avoid this, we insert some marker
7 * functions in the execution stream so we can set breakpoints at known
8 * locations, without worrying about invalidating line numbers by changing
9 * this file. We use null bodied functions are markers since gdb does
10 * not support breakpoints at labeled text points at this time.
12 * One place we need is a marker for when we start executing our tests
13 * instructions rather than any process startup code, so we insert one
14 * right after entering main(). Another is right before we finish, before
15 * we start executing any process termination code.
17 * Another problem we have to guard against, at least for the test
18 * suite, is that we need to ensure that the line that causes the
19 * watchpoint to be hit is still the current line when gdb notices
20 * the hit. Depending upon the specific code generated by the compiler,
21 * the instruction after the one that triggers the hit may be part of
22 * the same line or part of the next line. Thus we ensure that there
23 * are always some instructions to execute on the same line after the
24 * code that should trigger the hit.
33 char buf
[31] = "testtesttesttesttesttesttestte";
38 struct foo struct1
, struct2
, *ptr1
, *ptr2
;
43 char **global_ptr_ptr
;
62 struct foo5
*null_ptr
;
99 /* func2 breakpoint here */
112 x
= 1; /* second x assignment */
121 /* The point of this is that we will set a breakpoint at this call.
123 Then, if DECR_PC_AFTER_BREAK equals the size of a function call
124 instruction (true on a sun3 if this is gcc-compiled--FIXME we
125 should use asm() to make it work for any compiler, present or
126 future), then we will end up branching to the location just after
127 the breakpoint. And we better not confuse that with hitting the
140 global_ptr_ptr
= &global_ptr
;
148 int val
= 0, val2
= 23;
151 /* func5 breakpoint here */
159 /* func6 breakpoint here */
167 /* func7 breakpoint here */
180 for (count
= 0; count
< 4; count
++) {
182 ival3
= count
; ival4
= count
;
184 ival1
= count
; /* Outside loop */
186 ival3
= count
; ival4
= count
;
190 static char msg
[] = "type stuff for buf now:";
191 write (1, msg
, sizeof (msg
) - 1);
192 read (0, &buf
[0], 5);
196 /* We have a watchpoint on ptr1->val. It should be triggered if
197 ptr1's value changes. */
200 /* This should not trigger the watchpoint. If it does, then we
201 used the wrong value chain to re-insert the watchpoints or we
202 are not evaluating the watchpoint expression correctly. */
206 /* We have a watchpoint on ptr1->val. It should be triggered if
207 ptr1's value changes. */
210 /* This should not trigger the watchpoint. If it does, then we
211 used the wrong value chain to re-insert the watchpoints or we
212 are not evaluating the watchpoint expression correctly. */
216 /* We're going to watch locals of func2, to see that out-of-scope
217 watchpoints are detected and properly deleted.
221 /* This invocation is used for watches of a single
225 /* This invocation is used for watches of an expression
226 involving a local variable. */
229 /* This invocation is used for watches of a static
230 (non-stack-based) local variable. */
233 /* This invocation is used for watches of a local variable
234 when recursion happens.
239 /* This invocation is used for watches of a local variable with explicitly
240 specified scope when recursion happens.