[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 11/20] mcdstub: reset and trigger queries added
|
From: |
Nicolas Eder |
|
Subject: |
[PATCH v3 11/20] mcdstub: reset and trigger queries added |
|
Date: |
Tue, 7 Nov 2023 14:03:14 +0100 |
---
include/mcdstub/mcdstub.h | 25 ++++++++++++++
mcdstub/mcdstub.c | 69 +++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
diff --git a/include/mcdstub/mcdstub.h b/include/mcdstub/mcdstub.h
index eb46917d00..62394e7c12 100644
--- a/include/mcdstub/mcdstub.h
+++ b/include/mcdstub/mcdstub.h
@@ -507,6 +507,23 @@ CPUState *find_cpu(uint32_t thread_id);
*/
void handle_open_core(GArray *params, void *user_ctx);
+/**
+ * handle_query_reset_f() - Handler for the first reset query.
+ *
+ * This function sends the first reset name and ID.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_reset_f(GArray *params, void *user_ctx);
+
+/**
+ * handle_query_reset_c() - Handler for all consecutive reset queries.
+ *
+ * This functions sends all consecutive reset names and IDs. It uses the
+ * query_index parameter to determine which reset is queried next.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_reset_c(GArray *params, void *user_ctx);
+
/**
* handle_close_server() - Handler for closing the MCD server.
*
@@ -525,6 +542,14 @@ void handle_close_server(GArray *params, void *user_ctx);
*/
void handle_close_core(GArray *params, void *user_ctx);
+/**
+ * handle_query_trigger() - Handler for trigger query.
+ *
+ * Sends data on the different types of trigger and their options and actions.
+ * @params: GArray with all TCP packet parameters.
+ */
+void handle_query_trigger(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 657f80d2a2..d71dff633a 100644
--- a/mcdstub/mcdstub.c
+++ b/mcdstub/mcdstub.c
@@ -95,6 +95,27 @@ void init_query_cmds_table(MCDCmdParseEntry
*mcd_query_cmds_table)
mcd_query_cmds_table[cmd_number] = query_cores;
cmd_number++;
+ MCDCmdParseEntry query_reset_f = {
+ .handler = handle_query_reset_f,
+ .cmd = QUERY_ARG_RESET QUERY_FIRST,
+ };
+ mcd_query_cmds_table[cmd_number] = query_reset_f;
+ cmd_number++;
+
+ MCDCmdParseEntry query_reset_c = {
+ .handler = handle_query_reset_c,
+ .cmd = QUERY_ARG_RESET QUERY_CONSEQUTIVE,
+ };
+ strcpy(query_reset_c.schema, (char[2]) { ARG_SCHEMA_QRYHANDLE, '\0' });
+ mcd_query_cmds_table[cmd_number] = query_reset_c;
+ cmd_number++;
+
+ MCDCmdParseEntry query_trigger = {
+ .handler = handle_query_trigger,
+ .cmd = QUERY_ARG_TRIGGER,
+ };
+ mcd_query_cmds_table[cmd_number] = query_trigger;
+ cmd_number++;
MCDCmdParseEntry query_state = {
.handler = handle_query_state,
@@ -1001,6 +1022,44 @@ void handle_open_core(GArray *params, void *user_ctx)
}
}
+void handle_query_reset_f(GArray *params, void *user_ctx)
+{
+ /* 1. check length */
+ int nb_resets = mcdserver_state.resets->len;
+ if (nb_resets == 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);
+ }
+ /* 2. send data */
+ mcd_reset_st reset = g_array_index(mcdserver_state.resets, mcd_reset_st,
0);
+ g_string_append_printf(mcdserver_state.str_buf, "%s=%s.%s=%u.",
+ TCP_ARGUMENT_NAME, reset.name, TCP_ARGUMENT_ID, reset.id);
+ mcd_put_strbuf();
+}
+
+void handle_query_reset_c(GArray *params, void *user_ctx)
+{
+ /* reset options are the same for every cpu! */
+ uint32_t query_index = get_param(params, 0)->query_handle;
+
+ /* 1. check weather this was the last mem space */
+ int nb_groups = mcdserver_state.resets->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);
+ }
+
+ /* 2. send data */
+ mcd_reset_st reset = g_array_index(mcdserver_state.resets,
+ mcd_reset_st, query_index);
+ g_string_append_printf(mcdserver_state.str_buf, "%s=%s.%s=%u.",
+ TCP_ARGUMENT_NAME, reset.name, TCP_ARGUMENT_ID, reset.id);
+ mcd_put_strbuf();
+}
void handle_close_core(GArray *params, void *user_ctx)
{
@@ -1047,3 +1106,13 @@ void handle_close_server(GArray *params, void *user_ctx)
}
}
+void handle_query_trigger(GArray *params, void *user_ctx)
+{
+ mcd_trigger_into_st trigger = mcdserver_state.trigger;
+ g_string_printf(mcdserver_state.str_buf, "%s=%u.%s=%s.%s=%s.%s=%s.",
+ TCP_ARGUMENT_AMOUNT_TRIGGER, trigger.nr_trigger,
+ TCP_ARGUMENT_TYPE, trigger.type,
+ TCP_ARGUMENT_OPTION, trigger.option,
+ TCP_ARGUMENT_ACTION, trigger.action);
+ mcd_put_strbuf();
+}
--
2.34.1
- [PATCH v3 07/20] mcdstub: quitting QEMU via mcd command added, (continued)
- [PATCH v3 07/20] mcdstub: quitting QEMU via mcd command added, Nicolas Eder, 2023/11/07
- [PATCH v3 10/20] mcdstub: state query added: this query collects information about the state of a specific core. This commit also includes mcd_vm_state_change, which is called when the cpu state changes because it collects data for the query, Nicolas Eder, 2023/11/07
- [PATCH v3 09/20] mcdstub: open/close core added. This includes core specific data preparation: memory spaces, register groups and registers. This data preparation is done in the arm mcdstub, Nicolas Eder, 2023/11/07
- [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 <=
- [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, 2023/11/07
- [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