Mercurial > hg > Members > kono > os9 > sbc09
comparison trace.c @ 35:01519215ec70
add watch point
0xfe00 fixed ram area in MMU
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jul 2018 20:29:55 +0900 |
parents | 7c5379eb406e |
children | 52f7ad4c2ebb |
comparison
equal
deleted
inserted
replaced
34:2032755628dc | 35:01519215ec70 |
---|---|
56 | 56 |
57 typedef struct bp { | 57 typedef struct bp { |
58 int address; // physical address | 58 int address; // physical address |
59 int laddr; | 59 int laddr; |
60 int count; | 60 int count; |
61 int watch; // watch point | |
61 struct bp *next; | 62 struct bp *next; |
62 } BP, *BPTR; | 63 } BP, *BPTR; |
63 | 64 |
64 BPTR breakpoint = 0; | 65 BPTR breakpoint = 0; |
65 int bpskip = 0; | 66 int bpskip = 0; |
66 int trskip = 0; | 67 int trskip = 0; |
67 int stkskip = 0; | 68 int stkskip = 0; |
68 | 69 |
69 int getarg(char *buf, char** next) { | 70 int getarg(char *buf, char** next) { |
70 return strtol(buf,(char**)next,0); | 71 int value = strtol(buf,next,0); |
72 for(;next;) { | |
73 if ( **next == '+' ) { | |
74 value += strtol(*next+1,next,0); | |
75 } else if ( **next == '*' ) { | |
76 value *= strtol(*next+1,next,0); | |
77 } else if ( **next == '/' ) { | |
78 value /= strtol(*next+1,next,0); | |
79 } else if ( **next == '-' ) { | |
80 value -= strtol(*next+1,next,0); | |
81 } else if ( **next == '&' ) { | |
82 value &= strtol(*next+1,next,0); | |
83 } else if ( **next == '|' ) { | |
84 value |= strtol(*next+1,next,0); | |
85 } else break; | |
86 } | |
87 return value; | |
71 } | 88 } |
72 | 89 |
73 void printhelp(void) | 90 void printhelp(void) |
74 { | 91 { |
75 printf( | 92 printf( |
108 if (bpskip) { // skip unbreak instruction | 125 if (bpskip) { // skip unbreak instruction |
109 bpskip--; | 126 bpskip--; |
110 int ppc = paddr(pcreg,mmu); | 127 int ppc = paddr(pcreg,mmu); |
111 BPTR *prev = &breakpoint; | 128 BPTR *prev = &breakpoint; |
112 for(BPTR b = breakpoint; b ; prev=&b->next, b=b->next ) { | 129 for(BPTR b = breakpoint; b ; prev=&b->next, b=b->next ) { |
113 if (ppc==b->address /* || pcreg==b->laddr */) { | 130 #ifdef USE_MMU |
131 int watch = phymem[b->address]; | |
132 #else | |
133 int watch = mem[b->address]; | |
134 #endif | |
135 if (ppc==b->address || b->watch != watch ) { | |
136 b->watch = watch; | |
114 if (b->count==-1) { // temporaly break point | 137 if (b->count==-1) { // temporaly break point |
115 BPTR next = b->next; | 138 BPTR next = b->next; |
116 free(b); | 139 free(b); |
117 *prev = next; | 140 *prev = next; |
118 goto restart0; | 141 goto restart0; |
136 prog = (char*)phyadr - pcreg; | 159 prog = (char*)phyadr - pcreg; |
137 #endif | 160 #endif |
138 do_trace(stdout); | 161 do_trace(stdout); |
139 if (trskip>1) { // show trace and step | 162 if (trskip>1) { // show trace and step |
140 trskip--; | 163 trskip--; |
164 int watch; // watch point | |
141 set_term(escchar); | 165 set_term(escchar); |
142 return; | 166 return; |
143 } | 167 } |
144 restart: | 168 restart: |
145 printf("v09>"); | 169 printf("v09>"); |
179 bpskip = -1; | 203 bpskip = -1; |
180 goto restart; | 204 goto restart; |
181 case 'B': // break point list | 205 case 'B': // break point list |
182 for(BPTR bp = breakpoint; bp ; bp = bp->next) { | 206 for(BPTR bp = breakpoint; bp ; bp = bp->next) { |
183 #ifdef USE_MMU | 207 #ifdef USE_MMU |
184 printf("%x %x %d\n", bp->laddr, bp->address, bp->count); | 208 printf("0x%x p=0x%x c=%d w=0x%x\n", bp->laddr, bp->address, bp->count, bp->watch); |
185 #else | 209 #else |
186 printf("%x %d\n", bp->address, bp->count); | 210 printf("0x%x c=%d w=0x%x\n", bp->address, bp->count,bp->watch); |
187 #endif | 211 #endif |
188 } | 212 } |
189 goto restart; | 213 goto restart; |
190 case 'd': // delte break point list | 214 case 'd': // delte break point list |
191 if (s[1]) { | 215 if (s[1]) { |
358 bp->next = breakpoint; | 382 bp->next = breakpoint; |
359 breakpoint = bp; | 383 breakpoint = bp; |
360 bp->count = count; | 384 bp->count = count; |
361 bp->laddr = adr; | 385 bp->laddr = adr; |
362 bp->address = paddr(adr,mmu); | 386 bp->address = paddr(adr,mmu); |
387 #ifdef USE_MMU | |
388 bp->watch = *mem0(phymem,adr,mmu); | |
389 #else | |
390 bp->watch = mem[adr]; | |
391 #endif | |
363 } | 392 } |
364 | 393 |
365 int nexti(void) { | 394 int nexti(void) { |
366 #ifdef USE_MMU | 395 #ifdef USE_MMU |
367 int op1 = *mem0(phymem,pcreg,mmu); | 396 int op1 = *mem0(phymem,pcreg,mmu); |