Debian Codegraph @

src/gdb_test_program/main.c

raw symbols SCIP
1 /*
2 mbed CMSIS-DAP debugger
3 Copyright (c) 2015-2015 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17
18 #include<stdint.h>
19
20 volatile uint8_t run_breakpoint_test;
21 volatile uint8_t watchpoint_write;
22 volatile uint8_t watchpoint_read;
23 volatile uint8_t watchpoint_size;
24 void * volatile write_address;
25
26 volatile uint32_t watchpoint_write_buffer[3];
27
28
29 void function_1()
30 {
31
32 }
33
34 void function_2()
35 {
36
37 }
38
39 void function_3()
40 {
41
42 }
43
44 void breakpoint_test()
45 {
46
47 }
48
49 void watchpoint_test()
50 {
51 if (1 == watchpoint_size) {
52 if (watchpoint_read) {
53 *(volatile uint8_t*) write_address;
54 }
55 if (watchpoint_write) {
56 *(volatile uint8_t*) write_address = 42;
57 }
58 } else if (2 == watchpoint_size) {
59 if (watchpoint_read) {
60 *(volatile uint16_t*) write_address;
61 }
62 if (watchpoint_write) {
63 *(volatile uint16_t*) write_address = 42;
64 }
65 } else if (4 == watchpoint_size) {
66 if (watchpoint_read) {
67 *(volatile uint32_t*) write_address;
68 }
69 if (watchpoint_write) {
70 *(volatile uint32_t*) write_address = 42;
71 }
72 }
73 }
74
75 int main()
76 {
77 int i;
78
79 // Initialize variables
80 run_breakpoint_test = 0;
81 watchpoint_write = 0;
82 watchpoint_read = 0;
83 watchpoint_size = 0;
84 write_address = 0;
85 for (i = 0; i < sizeof(watchpoint_write_buffer) /
86 sizeof(watchpoint_write_buffer[0]); i++) {
87 watchpoint_write_buffer[i] = 0;
88 }
89
90 while(1) {
91 function_1();
92 function_2();
93 function_3();
94 if (run_breakpoint_test) {
95 breakpoint_test();
96 }
97 if (watchpoint_size) {
98 watchpoint_test();
99 }
100 }
101 }