From patchwork Fri Feb 24 23:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 65628 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2DA4385084E for ; Fri, 24 Feb 2023 23:27:14 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by sourceware.org (Postfix) with ESMTPS id B2BFD385DC3C for ; Fri, 24 Feb 2023 23:26:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2BFD385DC3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id h14so836164wru.4 for ; Fri, 24 Feb 2023 15:26:57 -0800 (PST) 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4uBKxTnIbXl3Sjo2HgwHdbRfZ6MR0BY57P4IPmXKyBA=; b=wuFkIOoYB/u1CH1F3T5W3Zbr544OhdHfeUHivHcGvw1ornd0UwuL1bzEAXy1KLNCgf Hw9xHB7filaougIfy77IUSlrqvbdxeWVar3bbZsW5BS+utPSwXAyUGjQm8+PpbhJmW3K Pju4f/veERp8B3a7ixKLyE46HK/RSgxdxIkUAkZXuz4AISvJgX5HYYVYIIZR2S5E+X3u 1RPJzHNxLXjaolCspo4cXw6yZDiK5SftP18RN2NKYcu8j4CRFwZ+dRNXr2Bg9JNBFFYS 8pzNgJb28WNBXVEXw07y+uytCyNdqWj5623ONp5n7ngmMMkj4gXlGd/udJ/occJ/wjmK 4OkQ== X-Gm-Message-State: AO0yUKXXZZHrdKPB0hmqn/A0XVseHC+vxOxfxz3L+a/WvBT92rVwb4jL Pagxyur2nnCtEoT6gQy8nZxzh+Qc+JMhTg== X-Google-Smtp-Source: AK7set8jylid2LEvPvxPd6lQRc22mfddUg+Y3kVDsN5xUdplbTSpw87Jk4E5YZ8JcLuFqb1AIwkGuw== X-Received: by 2002:a05:6000:1819:b0:2c7:17a4:4ece with SMTP id m25-20020a056000181900b002c717a44ecemr4415891wrh.26.1677281215705; Fri, 24 Feb 2023 15:26:55 -0800 (PST) Received: from localhost ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id l17-20020a5d6691000000b002c54e26bca5sm137759wru.49.2023.02.24.15.26.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Feb 2023 15:26:54 -0800 (PST) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Autogenerate gdb/syscalls/linux-defaults.xml.in (groups) from strace sources Date: Fri, 24 Feb 2023 23:26:49 +0000 Message-Id: <20230224232650.4031472-2-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20230224232650.4031472-1-pedro@palves.net> References: <20230224232650.4031472-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that "catch syscall group:process" doesn't catch clone3, while it does catch clone. The catch syscall group information is recorded in the gdb/syscalls/linux-defaults.xml.in file, which says: So I looked at the strace sources, to confirm that clone3 is in fact recorded in the "process" group there too, and to check what other syscalls might be missing groups. After some digging, I found that strace records the group info in C arrays, with entries like: ... [ 61] = { 4, TP, SEN(wait4), "wait4" }, [ 62] = { 2, TS|TP, SEN(kill), "kill" }, [ 63] = { 1, 0, SEN(uname), "uname" }, ... You can see the current master's table for Linux x86-64 here: https://github.com/strace/strace/blob/e88e5e9ae6da68f22d15f9be3193b1412ac9aa02/src/linux/x86_64/syscallent.h The column with TS|TP above is what defines each syscall's groups. So I wrote a script that extracts this information and generates linux-defaults.xml.in. Change-Id: I679d59d42fb2a914bf7a99e4c558e9696e5adff1 --- gdb/syscalls/update-linux-defaults.sh | 95 +++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 gdb/syscalls/update-linux-defaults.sh diff --git a/gdb/syscalls/update-linux-defaults.sh b/gdb/syscalls/update-linux-defaults.sh new file mode 100755 index 00000000000..2c001aa3b8a --- /dev/null +++ b/gdb/syscalls/update-linux-defaults.sh @@ -0,0 +1,95 @@ +#!/bin/sh + +# Copyright (C) 2023 Free Software Foundation, Inc. +# +# This file is part of GDB. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Used to generate linux-defaults.xml.in, like so: +# $ ./update-linux-defaults.sh ~/strace.git + +if [ $# -lt 1 ]; then + echo "dir argument needed" + exit 1 +fi + +d="$1" +shift + +if [ ! -d "$d" ]; then + echo "cannot find $d" + exit 1 +fi + +pre () +{ + f="$1" + + year=$(date +%Y) + + cat < + + + +EOF + + echo '' +} + + +post () +{ + echo '' +} + +generate () +{ + f="$1" + + pre "$f" + + grep -rn -E "T[A-Z][,|]" "$d/src/linux/" \ + | sed -e 's/\(T[A-Z][,|].*\)/\x03&/' -e 's/.*\x03//' \ + -e 's/,[ \t]*SEN[ \t]*(/, SEN(/g' \ + | grep ", SEN(" \ + | sed -e 's/\(.*\"\).*/\1/g' \ + -e 's/#64\"/\"/g' \ + | awk '{print $3 " " $1}' \ + | sort -u \ + | sed -e 's/|/,/g' \ + -e 's/TD,/descriptor,/g' \ + -e 's/TF,/file,/g' \ + -e 's/TI,/ipc,/g' \ + -e 's/TM,/memory,/g' \ + -e 's/TN,/network,/g' \ + -e 's/TP,/process,/g' \ + -e 's/TS,/signal,/g' \ + -e 's/[A-Z]\+,//g' \ + | grep -v '" $' \ + | sed 's/,$//g' \ + | awk "{printf \" \n\", \$1, \$2}" + + post +} + +f=linux-defaults.xml.in + +echo "Generating $f" +generate "$t" > "$f"