From nobody Tue Feb 10 11:16:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1598621996; cv=none; d=zohomail.com; s=zohoarc; b=f7c8okBqwrjLow9wXwXmPb4CxCwWO2jHZuAhn+DFG2v2vgdIdOwxu9wsqWgY5vBnr6ol+gIPUcGeH8GpnQyKpiCBYclxBu/VKGGHWlBFV2IFGeTFzYEx3euecNNX8N1XEbMQvCmRPXI3SrLQ3/njrnIRgXvrKON4CQK3i5rZhEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598621996; h=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=A7V9rfLDyKL3tHmL+sq5+GvF84f2Th5Kkvj26iOF5CQ=; b=KUPE8xF+KITe4kMcw22Cl+hcCqOvUqjnPb3XJAYvpbPhJBFK/fjvyN7w7ocEvGW3sUMVXPc+v8CgBlX6+uKdmnfobc1Nos9035RPsrVDcsy8OlluWF/z5wsyPs5STrX4b4D87DUSwXR0+jjbOdrLk/LIMjgDVttAcOwaDSJTqk4= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598621996002664.407826901035; Fri, 28 Aug 2020 06:39:56 -0700 (PDT) Received: from localhost ([::1]:53554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBebh-0007nm-QT for importer@patchew.org; Fri, 28 Aug 2020 09:39:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBeZy-0003aW-7J for qemu-devel@nongnu.org; Fri, 28 Aug 2020 09:38:06 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:33647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBeZv-0007Ff-PF for qemu-devel@nongnu.org; Fri, 28 Aug 2020 09:38:05 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M91Tq-1kHj7G3K3a-006Ajc; Fri, 28 Aug 2020 15:38:01 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/18] linux-user: Add an api to print enumareted argument values with strace Date: Fri, 28 Aug 2020 15:37:42 +0200 Message-Id: <20200828133753.2622286-8-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200828133753.2622286-1-laurent@vivier.eu> References: <20200828133753.2622286-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:teg7T1ZpbtEYbF07Jalqw4AtCRvsrrgutS8qSyUTo3fL6jAeRWs dNHivROgimG4DadCM2JGOf0zNVKYAgA+PRbBGGLsJPCq5yhOG+hp0H0yg3FamX5KFKVjZ8t tW0mgdUudgG8GMX/rpDdkW3Kak8OfAsPgqXUGmcfGnTvKkT8jIiPgPtLcKE9W+Yj4p0EPiy 70m1dpr9JQmDiCHbVUyuQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:JZNyc35OxHk=:ZbQt2dDPnLBlsF32uoNs4/ 5NHGiksm2mh15ezsusLeBDxBirdkkP+LKFLGHdZTLYBU6jaXGJieOzKENf1R2WZTMnJquS492 HLL9PsyvSzruJpJaYmJqwRz+gVOinwEtkgVVLiY4yR2EDEdXHHMM7cgGvc+tHEcBs2N1hgk9t uBvHYuT4uzk/iV6Jbk1OOqLcRnpgbomWaQIe/n/9CBquPhdG0GtM1VCKcUZ08sNKy9Nl7LDY9 vqTTNyf8u6ICOtC8p5FMS1hKMxSw/GzpPqUmRQ8INV5rJXUqO+fMr6nodL1/DI4w1hSa3TvKq F4n1dT8APDMl0aflB7uI4M1cp9uemGo6QhVf03NOFQ7yRvyUYHmekzkjawaLvJpXTkUD0njvZ R48FAlrJxhj+gv53saClul9QC1uEBLWTP3oPCsq6n9IZqmW7ETMogeF5bb9MspNDT8++xNgpk 8yLj5svdvl+eRR0V0cSzxBkuw/dBzxiQjKp/a44z++jkPWO+fR/myTspRJlXvnAKXPchq9Xw8 Lx0CyM0Qe31GMcyBJFxR4aJ3RM0GbvqYNJkYYRmpBX6WxqPUmWNZHx89wavBBVCEEHFPs3PhO 4wmKBPpMNoa2+wPsFi7y3UaoMJDUYJxns2N2MxKs0J9+M86rd5ZgsLFzfrqdxih47X4CuUaNF h289ma7FKvDDQX69cuOusL8IdfHUBnUR+qvBmGzp8sVoZEi95D/NnAK+OQeI8wvdf5sigBT9n dPdDETQqtGDYrfCh/Lex903+bDnoTzUeEK1XR2BemrXM5D3ZgMKxsqPtU1Cg4YgbaTNGnIdEN lm4ltXLPiBoagl1Noh2dxayV/D0uXCw6v9l/moe8IlKXm1J8dcR1veVXSdUAe3NrNhknyDM 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: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/28 09:38:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Filip Bozuta This patch introduces a type 'struct enums' and function 'print_enums()' that can be used to print enumerated argument values of some syscalls in strace. This can be used in future strace implementations. Also, macros 'ENUM_GENERIC()', 'ENUM_TARGET()' and 'ENUM_END', are introduced to enable automatic generation of aproppriate enumarated values and their repsective string representations (these macros are exactly the same as 'FLAG_GENERIC()', 'FLAG_TARGET()' and 'FLAG_END'). Future patches are planned to modify all existing print functions in 'strace.c' that print arguments of syscalls with enumerated values to use this new api. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <20200811164553.27713-5-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/strace.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index 4ac54ecffe9c..d0731b888d29 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -52,9 +52,23 @@ struct flags { /* end of flags array */ #define FLAG_END { 0, NULL } =20 +/* Structure used to translate enumerated values into strings */ +struct enums { + abi_long e_value; /* enum value */ + const char *e_string; /* stringified enum */ +}; + +/* common enums for all architectures */ +#define ENUM_GENERIC(name) { name, #name } +/* target specific enums */ +#define ENUM_TARGET(name) { TARGET_ ## name, #name } +/* end of enums array */ +#define ENUM_END { 0, NULL } + UNUSED static const char *get_comma(int); UNUSED static void print_pointer(abi_long, int); UNUSED static void print_flags(const struct flags *, abi_long, int); +UNUSED static void print_enums(const struct enums *, abi_long, int); UNUSED static void print_at_dirfd(abi_long, int); UNUSED static void print_file_mode(abi_long, int); UNUSED static void print_open_flags(abi_long, int); @@ -1252,6 +1266,23 @@ print_flags(const struct flags *f, abi_long flags, i= nt last) } } =20 +static void +print_enums(const struct enums *e, abi_long enum_arg, int last) +{ + for (; e->e_string !=3D NULL; e++) { + if (e->e_value =3D=3D enum_arg) { + qemu_log("%s", e->e_string); + break; + } + } + + if (e->e_string =3D=3D NULL) { + qemu_log("%#x", (unsigned int)enum_arg); + } + + qemu_log("%s", get_comma(last)); +} + static void print_at_dirfd(abi_long dirfd, int last) { --=20 2.26.2