2024-07-05 11:40:38 +03:00
|
|
|
#ifndef GDBSTUB_COMMANDS_H
|
|
|
|
#define GDBSTUB
|
|
|
|
|
|
|
|
typedef void (*GdbCmdHandler)(GArray *params, void *user_ctx);
|
|
|
|
|
|
|
|
typedef enum GDBThreadIdKind {
|
|
|
|
GDB_ONE_THREAD = 0,
|
|
|
|
GDB_ALL_THREADS, /* One process, all threads */
|
|
|
|
GDB_ALL_PROCESSES,
|
|
|
|
GDB_READ_THREAD_ERR
|
|
|
|
} GDBThreadIdKind;
|
|
|
|
|
|
|
|
typedef union GdbCmdVariant {
|
|
|
|
const char *data;
|
|
|
|
uint8_t opcode;
|
|
|
|
unsigned long val_ul;
|
|
|
|
unsigned long long val_ull;
|
|
|
|
struct {
|
|
|
|
GDBThreadIdKind kind;
|
|
|
|
uint32_t pid;
|
|
|
|
uint32_t tid;
|
|
|
|
} thread_id;
|
|
|
|
} GdbCmdVariant;
|
|
|
|
|
|
|
|
#define gdb_get_cmd_param(p, i) (&g_array_index(p, GdbCmdVariant, i))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* typedef GdbCmdParseEntry - gdb command parser
|
|
|
|
*
|
|
|
|
* This structure keeps the information necessary to match a gdb command,
|
|
|
|
* parse it (extract its parameters), and select the correct handler for it.
|
|
|
|
*
|
|
|
|
* @cmd: The command to be matched
|
|
|
|
* @cmd_startswith: If true, @cmd is compared using startswith
|
|
|
|
* @schema: Each schema for the command parameter entry consists of 2 chars,
|
|
|
|
* the first char represents the parameter type handling the second char
|
|
|
|
* represents the delimiter for the next parameter.
|
|
|
|
*
|
|
|
|
* Currently supported schema types:
|
|
|
|
* 'l' -> unsigned long (stored in .val_ul)
|
|
|
|
* 'L' -> unsigned long long (stored in .val_ull)
|
|
|
|
* 's' -> string (stored in .data)
|
|
|
|
* 'o' -> single char (stored in .opcode)
|
|
|
|
* 't' -> thread id (stored in .thread_id)
|
|
|
|
* '?' -> skip according to delimiter
|
|
|
|
*
|
|
|
|
* Currently supported delimiters:
|
|
|
|
* '?' -> Stop at any delimiter (",;:=\0")
|
|
|
|
* '0' -> Stop at "\0"
|
|
|
|
* '.' -> Skip 1 char unless reached "\0"
|
|
|
|
* Any other value is treated as the delimiter value itself
|
|
|
|
*
|
|
|
|
* @allow_stop_reply: True iff the gdbstub can respond to this command with a
|
|
|
|
* "stop reply" packet. The list of commands that accept such response is
|
|
|
|
* defined at the GDB Remote Serial Protocol documentation. See:
|
|
|
|
* https://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html#Stop-Reply-Packets.
|
2024-07-05 11:40:44 +03:00
|
|
|
*
|
|
|
|
* @need_cpu_context: Pass current CPU context to command handler via user_ctx.
|
2024-07-05 11:40:38 +03:00
|
|
|
*/
|
|
|
|
typedef struct GdbCmdParseEntry {
|
|
|
|
GdbCmdHandler handler;
|
|
|
|
const char *cmd;
|
|
|
|
bool cmd_startswith;
|
|
|
|
const char *schema;
|
|
|
|
bool allow_stop_reply;
|
2024-07-05 11:40:44 +03:00
|
|
|
bool need_cpu_context;
|
2024-07-05 11:40:38 +03:00
|
|
|
} GdbCmdParseEntry;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdb_put_packet() - put string into gdb server's buffer so it is sent
|
|
|
|
* to the client
|
|
|
|
*/
|
|
|
|
int gdb_put_packet(const char *buf);
|
|
|
|
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
/**
|
|
|
|
* gdb_extend_query_table() - Extend query table.
|
2024-07-18 12:45:11 +03:00
|
|
|
* @table: GPtrArray of GdbCmdParseEntry entries.
|
|
|
|
*
|
|
|
|
* The caller should free @table afterwards
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
*/
|
2024-07-18 12:45:11 +03:00
|
|
|
void gdb_extend_query_table(GPtrArray *table);
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdb_extend_set_table() - Extend set table.
|
2024-07-18 12:45:11 +03:00
|
|
|
* @table: GPtrArray of GdbCmdParseEntry entries.
|
|
|
|
*
|
|
|
|
* The caller should free @table afterwards
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
*/
|
2024-07-18 12:45:11 +03:00
|
|
|
void gdb_extend_set_table(GPtrArray *table);
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdb_extend_qsupported_features() - Extend the qSupported features string.
|
|
|
|
* @qsupported_features: The additional qSupported feature(s) string. The string
|
|
|
|
* should start with a semicolon and, if there are more than one feature, the
|
2024-07-18 12:45:11 +03:00
|
|
|
* features should be separate by a semicolon.
|
|
|
|
*
|
|
|
|
* The caller should free @qsupported_features afterwards if
|
|
|
|
* dynamically allocated.
|
gdbstub: Add support for target-specific stubs
Currently, it's not possible to have stubs specific to a given target,
even though there are GDB features which are target-specific, like, for
instance, memory tagging.
This commit introduces gdb_extend_qsupported_features,
gdb_extend_query_table, and gdb_extend_set_table functions as interfaces
to extend the qSupported string, the query handler table, and the set
handler table, allowing target-specific stub implementations.
Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240628050850.536447-4-gustavo.romero@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240705084047.857176-33-alex.bennee@linaro.org>
2024-07-05 11:40:39 +03:00
|
|
|
*/
|
|
|
|
void gdb_extend_qsupported_features(char *qsupported_features);
|
|
|
|
|
2024-07-05 11:40:43 +03:00
|
|
|
/**
|
|
|
|
* Convert a hex string to bytes. Conversion is done per byte, so 2 hex digits
|
|
|
|
* are converted to 1 byte. Invalid hex digits are treated as 0 digits.
|
|
|
|
*/
|
|
|
|
void gdb_hextomem(GByteArray *mem, const char *buf, int len);
|
|
|
|
|
2024-07-05 11:40:38 +03:00
|
|
|
#endif /* GDBSTUB_COMMANDS_H */
|