GDB Stub: Initial commit

This commit is contained in:
RichardG867
2022-03-12 20:20:25 -03:00
parent a924622216
commit 94be8cdfc6
10 changed files with 1112 additions and 0 deletions

View File

@@ -121,6 +121,7 @@ option(DINPUT "DirectInput"
option(CPPTHREADS "C++11 threads" ON)
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
option(MINITRACE "Enable Chrome tracing using the modified minitrace library" OFF)
option(GDBSTUB "Enable GDB stub server for debugging" ON)
option(DEV_BRANCH "Development branch" OFF)
if(NOT WIN32)
option(QT "QT GUI" ON)

View File

@@ -93,6 +93,7 @@
#include <86box/ui.h>
#include <86box/plat.h>
#include <86box/version.h>
#include <86box/gdbstub.h>
/* Stuff that used to be globally declared in plat.h but is now extern there
@@ -736,6 +737,8 @@ usage:
if (lang_init)
lang_id = lang_init;
gdbstub_init();
/* All good! */
return(1);
}
@@ -1171,6 +1174,8 @@ pc_close(thread_t *ptr)
mo_close();
scsi_disk_close();
gdbstub_close();
}

View File

@@ -23,6 +23,11 @@ if(CPPTHREADS)
target_sources(86Box PRIVATE thread.cpp)
endif()
if(GDBSTUB)
add_compile_definitions(USE_GDBSTUB)
target_sources(86Box PRIVATE gdbstub.c)
endif()
if(NEW_DYNAREC)
add_compile_definitions(USE_NEW_DYNAREC)
endif()

View File

@@ -22,6 +22,7 @@
#include <86box/fdd.h>
#include <86box/fdc.h>
#include <86box/machine.h>
#include <86box/gdbstub.h>
#include "386_common.h"
#ifdef USE_NEW_DYNAREC
#include "codegen.h"
@@ -256,6 +257,11 @@ exec386(int cycs)
if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t) tsc))
timer_process_inline();
#ifdef USE_GDBSTUB
if (gdbstub_singlestep)
return;
#endif
}
}
}

View File

@@ -34,6 +34,7 @@
#include <86box/pic.h>
#include <86box/ppi.h>
#include <86box/timer.h>
#include <86box/gdbstub.h>
/* Is the CPU 8088 or 8086. */
int is8086 = 0;
@@ -2832,5 +2833,10 @@ execx86(int cycs)
cpu_alu_op = 0;
}
#ifdef USE_GDBSTUB
if (gdbstub_singlestep)
return;
#endif
}
}

1042
src/gdbstub.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Definitions for the GDB stub server.
*
*
*
* Authors: RichardG, <richardg867@gmail.com>
*
* Copyright 2022 RichardG.
*/
#ifndef EMU_GDBSTUB_H
# define EMU_GDBSTUB_H
#ifdef USE_GDBSTUB
extern int gdbstub_singlestep;
extern void gdbstub_pause(int *p);
extern void gdbstub_init();
extern void gdbstub_close();
#else
#define gdbstub_singlestep 0
#define gdbstub_pause(p)
#define gdbstub_init()
#define gdbstub_close()
#endif
#endif

View File

@@ -92,6 +92,7 @@ extern "C" {
#include "../cpu/cpu.h"
#include <86box/plat.h>
#include <86box/gdbstub.h>
volatile int cpu_thread_run = 1;
int mouse_capture = 0;
@@ -314,6 +315,8 @@ plat_pause(int p)
static wchar_t oldtitle[512];
wchar_t title[512], paused_msg[64];
gdbstub_pause(&p);
if (p == dopause) {
#ifdef Q_OS_WINDOWS
if (source_hwnd)

View File

@@ -32,6 +32,7 @@
#include <86box/timer.h>
#include <86box/nvr.h>
#include <86box/ui.h>
#include <86box/gdbstub.h>
static int first_use = 1;
static uint64_t StartingTime;
@@ -719,6 +720,8 @@ plat_pause(int p)
static wchar_t oldtitle[512];
wchar_t title[512];
gdbstub_pause(&p);
if ((p == 0) && (time_sync & TIME_SYNC_ENABLED))
nvr_time_sync();

View File

@@ -44,6 +44,7 @@
#include <86box/win.h>
#include <86box/version.h>
#include <86box/discord.h>
#include <86box/gdbstub.h>
#ifdef MTR_ENABLED
#include <minitrace/minitrace.h>
@@ -1496,6 +1497,8 @@ plat_pause(int p)
static wchar_t oldtitle[512];
wchar_t title[512];
gdbstub_pause(&p);
/* If un-pausing, as the renderer if that's OK. */
if (p == 0)
p = get_vidpause();