* gdbstub beginnings

* gdbstub: finish gdb impl things, next up is integration with melonDS

* holy fuck the gdbstub works

* gdb breakpoints work, but there's a mysterious crash on continue

* fix memory corruption that sometimes happened, and make resetting the console thru gdb work

* remove some gdb debug printing

* fix things in gdbstub

* separate option for enabling gdbstub

* add mode-dependent CPU registers

* C++ize the GDBstub code

* add gdbstub config in emu settings dialog

* make sure gdb is disabled when jit is enabled

* Remove unnecessary compiler flags, mark ARMJIT assembly code as no-execute-stack

This hardens the binary a little bit against common exploitation methods

* add option to wait for debugger attach on startup

* only insert GNU stack notes on linux

* disable gdbstub enable checkbox when jit is enabled

* fix non-linux incompatibilities

* enable gdbstub by default

* fix issues with gdbstub settings disable stuff

* format stuff

* update gdb test code

* Fix segfault when calling StubCallbacks->GetCPU()

C++ overrides are hard. Please I'm just a lowly C programmer.

* fix packet size not being sent correctly

Thanks to @GlowingUmbreon on Github for troubleshooting this

* fix select(2) calls (i should read docs more properly)

* fix GDB command sequencing/parsing issue (hopefully)

* [GDB] implement no-ack mode

* fix sending ack on handshake

* get lldb to work
This commit is contained in:
PoroCYon
2023-10-22 15:35:31 +02:00
committed by GitHub
parent 3d58a338a1
commit 3ab752b8ca
29 changed files with 3210 additions and 49 deletions

75
src/debug/hexutil.h Normal file
View File

@ -0,0 +1,75 @@
#ifndef HEXUTIL_GDB_H_
#define HEXUTIL_GDB_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
inline static uint8_t hex2nyb(uint8_t v)
{
if (v >= '0' && v <= '9') return v - '0';
else if (v >= 'A' && v <= 'F') return v - 'A' + 0xa;
else if (v >= 'a' && v <= 'f') return v - 'a' + 0xa;
else
{
__builtin_trap();
return 0xcc;
}
}
inline static uint8_t nyb2hex(uint8_t v)
{
v &= 0xf;
if (v >= 0xa) return v - 0xa + 'a';
else return v - 0x0 + '0';
}
inline static void hexfmt8(uint8_t* dst, uint8_t v)
{
dst[0] = nyb2hex(v>>4);
dst[1] = nyb2hex(v>>0);
}
inline static uint8_t unhex8(const uint8_t* src)
{
return (hex2nyb(src[0]) << 4) | hex2nyb(src[1]);
}
inline static void hexfmt16(uint8_t* dst, uint16_t v)
{
dst[0] = nyb2hex(v>> 4);
dst[1] = nyb2hex(v>> 0);
dst[2] = nyb2hex(v>>12);
dst[3] = nyb2hex(v>> 8);
}
inline static uint16_t unhex16(const uint8_t* src)
{
return unhex8(&src[0*2]) | ((uint16_t)unhex8(&src[1*2]) << 8);
}
inline static void hexfmt32(uint8_t* dst, uint32_t v)
{
for (size_t i = 0; i < 4; ++i, v >>= 8)
{
dst[2*i+0] = nyb2hex(v>>4);
dst[2*i+1] = nyb2hex(v>>0);
}
}
inline static uint32_t unhex32(const uint8_t* src)
{
uint32_t v = 0;
for (size_t i = 0; i < 4; ++i)
{
v |= (uint32_t)unhex8(&src[i*2]) << (i*8);
}
return v;
}
#ifdef __cplusplus
}
#endif
#endif