From nobody Mon Feb 9 14:15:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677020062; cv=none; d=zohomail.com; s=zohoarc; b=Ew8jjrwd5Szt8MXnGj9Zt0PJ68ayXOVp4Rq34X+jSXfiyvaCLYlmO1XM7IXsk46bLFNrV0TekRvp+ELipL0EEumDfv4MPyjDuI/TUItWRL5foxokirA8Auv7e7b6PiegWMgKvXXrP0GnsJDpz9dnlkm5FYujufdyF2+auznyWIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677020062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JFc0w+Wapn0g+MU5vOsVkVSGetdAkH4dzviTgEpyCGU=; b=ajFoUA7KRe/7k0Vkq5xUHlNqvajXKgreT5OawRLzbnHG1mhJRFiSGYBtUcCl9NAOFXbvKoh6X3siFH/LSPXYqK4hWm2iQeTC/r497xJxsMER9WjlS6SyCfCF2DRm+d21nXcDEOgDC01+o9EZI+8fufzKjYjzG3IHGODdxC+Ehbg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167702006259351.882743437053136; Tue, 21 Feb 2023 14:54:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUbVG-0007XI-Eq; Tue, 21 Feb 2023 17:52:54 -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 1pUbV6-0007NU-2L for qemu-devel@nongnu.org; Tue, 21 Feb 2023 17:52:44 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUbUw-000460-0V for qemu-devel@nongnu.org; Tue, 21 Feb 2023 17:52:43 -0500 Received: by mail-wr1-x434.google.com with SMTP id bo30so5468204wrb.0 for ; Tue, 21 Feb 2023 14:52:33 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t3-20020a5d4603000000b002bfd524255esm5807542wrq.43.2023.02.21.14.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 14:52:31 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2B2291FFB7; Tue, 21 Feb 2023 22:52:28 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JFc0w+Wapn0g+MU5vOsVkVSGetdAkH4dzviTgEpyCGU=; b=QZtRi94IRGvKdonD3rmSOlDZghkfwQWsjYeVFyDWXw5ADKQRlESp7ycSy+QiMpRR05 ape7Gd54vw9WQqA0HLhvpbloN8lA5Fo5zWB5xZvTxv86nkAgco0/g4r8bpjbPfOGVFFl pLtOlhyMEOXsbsMcQDyP/6xhHQ/KF68o7YERx/tONCH5uVGIvEzHcN5bCexc3JhCMHex BiCNtfGMEUA2HVQyIpRD/PikCxnTrMSxq4b2dChvLM++uTPxlDZobeOrujY4RgOzClqM 7oZPVahEQL8F6EnWkLXM9o57gzh/C1waqCsdvihuJ8sF9tNRdKNKztdoecPwMjmGkcxk Bjdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JFc0w+Wapn0g+MU5vOsVkVSGetdAkH4dzviTgEpyCGU=; b=VI2qf58B0YMlx2D6+w1roQEjcm4F9tXEscK5M/4fFxrWc9w0N7SycgZwcGAFeDugX2 0Z/yXEHdXy5ffzkqCN6Wv8NzBP8e0icqiLKv3Qwk8G6eiAIofXaYa9f83KyRtrSV3W0B mFz93OEeBToI6eD1gvERI9GRj2rfCQT+b67z6Z/mkYqkSo+kUm2mED1A1rrVIx5nkYcx olUSZC3x2MWZvh2MW65HoDpo94BC8KO2stvDJZlmLdXWsOn8sU6sVx1MdDE+0/OcK+BR Rqn/MRn/1uYR+74vo7bo6i6UmxPYGfEFSyREQmvpAfiGpuwUsXEwJiqSqKKocAaaG1CI 5ygQ== X-Gm-Message-State: AO0yUKUfrEL//0cLLMcuFbjt+Jzta2qDsgxJ4Safp/J7C2VN68qYdsP2 XcmztocK8o0+13G+lh9uc0I91w== X-Google-Smtp-Source: AK7set+gNyNcW5ZSNqKH/Nk3AXy3bDIRs1OtMbvwutzIKewT0ynKEZkuAxdAXsLoKUt32RvcwdC/EA== X-Received: by 2002:a05:6000:1091:b0:2c5:5d11:fa52 with SMTP id y17-20020a056000109100b002c55d11fa52mr6046534wrw.15.1677019952255; Tue, 21 Feb 2023 14:52:32 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Yoshinori Sato , nicolas.eder@lauterbach.com, Stafford Horne , Daniel Henrique Barboza , Mahmoud Mandour , Taylor Simpson , mads@ynddal.dk, Marek Vasut , Artyom Tarasenko , Alistair Francis , qemu-ppc@nongnu.org, Yanan Wang , Sunil Muthuswamy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , Xiaojuan Yang , Richard Henderson , Peter Maydell , Alexandre Iooss , Chris Wulff , Jiaxun Yang , David Gibson , "Edgar E. Iglesias" , Greg Kurz , David Hildenbrand , Song Gao , Ilya Leoshkevich , Max Filippov , Mark Cave-Ayland Subject: [PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals Date: Tue, 21 Feb 2023 22:52:10 +0000 Message-Id: <20230221225227.3735319-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221225227.3735319-1-alex.bennee@linaro.org> References: <20230221225227.3735319-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677020063084100005 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 Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 27 +++++++++++++++++++++++++++ gdbstub/gdbstub.c | 20 -------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index de56328a2c..6be05fac9f 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -55,6 +55,33 @@ typedef struct GDBState { int supported_sstep_flags; } GDBState; =20 + +/* + * Inline utility function, convert from int to hex and back + */ + +static inline int fromhex(int v) +{ + if (v >=3D '0' && v <=3D '9') { + return v - '0'; + } else if (v >=3D 'A' && v <=3D 'F') { + return v - 'A' + 10; + } else if (v >=3D 'a' && v <=3D '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. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index d8bf90361e..4407706aa3 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -546,26 +546,6 @@ static void put_buffer(const uint8_t *buf, int len) #endif } =20 -static inline int fromhex(int v) -{ - if (v >=3D '0' && v <=3D '9') - return v - '0'; - else if (v >=3D 'A' && v <=3D 'F') - return v - 'A' + 10; - else if (v >=3D 'a' && v <=3D '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'; -} - /* writes 2*len+1 bytes in buf */ static void memtohex(GString *buf, const uint8_t *mem, int len) { --=20 2.39.1