From patchwork Thu Jan 5 16:43:07 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: 639268 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp320486pvb; Thu, 5 Jan 2023 08:43:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOGVX+FqPGLeKrDAvsb5Jntfc3h65zfK/MqPZnDcyFSKGrwXqS1wkhdbAfiAVr/Az4mH1P X-Received: by 2002:a05:622a:1e14:b0:3ab:ceb9:10fd with SMTP id br20-20020a05622a1e1400b003abceb910fdmr3872265qtb.25.1672937038828; Thu, 05 Jan 2023 08:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672937038; cv=none; d=google.com; s=arc-20160816; b=b2pH0URGlWSedKyhazJpW+pNgUrE1+V0hmAfgexOzN4A/DGwj0OKtcSPEfKqczQvnG kHE17L/N6134lpsbYPjyq8fJzYXWIstlV1fXvNuzLOSWoUHBumXn/Yf6yJaQ8RXcBARh LoLE00X6kA4CVF1CAVfPwP6oSAEVXXRE0g7+jeu0rONmpAuNfS6H6h7GEMgRFsjJvaqQ D81QS5MngywwD6pbxSKipf8pxhEASggSvhj8xAGgDt+zgxdoHTR/q0JNPG2d7aGqv2YX 6vCYrAQyvSIIVX/FwO9Y7v80IDGjJ6CFumOANnu9AeirB/gerj63ehy5IlZdylp4y4u0 vCKw== 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=EerVrIzCjfEKyD8t5zQfya8CKSRP1ftyfpksI7gVAwM=; b=GSk8A3m/mz4dxakjLlWvBD0LUY+lETzBFDBs7Zm+y4DxI33IVm5hBIZhWhi3LIMF/i jvPLl3od7yFBljeNRSTaUW6ulft4ZRunUaJRQIHJJNadmfEske/cOacohbIXSho7mx7O HSjDA8/uiMPfRn+XgLhjsRILFQwS5BKa0SGb3r6WZmqCG3VJCSDVyELV51+qKgZfYNin yTUK9Q2cHNHTyDQJPv4nNNBv0SFs10sW9xUqbt35iWP9g4L4ZFH68oYL60pXeiH1c1Gm 3+lSbtlKZ9Vr1NcnvhznMrTlupKQQPYlrKTqBGnWhKiT47MBariiH/dLxBm39rJl344A 1glQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CxU5F4Hj; 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 ff13-20020a05622a4d8d00b0039cdeacc6cbsi20420755qtb.120.2023.01.05.08.43.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 08:43:58 -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=CxU5F4Hj; 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 1pDTLB-0007Au-Jj; Thu, 05 Jan 2023 11:43:41 -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 1pDTL8-00075S-CR for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:38 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTKw-0006yx-S4 for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:38 -0500 Received: by mail-wm1-x331.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so1777088wms.2 for ; Thu, 05 Jan 2023 08:43:26 -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=EerVrIzCjfEKyD8t5zQfya8CKSRP1ftyfpksI7gVAwM=; b=CxU5F4HjJ+2g0oQG+sF5FcV4SezpLQEE9xea3C4OjSkIjoctUdqXTkxRiSJt3hJq5O 5LPhjmugtEYEMBt/hVNBB6EjDBDkBDonmuRlxL67Zn3sf0WGX4XmglPhwxgaVTpOTopr y8xQZO0hzRiSzEJgf7NMQH7sQLuBhoobKqA1QoRiDdzCOXn9fJEvZoJuJhd/RwBYZuND giaHlkx9qzC/xFzAI7mL6WfvJA4EhzOCjHtoQeuUSIytBlC4Ydzj0TauVNjIey5M32Az GEQ8u13b1GVPSu06SWg1Tdlh1rBy7GFMTpwXZe9S5pUXL+2c+r/eoAACtSfDOHrHdMfx NpPg== 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=EerVrIzCjfEKyD8t5zQfya8CKSRP1ftyfpksI7gVAwM=; b=dJ6j5jeefOz9rBH5qPSTpHLQN/04KR003RcQL0yhG4JiPxa3DDK7XotY78EhvdkYN5 yzUh/e/si+YyDKnxQh3sjMApmCFu0SZHvHIXHSu+8YGuXzYPkKO07LouS/Vn0wxsdIrB joywMPGZcBIRdI9a9ayHW1wkuQwDRnOveSChWOkdxRwg4DKn8CLRP3zNZpsNmA3HR5Bz iJBgMuGJYLpeDrFF4E3AC19zDrZhz4/lSu0cXND8kJ3rWRD3BJmg9w7vOAq6e3tcobZw MIAEC2KDoSby9Fn3BTx7OmOmTssgk43S5r0nrRuAzULeEfTM+ykZyio82eLdhCc15dT1 7z6Q== X-Gm-Message-State: AFqh2krL8195xjiyvy2no5J3r+Y8CSQyJ4jaPyrd3IG5K08zp4yQ2Ty2 fqNWaaEqkK3FEhMId4yU3TzoFQ== X-Received: by 2002:a05:600c:b4d:b0:3d3:5d69:7aa5 with SMTP id k13-20020a05600c0b4d00b003d35d697aa5mr35344276wmr.25.1672937005143; Thu, 05 Jan 2023 08:43:25 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n14-20020a05600c3b8e00b003b49bd61b19sm3366476wms.15.2023.01.05.08.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:43:22 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D77B01FFC0; Thu, 5 Jan 2023 16:43:20 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org, alex.bennee@gmail.com Cc: David Hildenbrand , Sunil Muthuswamy , Aurelien Jarno , Michael Rolnik , Aleksandar Rikalo , Greg Kurz , Ilya Leoshkevich , Thomas Huth , qemu-ppc@nongnu.org, Laurent Vivier , Max Filippov , Yanan Wang , Marek Vasut , Stafford Horne , Peter Maydell , Daniel Henrique Barboza , Palmer Dabbelt , =?utf-8?q?Alex_Benn=C3=A9e?= , Taylor Simpson , Marcel Apfelbaum , Alexandre Iooss , Chris Wulff , Richard Henderson , Eduardo Habkost , Song Gao , Mark Cave-Ayland , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , Artyom Tarasenko , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Alistair Francis , "Edgar E. Iglesias" , Bastian Koppelmann , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Bin Meng , Mahmoud Mandour , David Gibson , Yoshinori Sato , Xiaojuan Yang , qemu-arm@nongnu.org Subject: [PATCH v2 08/21] gdbstub: move fromhex/tohex routines to internals Date: Thu, 5 Jan 2023 16:43:07 +0000 Message-Id: <20230105164320.2164095-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230105164320.2164095-1-alex.bennee@linaro.org> References: <20230105164320.2164095-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- 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 9784db2dc5..c8bb85cf34 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -74,6 +74,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 92b2f5c3db..d4ee23b51c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -531,26 +531,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) {