From patchwork Fri Mar 3 02:57:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658443 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225163wrb; Thu, 2 Mar 2023 18:58:41 -0800 (PST) X-Google-Smtp-Source: AK7set/lmJ2efjeuiXcaastTnWXcHTJZaJOGoEfu+GTK//nRKwUZWvmQ2hM4MQGl4PvpURS86TF4 X-Received: by 2002:a05:6214:2a46:b0:56b:79fa:e6d9 with SMTP id jf6-20020a0562142a4600b0056b79fae6d9mr715722qvb.31.1677812321582; Thu, 02 Mar 2023 18:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812321; cv=none; d=google.com; s=arc-20160816; b=GRU91Ye1Lq84vcT2mrInn9yx3ubcQSpZTk+NZ8tWQlB3jlkbwbZssv3docWHgDYrVp wd0iAhOmS8lqDuAUfo4Q3kqPa884u6BJIXd9j/U9VSz/eHacHj6lT8XmJDGNTfXULlfK +6AN/I3hIMqfvNHMGnQXZSR7ZKLrJ6JmuOl5PH5qZCoNHzp/ulieVOv2poyIYi5P+jV9 jY/C+SmGkY06YQw8ikm6VPtxO68vlEEeEtF2oHND6FLEapq0WRxPvTJ7+r4SgVTNDdzk IkPP4lHUrYEt2v609LVwK90aqaz78tfHSIpkK7hNFPv5+WENLUJjFWkU8Kvl0v9ePoB9 ZDtQ== 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=oyetBuVHUOfnAjdQZE3Kw0yqpOK6LZBVb4ZSB9EDZrj0NuVLXDsTgpB69Uay33OoRB lZMFrVUu+kLyhhd2srGeHJ5j72n65CjXN/dEdktNBpCpuM2x7kt70nHwdixHmfl2sFl1 KC6l9Y/BrlL0QyEi50snRG526UJVOiWGOdImHseGlxsuSkG275V2ZDDncrBYvdv9heWE pkVfwHbhFisTbsuWjfB2ZUcoeuY/2tanK/jY7Zf2hUzsaay4Wpq56kf1icELUg7qrhGy +yYJIH4RBYtNEoxhQv3wpbZALlESPpwvkED3oZF+z+8pGvHVhwP9+/AQHPvyEa0U9/5B h0Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NUnIy20L; 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 k7-20020a05622a03c700b003b9b60dd798si967481qtx.761.2023.03.02.18.58.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:58:41 -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=NUnIy20L; 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 1pXvcj-0007T7-KN; Thu, 02 Mar 2023 21:58:21 -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 1pXvch-0007Rn-Lu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvce-0001mZ-Bf for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: by mail-pj1-x102b.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851598pjh.0 for ; Thu, 02 Mar 2023 18:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NUnIy20LGnEP/1vY3HMnYooszgnMBv2svb75F64iQhCevUdpJc+szWcujV3BgNfMKV E7ieC0VjgVljadSCgf8Q6Ne/mJE8E4kdo7jAdv+vxmIs17BF+e0UVnegC9ohwoCMW+8z A54S27MJpCPkd2g1Irc33pIZ99HbMBVUFofaqQKUIrKg5OM+XzoV4dbZLY1bsWhbLKlL JoANFIe4+UANDC/q5Xe4im8CmmigxbKIY9Ss9GhyKE4YmzMXs0yDMYzblQESfDGhRnEF MTGmEUZW7Tv4e9A+5rClanHWtw+JhpzAXiA5rlRdCIwNzVtXJuHUWx7BF8Aa5FqQvgiM RMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NOsG8qnL+RnJZagE8XyqJT1n/tYfAsGLMoNwDI6hYQU5UubeITaKEbogS3xcuAYjJE vEkwgHFDsKbylKavEJxfi26z2FWCixGVc5MexqbiwKetYjqFe/Yf/MVAixFVlo44ad/N 45pvLnNIMVx6jXQcx9k73MJYKmFwNMT84xj8hxvy4cgzhDUp+hQtaVvFze1wwq3o+WRv BYcpJQYCSdhKE+gDAOxCLb/+2V8blZChvMKe3Uh5+uYKcO7TZhfB+eP0WohIWJ1YZIAE pz/GbjdoTSaPVxXJikE/YMIsdn1Z00G0k7RDmiPiQeqCV7PaGgJBGxcT7Mz6B6GJ/d9U vAtw== X-Gm-Message-State: AO0yUKVQUMTn/6m7X1Vvgt1xGZ3impyTXIy+UxkqIVNRK5KJ4Do737+W dmyFJeQJuGAtzkdpwA02x0o9m69zP/8NsDAj5XM= X-Received: by 2002:a17:902:c40b:b0:19e:8bfe:7d68 with SMTP id k11-20020a170902c40b00b0019e8bfe7d68mr711206plk.11.1677812294264; Thu, 02 Mar 2023 18:58:14 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals Date: Thu, 2 Mar 2023 18:57:44 -0800 Message-Id: <20230303025805.625589-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée 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 Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org> --- 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) {