From patchwork Thu Mar 2 19:08:28 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: 658124 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp64679wrb; Thu, 2 Mar 2023 11:09:58 -0800 (PST) X-Google-Smtp-Source: AK7set91sfNdGg7SjCtf8+DAoyPr051WNBjvG0EaDlNgBcYJrOZOFkZg74/Xbs5moCr95KTnyXyH X-Received: by 2002:a05:622a:5cf:b0:3bf:d5e4:308c with SMTP id d15-20020a05622a05cf00b003bfd5e4308cmr19641359qtb.46.1677784198652; Thu, 02 Mar 2023 11:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677784198; cv=none; d=google.com; s=arc-20160816; b=MNWLYgcOFI39hu50rJgm+l34T53dlJuNZc6Q7L/WvVCCOOeS0gkIkRNRQiVajxYIi4 91//pGrrn2un8fip0Ji4vaKzrYrIoDfOafOLOaSLB2pfFBJlsVrXDjzV7JcAw1bkaJwZ KbSnkeMEUrQ4YU/WLQG95mIA1hzGf2wXmFuLmY+k2AgPZYoI0+s6yjuLjXMi1lOML0A+ FcoQHgXthz29fHnJrYKyCuw+FJwCd2hPbHsZEQlPHkZ0Gz6CxfDE5/oMl0sK4fWk72w8 26ZmpwkD028mAAvRjPaTWwDNsDWOtJrCe54U8bo99Dv7fr5IF0yFloh0a1uVe0X+n8S5 oK4g== 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=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=gVULV534K4iVA1eM5JtcsbQk566qbPWu0PlOLI8QFmpRuvC8cRa0NvBUIn8Yjdlm/j Ynd2R5/JdvafkJZsATcPNkdL5aRg7gtX8kYAedqdMpO3Zdu9Wa56ZPZBQtnfCHX5tLKV s9b/A++r8Oggguh+uKATi50PdD+1S2P40XLuwnSwKyZxDp0mvISszJPMi3kCoLGWb8qf A9YmlJNEOdBuSwlJmqLpPBVK0XlrZC5f5iSXqbFYBIoFJP/H6T7KolIIRHluO4BzdYq0 p6C+2w2wFkKjT+nZ3Jd9mgZqqE48APlGXL/6tIvz8dQ9cNqfj3bTnAouflfQAZ8OwVXC Dj3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fv7CdPJT; 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 m1-20020ac85b01000000b003b68aef3869si201978qtw.663.2023.03.02.11.09.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 11:09: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=fv7CdPJT; 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 1pXoIb-0007Un-MT; Thu, 02 Mar 2023 14:09:05 -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 1pXoIZ-0007Rz-Vm for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:04 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIO-0004X5-Du for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:03 -0500 Received: by mail-wr1-x42a.google.com with SMTP id l25so148509wrb.3 for ; Thu, 02 Mar 2023 11:08:52 -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=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=fv7CdPJTK9CJaeTbeeSsek2LKFF9kpjrFZaRix6juRaohfp3SLvfs3Ggy602Up+h22 rM2xGkf/oXZa4xPJz1dMsS/9nSu4BO2fUaLutGMQQZBJacAaysZ9yjQaij8vg+rbctxQ Q5MnIaXHSg9UzOK0B53f4LSbOxoFhEJqE/JrC9ChRXQiO2ZQZ+9DU+Xq0CMEbWfA2HBB Kxe50BtD8Df5BZeNZ2RrVKItDRm/fhDLrIk6vt0R20H34+d4SvBadDANJHcqLzxkCqCV kc70xW8lcrMlG6QToYS7BYHHbJOq+m1tQBnEwCkuHs+ArsDP3CmduWv/bJKuT+1ibyy2 VQXg== 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=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=Pu9gHPLmSlLcA0/pxf657aZ2jFtyXrEUzhXbX05Ns2ljqBM4IMVOycZqOvm+OzLn1I /qqrqu72Cl8uGr9qWRH3Jd+6PEODDKNCvNbaNYMPI1UOEiar2dkoF2IBIGj/UMbXwSOi nC/+tcHlbFcd6R7hZn0nvWVNaI277lqW1s4g+jEgJUYcsTAPjLSI41eG48Fg0vaEWi3Y kKITxOk+HM6T20qPMkgbG+I+KIPB7zOPa4TZjLATJAHAyjcfNeOnoEr20INrvMFPR+D0 5xvPLhgosEfORzsnZw+e9Nk75jCOIJIwRJl9WQHrsHXFI7wqaDyPL+epsDy3ydxbsEi8 gnAQ== X-Gm-Message-State: AO0yUKVy522BrH9D0y2Z+eXe7ivOzXzHfB0fEEfXthgLeYtHXNtajvsx 1AbA6AjdoK/7niHGfbI0HxT8fQ== X-Received: by 2002:a5d:604b:0:b0:2c7:faf:af32 with SMTP id j11-20020a5d604b000000b002c70fafaf32mr7953987wrt.14.1677784131052; Thu, 02 Mar 2023 11:08:51 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r4-20020a5d4944000000b002c56013c07fsm114369wrs.109.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 941401FFB7; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Palmer Dabbelt , Laurent Vivier , nicolas.eder@lauterbach.com, Ilya Leoshkevich , kvm@vger.kernel.org, "Edgar E. Iglesias" , David Gibson , Max Filippov , Sunil Muthuswamy , qemu-s390x@nongnu.org, Stafford Horne , Bin Meng , Marek Vasut , Greg Kurz , Song Gao , Aleksandar Rikalo , Liu Zhiwei , Alistair Francis , Chris Wulff , qemu-riscv@nongnu.org, Michael Rolnik , qemu-arm@nongnu.org, Cleber Rosa , Artyom Tarasenko , Marcel Apfelbaum , Eduardo Habkost , Yoshinori Sato , Alexandre Iooss , Daniel Henrique Barboza , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , mads@ynddal.dk, Mark Cave-Ayland , qemu-ppc@nongnu.org, Richard Henderson , John Snow , Xiaojuan Yang , Thomas Huth , Paolo Bonzini , Mahmoud Mandour , Aurelien Jarno , Bastian Koppelmann , Yanan Wang , David Hildenbrand , Taylor Simpson , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 08/26] gdbstub: move fromhex/tohex routines to internals Date: Thu, 2 Mar 2023 19:08:28 +0000 Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302190846.2593720-1-alex.bennee@linaro.org> References: <20230302190846.2593720-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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 32daaf73a3..b4620f99c4 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -57,6 +57,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 abb1777e73..ba46ed73b3 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) {