mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00

These will be needed from multiple places in the code. They are declared as inline so move to the header and fix up to modern coding style. The only other place that messes with hex stuff at the moment is the URI handling in utils but that would be more code churn so leave for now. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org> Message-Id: <20230303025805.625589-9-richard.henderson@linaro.org>
96 lines
2 KiB
C
96 lines
2 KiB
C
/*
|
|
* gdbstub internals
|
|
*
|
|
* Copyright (c) 2022 Linaro Ltd
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef GDBSTUB_INTERNALS_H
|
|
#define GDBSTUB_INTERNALS_H
|
|
|
|
#include "exec/cpu-common.h"
|
|
|
|
#define MAX_PACKET_LENGTH 4096
|
|
|
|
/*
|
|
* Shared structures and definitions
|
|
*/
|
|
|
|
typedef struct GDBProcess {
|
|
uint32_t pid;
|
|
bool attached;
|
|
|
|
char target_xml[1024];
|
|
} GDBProcess;
|
|
|
|
enum RSState {
|
|
RS_INACTIVE,
|
|
RS_IDLE,
|
|
RS_GETLINE,
|
|
RS_GETLINE_ESC,
|
|
RS_GETLINE_RLE,
|
|
RS_CHKSUM1,
|
|
RS_CHKSUM2,
|
|
};
|
|
|
|
typedef struct GDBState {
|
|
bool init; /* have we been initialised? */
|
|
CPUState *c_cpu; /* current CPU for step/continue ops */
|
|
CPUState *g_cpu; /* current CPU for other ops */
|
|
CPUState *query_cpu; /* for q{f|s}ThreadInfo */
|
|
enum RSState state; /* parsing state */
|
|
char line_buf[MAX_PACKET_LENGTH];
|
|
int line_buf_index;
|
|
int line_sum; /* running checksum */
|
|
int line_csum; /* checksum at the end of the packet */
|
|
GByteArray *last_packet;
|
|
int signal;
|
|
bool multiprocess;
|
|
GDBProcess *processes;
|
|
int process_num;
|
|
char syscall_buf[256];
|
|
gdb_syscall_complete_cb current_syscall_cb;
|
|
GString *str_buf;
|
|
GByteArray *mem_buf;
|
|
int sstep_flags;
|
|
int supported_sstep_flags;
|
|
} GDBState;
|
|
|
|
|
|
/*
|
|
* Inline utility function, convert from int to hex and back
|
|
*/
|
|
|
|
static inline int fromhex(int v)
|
|
{
|
|
if (v >= '0' && v <= '9') {
|
|
return v - '0';
|
|
} else if (v >= 'A' && v <= 'F') {
|
|
return v - 'A' + 10;
|
|
} else if (v >= 'a' && v <= 'f') {
|
|
return v - 'a' + 10;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
static inline int tohex(int v)
|
|
{
|
|
if (v < 10) {
|
|
return v + '0';
|
|
} else {
|
|
return v - 10 + 'a';
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Break/Watch point support - there is an implementation for softmmu
|
|
* and user mode.
|
|
*/
|
|
bool gdb_supports_guest_debug(void);
|
|
int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len);
|
|
int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len);
|
|
void gdb_breakpoint_remove_all(CPUState *cs);
|
|
|
|
#endif /* GDBSTUB_INTERNALS_H */
|