From nobody Tue Feb 10 01:35:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699362380153833.7408253195417; Tue, 7 Nov 2023 05:06:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0Lm9-0001qM-Gj; Tue, 07 Nov 2023 08:05:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0Lko-0008KI-LT for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:04:28 -0500 Received: from smtp1.lauterbach.com ([62.154.241.196]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0Lkg-000602-DK for qemu-devel@nongnu.org; Tue, 07 Nov 2023 08:04:25 -0500 Received: (qmail 31271 invoked by uid 484); 7 Nov 2023 13:04:01 -0000 Received: from nedpc1.intern.lauterbach.com (Authenticated_SSL:neder@[10.2.11.92]) (envelope-sender ) by smtp1.lauterbach.com (qmail-ldap-1.03) with TLS_AES_256_GCM_SHA384 encrypted SMTP for ; 7 Nov 2023 13:03:59 -0000 X-Qmail-Scanner-Diagnostics: from nedpc1.intern.lauterbach.com by smtp1.lauterbach.com (envelope-from , uid 484) with qmail-scanner-2.11 (mhr: 1.0. clamdscan: 0.99/21437. spamassassin: 3.4.0. Clear:RC:1(10.2.11.92):. Processed in 0.071439 secs); 07 Nov 2023 13:04:01 -0000 From: Nicolas Eder To: qemu-devel@nongnu.org Cc: "Nicolas Eder" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Christian Boenig" Subject: [PATCH v3 12/20] mcdstub: missing parse_reg_xml function for parsing gdb register xml files added Date: Tue, 7 Nov 2023 14:03:15 +0100 Message-Id: <20231107130323.4126-13-nicolas.eder@lauterbach.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231107130323.4126-1-nicolas.eder@lauterbach.com> References: <20231107130323.4126-1-nicolas.eder@lauterbach.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Qmail-Scanner-2.11: added fake Content-Type header Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=62.154.241.196; envelope-from=nicolas.eder@lauterbach.com; helo=smtp1.lauterbach.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1699362381722100001 Content-Type: text/plain; charset="utf-8" --- mcdstub/mcdstub.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/mcdstub/mcdstub.c b/mcdstub/mcdstub.c index d71dff633a..3e87378b45 100644 --- a/mcdstub/mcdstub.c +++ b/mcdstub/mcdstub.c @@ -867,6 +867,127 @@ CPUState *find_cpu(uint32_t thread_id) } =20 =20 +void parse_reg_xml(const char *xml, int size, GArray *registers, + uint8_t reg_type, uint32_t reg_id_offset) +{ + /* iterates over the complete xml file */ + int i, j; + uint32_t current_reg_id =3D reg_id_offset; + uint32_t internal_id; + int still_to_skip =3D 0; + char argument[64] =3D {0}; + char value[64] =3D {0}; + bool is_reg =3D false; + bool is_argument =3D false; + bool is_value =3D false; + GArray *reg_data; + + char c; + char *c_ptr; + + xml_attrib attribute_j; + const char *argument_j; + const char *value_j; + + for (i =3D 0; i < size; i++) { + c =3D xml[i]; + c_ptr =3D &c; + + if (still_to_skip > 0) { + /* skip unwanted chars */ + still_to_skip--; + continue; + } + + if (strncmp(&xml[i], "", 2) =3D=3D 0) { + /* end of register info */ + still_to_skip =3D 1; + is_reg =3D false; + + /* create empty register */ + mcd_reg_st my_register =3D (const struct mcd_reg_st){ 0 }; + + /* add found attribtues */ + for (j =3D 0; j < reg_data->len; j++) { + attribute_j =3D g_array_index(reg_data, xml_attrib, j); + + argument_j =3D attribute_j.argument; + value_j =3D attribute_j.value; + + if (strcmp(argument_j, "name") =3D=3D 0) { + strcpy(my_register.name, value_j); + } else if (strcmp(argument_j, "regnum") =3D=3D 0) { + my_register.id =3D atoi(value_j); + } else if (strcmp(argument_j, "bitsize") =3D=3D 0) { + my_register.bitsize =3D atoi(value_j); + } else if (strcmp(argument_j, "type") =3D=3D 0) { + strcpy(my_register.type, value_j); + } else if (strcmp(argument_j, "group") =3D=3D 0) { + strcpy(my_register.group, value_j); + } + } + /* add reg_type, internal_id and id*/ + my_register.reg_type =3D reg_type; + my_register.internal_id =3D internal_id; + internal_id++; + if (!my_register.id) { + my_register.id =3D current_reg_id; + current_reg_id++; + } else { + /* set correct ID for the next register */ + current_reg_id =3D my_register.id + 1; + } + /* store register */ + g_array_append_vals(registers, (gconstpointer)&my_register= , 1); + /* free memory */ + g_array_free(reg_data, false); + } else { + /* store info for register */ + switch (c) { + case ' ': + break; + case '=3D': + is_argument =3D false; + break; + case '"': + if (is_value) { + /* end of value reached */ + is_value =3D false; + /* store arg-val combo */ + xml_attrib current_attribute; + strcpy(current_attribute.argument, argument); + strcpy(current_attribute.value, value); + g_array_append_vals(reg_data, + (gconstpointer)¤t_attribute, 1); + memset(argument, 0, sizeof(argument)); + memset(value, 0, sizeof(value)); + } else { + /*start of value */ + is_value =3D true; + } + break; + default: + if (is_argument) { + strncat(argument, c_ptr, 1); + } else if (is_value) { + strncat(value, c_ptr, 1); + } else { + is_argument =3D true; + strncat(argument, c_ptr, 1); + } + break; + } + } + } + } +} + int int_cmp(gconstpointer a, gconstpointer b) { int int_a =3D *(int *)a; --=20 2.34.1