From patchwork Tue Feb 21 22:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 655381 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp370327wrb; Tue, 21 Feb 2023 14:54:22 -0800 (PST) X-Google-Smtp-Source: AK7set8DmrTtYoYlCh8NzK+XTScqwf0CxUeNTGU2ohqcMSQ+4+IXD96R9vln2UvvkNK+k6bMYucW X-Received: by 2002:a05:6214:2508:b0:56f:8a99:1a7a with SMTP id gf8-20020a056214250800b0056f8a991a7amr10359295qvb.23.1677020062090; Tue, 21 Feb 2023 14:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677020062; cv=none; d=google.com; s=arc-20160816; b=wGq5zK2dNUS1vuy9PM64LRIA16GKTAUjGSVacKpBYa2bEgzQZn1Dvp5Df/9PR840Hl qEHZD9wX7aOXSkN2Cg0pPKfDx3F9zra8ypdD7nJkAMTfGWg1ogpauNQugIxGTMAOXlRH 6LLNcMqxZ0YWAUtcWn3aFu4N4jcS2zQ/0TWB77i4e+jQmz+7uHhWaeiVUB73YZAel0YV TJ0pPlK49NAReW6Kxu4zsQJMc2FRlJHfYvH865OcdiIU+TjA4ANmnBRVIN8gvV2eHv8l qpNmQdmogND1jnfplSQDWu+Bb+p6p32/kFbFh35VuvJvMykvwMv2nqVPgvXiOcwzy9s9 cseg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JFc0w+Wapn0g+MU5vOsVkVSGetdAkH4dzviTgEpyCGU=; b=XKItAXP5QHkvg48LmVLS2iQB4PMq1bfs7Y5hvE9SybAVyUU66ME7obXbsaQgIH5iYM Avn2NJ+mNkvBBqQxIq8+KxmllHCxw1gBRWajE4M6TG07XQ0B7IQf+l4dF+k7bgEDB4lR GROJ8sfCCxkOOVfPTsLfNXq+m4PdeJGJnp5As35KapPC7JbeaT5Ec5y40cAtQSWPMgjo 8YNDynitRsjmY7NUoH2btoOVjjYJho7iEmtiFTyLjCST/G65S0Av4thEX+e73XMIThLU W0kTForaxZcNwGSe7m8jVevbQR0HstiDGarOHQ0neHyhn+H5A+xfBwJiDeScCrlq+Qy9 O6Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZtRi94I; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m19-20020a0cf193000000b0053226b8f7ffsi13190337qvl.83.2023.02.21.14.54.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 14:54:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QZtRi94I; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Le_Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée --- 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; + +/* + * Inline utility function, convert from int to hex and back + */ + +static inline int fromhex(int v) +{ + if (v >= '0' && v <= '9') { + return v - '0'; + } else if (v >= 'A' && v <= 'F') { + return v - 'A' + 10; + } else if (v >= 'a' && v <= '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 } -static inline int fromhex(int v) -{ - if (v >= '0' && v <= '9') - return v - '0'; - else if (v >= 'A' && v <= 'F') - return v - 'A' + 10; - else if (v >= 'a' && v <= '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) {