[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 13/20] mcdstub: added queries for memory spaces, register grou
|
From: |
Nicolas Eder |
|
Subject: |
[PATCH v3 13/20] mcdstub: added queries for memory spaces, register groups and registers |
|
Date: |
Tue, 7 Nov 2023 14:03:16 +0100 |
---
include/mcdstub/mcdstub.h | 57 ++++++++++
mcdstub/mcdstub.c | 229 ++++++++++++++++++++++++++++++++++++++
2 files changed, 286 insertions(+)
diff --git a/include/mcdstub/mcdstub.h b/include/mcdstub/mcdstub.h
index 62394e7c12..85ca8b3b62 100644
--- a/include/mcdstub/mcdstub.h
+++ b/include/mcdstub/mcdstub.h
@@ -550,6 +550,63 @@ void handle_close_core(GArray *params, void *user_ctx);
*/
void handle_query_trigger(GArray *params, void *user_ctx);
+/**
+ * handle_query_reg_groups_f() - Handler for the first register group query.
+ *
+ * This function sends the first register group name and ID.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_reg_groups_f(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_reg_groups_c() - Handler for all consecutive register group
+ * queries.
+ *
+ * This function sends all consecutive register group names and IDs. It uses
+ * the query_index parameter to determine which register group is queried next.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_reg_groups_c(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_mem_spaces_f() Handler for the first memory space query.
+ *
+ * This function sends the first memory space name, ID, type and accessing
+ * options.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_mem_spaces_f(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_mem_spaces_c() - Handler for all consecutive memory space
+ * queries.
+ *
+ * This function sends all consecutive memory space names, IDs, types and
+ * accessing options.
+ * It uses the query_index parameter to determine
+ * which memory space is queried next.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_mem_spaces_c(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_regs_f() - Handler for the first register query.
+ *
+ * This function sends the first register with all its information.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_regs_f(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_regs_c() - Handler for all consecutive register queries.
+ *
+ * This function sends all consecutive registers with all their information.
+ * It uses the query_index parameter to determine
+ * which register is queried next.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_regs_c(GArray *params, void *user_ctx);
+
/**
* handle_open_server() - Handler for opening the MCD server.
*
diff --git a/mcdstub/mcdstub.c b/mcdstub/mcdstub.c
index 3e87378b45..56854c4c76 100644
--- a/mcdstub/mcdstub.c
+++ b/mcdstub/mcdstub.c
@@ -117,6 +117,54 @@ void init_query_cmds_table(MCDCmdParseEntry
*mcd_query_cmds_table)
mcd_query_cmds_table[cmd_number] = query_trigger;
cmd_number++;
+ MCDCmdParseEntry query_mem_spaces_f = {
+ .handler = handle_query_mem_spaces_f,
+ .cmd = QUERY_ARG_MEMORY QUERY_FIRST,
+ };
+ strcpy(query_mem_spaces_f.schema, (char[2]) { ARG_SCHEMA_CORENUM, '\0' });
+ mcd_query_cmds_table[cmd_number] = query_mem_spaces_f;
+ cmd_number++;
+
+ MCDCmdParseEntry query_mem_spaces_c = {
+ .handler = handle_query_mem_spaces_c,
+ .cmd = QUERY_ARG_MEMORY QUERY_CONSEQUTIVE,
+ };
+ strcpy(query_mem_spaces_c.schema, (char[2]) { ARG_SCHEMA_QRYHANDLE, '\0'
});
+ mcd_query_cmds_table[cmd_number] = query_mem_spaces_c;
+ cmd_number++;
+
+ MCDCmdParseEntry query_reg_groups_f = {
+ .handler = handle_query_reg_groups_f,
+ .cmd = QUERY_ARG_REGGROUP QUERY_FIRST,
+ };
+ strcpy(query_reg_groups_f.schema, (char[2]) { ARG_SCHEMA_CORENUM, '\0' });
+ mcd_query_cmds_table[cmd_number] = query_reg_groups_f;
+ cmd_number++;
+
+ MCDCmdParseEntry query_reg_groups_c = {
+ .handler = handle_query_reg_groups_c,
+ .cmd = QUERY_ARG_REGGROUP QUERY_CONSEQUTIVE,
+ };
+ strcpy(query_reg_groups_c.schema, (char[2]) { ARG_SCHEMA_QRYHANDLE, '\0'
});
+ mcd_query_cmds_table[cmd_number] = query_reg_groups_c;
+ cmd_number++;
+
+ MCDCmdParseEntry query_regs_f = {
+ .handler = handle_query_regs_f,
+ .cmd = QUERY_ARG_REG QUERY_FIRST,
+ };
+ strcpy(query_regs_f.schema, (char[2]) { ARG_SCHEMA_CORENUM, '\0' });
+ mcd_query_cmds_table[cmd_number] = query_regs_f;
+ cmd_number++;
+
+ MCDCmdParseEntry query_regs_c = {
+ .handler = handle_query_regs_c,
+ .cmd = QUERY_ARG_REG QUERY_CONSEQUTIVE,
+ };
+ strcpy(query_regs_c.schema, (char[2]) { ARG_SCHEMA_QRYHANDLE, '\0' });
+ mcd_query_cmds_table[cmd_number] = query_regs_c;
+ cmd_number++;
+
MCDCmdParseEntry query_state = {
.handler = handle_query_state,
.cmd = QUERY_ARG_STATE,
@@ -1237,3 +1285,184 @@ void handle_query_trigger(GArray *params, void
*user_ctx)
TCP_ARGUMENT_ACTION, trigger.action);
mcd_put_strbuf();
}
+
+void handle_query_mem_spaces_f(GArray *params, void *user_ctx)
+{
+ /* 1. get correct memspaces and set the query_cpu */
+ uint32_t cpu_id = get_param(params, 0)->cpu_id;
+ mcdserver_state.query_cpu_id = cpu_id;
+ GArray *memspaces = g_list_nth_data(mcdserver_state.all_memspaces, cpu_id);
+
+ /* 2. check length */
+ int nb_groups = memspaces->len;
+ if (nb_groups == 1) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "1%s", QUERY_END_INDEX);
+ }
+
+ /* 3. send data */
+ mcd_mem_space_st space = g_array_index(memspaces, mcd_mem_space_st, 0);
+ g_string_append_printf(mcdserver_state.str_buf,
+ "%s=%s.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.%s=%ld.%s=%ld.%s=%u.",
+ TCP_ARGUMENT_NAME, space.name,
+ TCP_ARGUMENT_ID, space.id,
+ TCP_ARGUMENT_TYPE, space.type,
+ TCP_ARGUMENT_BITS_PER_MAU, space.bits_per_mau,
+ TCP_ARGUMENT_INVARIANCE, space.invariance,
+ TCP_ARGUMENT_ENDIAN, space.endian,
+ TCP_ARGUMENT_MIN, space.min_addr,
+ TCP_ARGUMENT_MAX, space.max_addr,
+ TCP_ARGUMENT_SUPPORTED_ACCESS_OPTIONS, space.supported_access_options);
+ mcd_put_strbuf();
+}
+
+void handle_query_mem_spaces_c(GArray *params, void *user_ctx)
+{
+ /*
+ * this funcitons send all mem spaces except for the first
+ * 1. get parameter and memspace
+ */
+ uint32_t query_index = get_param(params, 0)->query_handle;
+ uint32_t cpu_id = mcdserver_state.query_cpu_id;
+ GArray *memspaces = g_list_nth_data(mcdserver_state.all_memspaces, cpu_id);
+
+ /* 2. check weather this was the last mem space */
+ int nb_groups = memspaces->len;
+ if (query_index + 1 == nb_groups) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "%u!", query_index + 1);
+ }
+
+ /* 3. send the correct memspace */
+ mcd_mem_space_st space = g_array_index(memspaces,
+ mcd_mem_space_st, query_index);
+ g_string_append_printf(mcdserver_state.str_buf,
+ "%s=%s.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.%s=%ld.%s=%ld.%s=%u.",
+ TCP_ARGUMENT_NAME, space.name,
+ TCP_ARGUMENT_ID, space.id,
+ TCP_ARGUMENT_TYPE, space.type,
+ TCP_ARGUMENT_BITS_PER_MAU, space.bits_per_mau,
+ TCP_ARGUMENT_INVARIANCE, space.invariance,
+ TCP_ARGUMENT_ENDIAN, space.endian,
+ TCP_ARGUMENT_MIN, space.min_addr,
+ TCP_ARGUMENT_MAX, space.max_addr,
+ TCP_ARGUMENT_SUPPORTED_ACCESS_OPTIONS, space.supported_access_options);
+ mcd_put_strbuf();
+}
+
+void handle_query_reg_groups_f(GArray *params, void *user_ctx)
+{
+ /* 1. get correct reggroups and set the query_cpu */
+ uint32_t cpu_id = get_param(params, 0)->cpu_id;
+ mcdserver_state.query_cpu_id = cpu_id;
+ GArray *reggroups = g_list_nth_data(mcdserver_state.all_reggroups, cpu_id);
+
+ /* 2. check length */
+ int nb_groups = reggroups->len;
+ if (nb_groups == 1) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "1%s", QUERY_END_INDEX);
+ }
+ /* 3. send data */
+ mcd_reg_group_st group = g_array_index(reggroups, mcd_reg_group_st, 0);
+ g_string_append_printf(mcdserver_state.str_buf, "%s=%u.%s=%s.",
+ TCP_ARGUMENT_ID, group.id, TCP_ARGUMENT_NAME, group.name);
+ mcd_put_strbuf();
+}
+
+void handle_query_reg_groups_c(GArray *params, void *user_ctx)
+{
+ /*
+ * this funcitons send all reg groups except for the first
+ * 1. get parameter and memspace
+ */
+ uint32_t query_index = get_param(params, 0)->query_handle;
+ uint32_t cpu_id = mcdserver_state.query_cpu_id;
+ GArray *reggroups = g_list_nth_data(mcdserver_state.all_reggroups, cpu_id);
+
+ /* 2. check weather this was the last reg group */
+ int nb_groups = reggroups->len;
+ if (query_index + 1 == nb_groups) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "%u!", query_index + 1);
+ }
+
+ /* 3. send the correct reggroup */
+ mcd_reg_group_st group = g_array_index(reggroups, mcd_reg_group_st,
+ query_index);
+ g_string_append_printf(mcdserver_state.str_buf, "%s=%u.%s=%s.",
+ TCP_ARGUMENT_ID, group.id, TCP_ARGUMENT_NAME, group.name);
+ mcd_put_strbuf();
+}
+
+void handle_query_regs_f(GArray *params, void *user_ctx)
+{
+ /* 1. get correct registers and set the query_cpu */
+ uint32_t cpu_id = get_param(params, 0)->cpu_id;
+ mcdserver_state.query_cpu_id = cpu_id;
+ GArray *registers = g_list_nth_data(mcdserver_state.all_registers, cpu_id);
+
+ /* 2. check length */
+ int nb_regs = registers->len;
+ if (nb_regs == 1) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "1%s", QUERY_END_INDEX);
+ }
+ /* 3. send data */
+ mcd_reg_st my_register = g_array_index(registers, mcd_reg_st, 0);
+ g_string_append_printf(mcdserver_state.str_buf,
+ "%s=%u.%s=%s.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.",
+ TCP_ARGUMENT_ID, my_register.id,
+ TCP_ARGUMENT_NAME, my_register.name,
+ TCP_ARGUMENT_SIZE, my_register.bitsize,
+ TCP_ARGUMENT_REGGROUPID, my_register.mcd_reg_group_id,
+ TCP_ARGUMENT_MEMSPACEID, my_register.mcd_mem_space_id,
+ TCP_ARGUMENT_TYPE, my_register.mcd_reg_type,
+ TCP_ARGUMENT_THREAD, my_register.mcd_hw_thread_id,
+ TCP_ARGUMENT_OPCODE, my_register.opcode);
+ mcd_put_strbuf();
+}
+
+void handle_query_regs_c(GArray *params, void *user_ctx)
+{
+ /*
+ * this funcitons send all regs except for the first
+ * 1. get parameter and registers
+ */
+ uint32_t query_index = get_param(params, 0)->query_handle;
+ uint32_t cpu_id = mcdserver_state.query_cpu_id;
+ GArray *registers = g_list_nth_data(mcdserver_state.all_registers, cpu_id);
+
+ /* 2. check weather this was the last register */
+ int nb_regs = registers->len;
+ if (query_index + 1 == nb_regs) {
+ /* indicates this is the last packet */
+ g_string_printf(mcdserver_state.str_buf, "0%s", QUERY_END_INDEX);
+ } else {
+ g_string_printf(mcdserver_state.str_buf, "%u!", query_index + 1);
+ }
+
+ /* 3. send the correct register */
+ mcd_reg_st my_register = g_array_index(registers, mcd_reg_st, query_index);
+ g_string_append_printf(mcdserver_state.str_buf,
+ "%s=%u.%s=%s.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.%s=%u.",
+ TCP_ARGUMENT_ID, my_register.id,
+ TCP_ARGUMENT_NAME, my_register.name,
+ TCP_ARGUMENT_SIZE, my_register.bitsize,
+ TCP_ARGUMENT_REGGROUPID, my_register.mcd_reg_group_id,
+ TCP_ARGUMENT_MEMSPACEID, my_register.mcd_mem_space_id,
+ TCP_ARGUMENT_TYPE, my_register.mcd_reg_type,
+ TCP_ARGUMENT_THREAD, my_register.mcd_hw_thread_id,
+ TCP_ARGUMENT_OPCODE, my_register.opcode);
+ mcd_put_strbuf();
+}
--
2.34.1
- [PATCH v3 08/20] mcdstub: query packet processing added and core/system querie added, (continued)
- [PATCH v3 08/20] mcdstub: query packet processing added and core/system querie added, Nicolas Eder, 2023/11/07
- [PATCH v3 05/20] mcdstub: tcp packet processing added, Nicolas Eder, 2023/11/07
- [PATCH v3 20/20] mcdstub: updated MAINTAINERS file and fully activated the mcdstub in the meson build system, Nicolas Eder, 2023/11/07
- [PATCH v3 18/20] mcdstub: read/write to memory added: This also includes various helper functions in the QEMU memory code, Nicolas Eder, 2023/11/07
- [PATCH v3 02/20] mcdstub gdbstub: new DebugClass and DebugState introduced. They are used to abstract the debugger details behind a QOM. This is currently used in the cpu_handle_guest_debug function, Nicolas Eder, 2023/11/07
- [PATCH v3 11/20] mcdstub: reset and trigger queries added, Nicolas Eder, 2023/11/07
- [PATCH v3 06/20] mcdstub: open/close server functions and trigger/reset data added. User for initial connection with an mcd client, Nicolas Eder, 2023/11/07
- [PATCH v3 12/20] mcdstub: missing parse_reg_xml function for parsing gdb register xml files added, Nicolas Eder, 2023/11/07
- [PATCH v3 13/20] mcdstub: added queries for memory spaces, register groups and registers,
Nicolas Eder <=
- [PATCH v3 19/20] mcdstub: break/watchpoints added, Nicolas Eder, 2023/11/07
- [PATCH v3 14/20] mcdstub: missing handle_query_state function added, Nicolas Eder, 2023/11/07
- [PATCH v3 04/20] mcdstub: added header with defines specific to the mcd tcp packet communication, Nicolas Eder, 2023/11/07
- [PATCH v3 16/20] mcdstub: function construct for resets added, Nicolas Eder, 2023/11/07
- [PATCH v3 15/20] mcdstub: added go, break and step functionality and all corresponding functions, Nicolas Eder, 2023/11/07
- [PATCH v3 03/20] gdbstub: moving code so that it can be easier accessed from outside the gdbstub: fromhex and tohex functions moved to a cutils header. GDBRegisterState moved to gdbstub.h, Nicolas Eder, 2023/11/07
- [PATCH v3 17/20] mcdstub: reading/writing registers added, Nicolas Eder, 2023/11/07
- Re: [PATCH v3 00/20] first version of mcdstub, Philippe Mathieu-Daudé, 2023/11/08