Update gdbstub.

This commit is contained in:
Colin 2025-09-22 07:28:09 +00:00
parent 9ac39e6a12
commit 8eaf2c0b7b
10 changed files with 2808 additions and 482 deletions

View File

@ -53,6 +53,7 @@
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"internals.h": "c"
}
}

30
backup/breakpoint.h Normal file
View File

@ -0,0 +1,30 @@
/*
* QEMU breakpoint & watchpoint definitions
*
* Copyright (c) 2012 SUSE LINUX Products GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef EXEC_BREAKPOINT_H
#define EXEC_BREAKPOINT_H
#include "qemu/queue.h"
#include "exec/vaddr.h"
#include "exec/memattrs.h"
typedef struct CPUBreakpoint {
vaddr pc;
int flags; /* BP_* */
QTAILQ_ENTRY(CPUBreakpoint) entry;
} CPUBreakpoint;
typedef struct CPUWatchpoint {
vaddr vaddr;
vaddr len;
vaddr hitaddr;
MemTxAttrs hitattrs;
int flags; /* BP_* */
QTAILQ_ENTRY(CPUWatchpoint) entry;
} CPUWatchpoint;
#endif

1178
backup/cpu.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,13 @@ set(CMAKE_CXX_EXTENSIONS ON)
find_package(PkgConfig REQUIRED) # GLib
pkg_check_modules(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS}) #
link_directories(${GLIB_LIBRARY_DIRS}) #
file(GLOB UTILS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp
@ -55,4 +62,4 @@ set_source_files_properties(${UTILS_SRC} PROPERTIES LANGUAGE CXX)
add_executable(stub ${UTILS_SRC} stub.cpp)
target_include_directories(stub PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(stub PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/utils)
target_link_libraries(stub ${GLIB_LIBRARIES})

30
gdbstub/breakpoint.h Normal file
View File

@ -0,0 +1,30 @@
/*
* QEMU breakpoint & watchpoint definitions
*
* Copyright (c) 2012 SUSE LINUX Products GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef EXEC_BREAKPOINT_H
#define EXEC_BREAKPOINT_H
// #include "qemu/queue.h"
// #include "exec/vaddr.h"
// #include "exec/memattrs.h"
typedef struct CPUBreakpoint {
uintptr_t pc;
int flags; /* BP_* */
struct CPUBreakpoint* entry;
} CPUBreakpoint;
typedef struct CPUWatchpoint {
uintptr_t vaddr;
uintptr_t len;
uintptr_t hitaddr;
// MemTxAttrs hitattrs;
int flags; /* BP_* */
struct CPUWatchpoint* entry;
} CPUWatchpoint;
#endif

1151
gdbstub/cpu.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,12 @@
#define DEFAULT_GDBSTUB_PORT "1234"
typedef uintptr_t vaddr;
typedef int Error;
#define MMU_ACCESS_COUNT 16
/* GDB breakpoint/watchpoint types */
#define GDB_BREAKPOINT_SW 0
#define GDB_BREAKPOINT_HW 1

View File

@ -1,22 +1,23 @@
#ifndef GDBSTUB_H
#define GDBSTUB_H
#include "cpu.h"
typedef struct GDBFeature {
const char *xmlname;
const char *xml;
const char *name;
const char * const *regs;
int num_regs;
const char *xmlname;
const char *xml;
const char *name;
const char *const *regs;
int num_regs;
} GDBFeature;
typedef struct GDBFeatureBuilder {
GDBFeature *feature;
GPtrArray *xml;
GPtrArray *regs;
int base_reg;
GDBFeature *feature;
GPtrArray *xml;
GPtrArray *regs;
int base_reg;
} GDBFeatureBuilder;
/* Get or set a register. Returns the size of the register. */
typedef int (*gdb_get_reg_cb)(CPUState *cpu, GByteArray *buf, int reg);
typedef int (*gdb_set_reg_cb)(CPUState *cpu, uint8_t *buf, int reg);
@ -36,9 +37,8 @@ void gdb_init_cpu(CPUState *cpu);
* @xml - xml name of set
* @gpos - non-zero to append to "general" register set at @gpos
*/
void gdb_register_coprocessor(CPUState *cpu,
gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg,
const GDBFeature *feature, int g_pos);
void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature,
int g_pos);
/**
* gdb_unregister_coprocessor_all() - unregisters supplemental set of registers
@ -70,8 +70,7 @@ bool gdbserver_start(const char *port_or_device, Error **errp);
* @xmlname: The name of the XML.
* @base_reg: The base number of the register ID.
*/
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
const char *name, const char *xmlname,
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature, const char *name, const char *xmlname,
int base_reg);
/**
@ -80,9 +79,7 @@ void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
* @format: The format of the tag.
* @...: The values to be formatted.
*/
void G_GNUC_PRINTF(2, 3)
gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder,
const char *format, ...);
void G_GNUC_PRINTF(2, 3) gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder, const char *format, ...);
/**
* gdb_feature_builder_append_reg() - Append a register.
@ -93,12 +90,8 @@ gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder,
* @type: The type of the register.
* @group: The register group to which this register belongs; it can be NULL.
*/
void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder,
const char *name,
int bitsize,
int regnum,
const char *type,
const char *group);
void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder, const char *name, int bitsize, int regnum,
const char *type, const char *group);
/**
* gdb_feature_builder_end() - End building GDBFeature.
@ -142,9 +135,9 @@ int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg);
* typedef GDBRegDesc - a register description from gdbstub
*/
typedef struct {
int gdb_reg;
const char *name;
const char *feature_name;
int gdb_reg;
const char *name;
const char *feature_name;
} GDBRegDesc;
/**

View File

@ -1,8 +1,8 @@
// #include "gdbstub.h"
#include <iostream>
#include "conn.h"
#include "gdbstub.h"
int main(int argc, char *argv[]) {
conn_t conn;

File diff suppressed because it is too large Load Diff