- Timestamp:
- 08/05/2017 08:48:28 PM (7 years ago)
- Branches:
- master
- Children:
- 29618fe
- Parents:
- 5fa5369
- Location:
- emu
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/all.h
r5fa5369 r149c3e0 73 73 extern void gdb_quit(void); 74 74 extern void gdb_loop(void); 75 extern void gdb_inst( void);75 extern void gdb_inst(bool bp); 76 76 77 77 extern SDL_mutex *cpu_mutex; -
emu/cpu.c
r5fa5369 r149c3e0 494 494 static void inst_cb(void) 495 495 { 496 gdb_inst();497 498 496 uint32_t pc = m68k_get_reg(NULL, M68K_REG_PC); 499 497 uint32_t op = m68k_read_memory_16(pc); 498 499 gdb_inst(op == 0x4e4f); 500 500 501 501 if (op == 0x4e4d) { -
emu/gdb.c
r5fa5369 r149c3e0 39 39 #define LOCK_REQ 1 40 40 #define LOCK_ACK 2 41 #define LOCK_BP 3 41 42 42 43 typedef enum { … … 97 98 } 98 99 99 void gdb_inst( void)100 void gdb_inst(bool bp) 100 101 { 101 102 ver3("gdb inst"); 102 103 103 if ( SDL_AtomicGet(&lock) == LOCK_NONE) {104 if (!bp && SDL_AtomicGet(&lock) == LOCK_NONE) { 104 105 return; 105 106 } … … 107 108 if (SDL_UnlockMutex(cpu_mutex) < 0) { 108 109 fail("SDL_UnlockMutex() failed: %s", SDL_GetError()); 110 } 111 112 if (bp) { 113 ver2("-> lock bp"); 114 SDL_AtomicSet(&lock, LOCK_BP); 115 116 while (SDL_AtomicGet(&lock) != LOCK_REQ) { 117 SDL_Delay(100); 118 } 109 119 } 110 120 … … 124 134 } 125 135 136 static void wait_cpu(void) 137 { 138 while (SDL_AtomicGet(&lock) != LOCK_ACK) { 139 SDL_Delay(100); 140 } 141 142 ver2("<- lock ack"); 143 } 144 126 145 static void stop_cpu(void) 127 146 { … … 129 148 SDL_AtomicSet(&lock, LOCK_REQ); 130 149 131 while (SDL_AtomicGet(&lock) != LOCK_ACK) { 132 SDL_Delay(100); 133 } 134 135 ver2("<- lock ack"); 150 wait_cpu(); 136 151 } 137 152 … … 140 155 ver2("-> lock none"); 141 156 SDL_AtomicSet(&lock, LOCK_NONE); 142 }143 144 static void step_cpu(void)145 {146 ver2("-> lock req");147 SDL_AtomicSet(&lock, LOCK_REQ);148 }149 150 static void wait_cpu(void)151 {152 while (SDL_AtomicGet(&lock) != LOCK_ACK) {153 SDL_Delay(100);154 }155 156 ver2("<- lock ack");157 157 } 158 158 … … 215 215 216 216 cont_cpu(); 217 wait_cpu(); 218 219 // 0x05 = SIGTRAP 220 return RES_DAT("S05", 3); 217 218 return RES_OK; 221 219 } 222 220 … … 227 225 } 228 226 229 step_cpu(); 230 wait_cpu(); 227 stop_cpu(); 231 228 232 229 // 0x05 = SIGTRAP … … 455 452 } 456 453 454 if (res.out == NULL) { 455 return RES_OK; 456 } 457 457 458 static const uint8_t *hex = (uint8_t *)"0123456789abcdef"; 458 459 static uint8_t buf[SZ_BUF]; … … 487 488 488 489 ver3("input %c st %d n %d", byte, (int32_t)state, n_buf); 490 491 if (state == STATE_HEAD && byte == 0x03) { 492 stop_cpu(); 493 state = STATE_ACK; 494 return RES_DAT("$S05#b8", 7); 495 } 489 496 490 497 switch (state) { … … 552 559 } 553 560 561 if (res.out == NULL) { 562 state = STATE_HEAD; 563 return RES_OK; 564 } 565 554 566 state = STATE_ACK; 555 567 return RES_DAT(res.out, res.n_out); … … 588 600 589 601 while (SDL_AtomicGet(&run) != 0) { 590 int32_t n_act = SDLNet_CheckSockets(set, 250);602 int32_t n_act = SDLNet_CheckSockets(set, 100); 591 603 592 604 if (n_act < 0) { 593 605 fail("SDLNet_CheckSockets() failed: %s", SDLNet_GetError()); 606 } 607 608 if (SDL_AtomicGet(&lock) == LOCK_BP) { 609 ver2("<- lock bp"); 610 stop_cpu(); 611 state = STATE_ACK; 612 613 if (SDLNet_TCP_Send(con, "$S05#b8", 7) != 7) { 614 err("connection error"); 615 con_close(con); 616 con = NULL; 617 continue; 618 } 619 620 continue; 594 621 } 595 622
Note:
See TracChangeset
for help on using the changeset viewer.