Mercurial > repos > blastem
diff gdb_remote.c @ 2053:3414a4423de1 segacd
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 15 Jan 2022 13:15:21 -0800 |
parents | 3a46ff899fa6 |
children | a7b753e260a2 f80c6111e1ae |
line wrap: on
line diff
--- a/gdb_remote.c Sat Jan 05 00:58:08 2019 -0800 +++ b/gdb_remote.c Sat Jan 15 13:15:21 2022 -0800 @@ -18,13 +18,13 @@ #define GDB_OUT_FD STDOUT_FILENO #define GDB_READ read #define GDB_WRITE write +#include <unistd.h> #endif #include "gdb_remote.h" #include "68kinst.h" #include "debug.h" #include "util.h" -#include <unistd.h> #include <fcntl.h> #include <stddef.h> #include <stdlib.h> @@ -132,25 +132,13 @@ } } -uint8_t read_byte(m68k_context * context, uint32_t address) +static uint8_t m68k_read_byte(m68k_context *context, uint32_t address) { - - genesis_context *gen = context->system; - //TODO: Use generated read/write functions to support access to hardware that is not ROM or RAM - uint16_t * word = get_native_pointer(address & 0xFFFFFFFE, (void **)context->mem_pointers, &context->options->gen); - if (word) { - if (address & 1) { - return *word; - } - return *word >> 8; -} - if (address >= 0xA00000 && address < 0xA04000) { - return gen->zram[address & 0x1FFF]; - } - return 0; + //TODO: share this implementation with builtin debugger + return read_byte(address, (void **)context->mem_pointers, &context->options->gen, context); } -void write_byte(m68k_context * context, uint32_t address, uint8_t value) +void m68k_write_byte(m68k_context * context, uint32_t address, uint8_t value) { genesis_context *gen = context->system; //TODO: Use generated read/write functions so that memory map is properly respected @@ -170,7 +158,7 @@ if (address >= 0xA00000 && address < 0xA04000) { gen->zram[address & 0x1FFF] = value; genesis_context * gen = context->system; -#ifndef NO_Z80 +#if !defined(NO_Z80) && !defined(NEW_CORE) z80_handle_code_write(address & 0x1FFF, gen->z80); #endif return; @@ -305,7 +293,7 @@ char *cur = send_buf; while (size) { - hex_8(read_byte(context, address), cur); + hex_8(m68k_read_byte(context, address), cur); cur += 2; address++; size--; @@ -326,7 +314,7 @@ tmp[0] = *(cur++); tmp[1] = *(cur++); tmp[2] = 0; - write_byte(context, address, strtoul(tmp, NULL, 16)); + m68k_write_byte(context, address, strtoul(tmp, NULL, 16)); address++; size--; } @@ -401,6 +389,10 @@ gdb_send_command("m1"); } else if (!strcmp("sThreadInfo", command + 1)) { gdb_send_command("l"); + } else if (!memcmp("ThreadExtraInfo", command+1, strlen("ThreadExtraInfo"))) { + gdb_send_command(""); + } else if (command[1] == 'P') { + gdb_send_command(""); } else { goto not_impl; } @@ -558,21 +550,13 @@ } } -#ifdef _WIN32 -void gdb_cleanup(void) -{ - WSACleanup(); -} -WSADATA wsa_data; -#endif - void gdb_remote_init(void) { buf = malloc(INITIAL_BUFFER_SIZE); curbuf = NULL; bufsize = INITIAL_BUFFER_SIZE; #ifdef _WIN32 - WSAStartup(MAKEWORD(2,2), &wsa_data); + socket_init(); struct addrinfo request, *result; memset(&request, 0, sizeof(request)); @@ -588,6 +572,7 @@ if (bind(listen_sock, result->ai_addr, result->ai_addrlen) < 0) { fatal_error("Failed to bind GDB remote debugging socket"); } + freeaddrinfo(result); if (listen(listen_sock, 1) < 0) { fatal_error("Failed to listen on GDB remote debugging socket"); } @@ -595,6 +580,8 @@ if (gdb_sock < 0) { fatal_error("accept returned an error while listening on GDB remote debugging socket"); } - closesocket(listen_sock); + socket_close(listen_sock); +#else + disable_stdout_messages(); #endif }