From patchwork Tue Sep 14 13:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06948C433F5 for ; Tue, 14 Sep 2021 13:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0130606A5 for ; Tue, 14 Sep 2021 13:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbhINNXK (ORCPT ); Tue, 14 Sep 2021 09:23:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXK (ORCPT ); Tue, 14 Sep 2021 09:23:10 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA8AC061762 for ; Tue, 14 Sep 2021 06:21:52 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id v24so13665445eda.3 for ; Tue, 14 Sep 2021 06:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KS8r8oY8x2kfdcoMywa4LhAV1/KUW+EnGnL0wzDkhKI=; b=czMmUvSTHBxKhv25GYY7KRqj7HNayhUzxERh9AKs79FhvBmBInBAWkUYGpK1bkSsoF R6k7iOLIjFhyXmfZfimvrMd/jU+7wO+PeFfdLtuo6Ms4wPvqYbM7nRLGryCQy75tX2Bz uVfj2yjPpdPwtSd74ENNFGrvqiMSkfqA+UMjj4YQ6Su8BuHoFxEqdbUg/ufg5U14MQBK tuxEVH+MIReTz/2Vq5JI8k4g1oVb7yunSMPePPddC6x6JfZYQshKBnm2IyzptwuberpJ /WDG9qdcj/IpIt2eZX7EFlB4lJIhPkXNAPh9MOMvp9gmqIAFFi54Uia4KG1QSRzfCj0O Ygkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KS8r8oY8x2kfdcoMywa4LhAV1/KUW+EnGnL0wzDkhKI=; b=I20Ldngi4Vru650PC2xOJlmQJs++voCEdfozYJgoJjUAJYqlKtszR4Ud1cxDeHNpCX JFZM443ou24e87wOvyBkWfh/X36usQCsbtvjVDF85Q6DECIQ9fhgX1/+powKHGYBJIA3 Y2s9vDqwrLHgGzabL9xYE1GrLiBO4sfIMT7p/WX8TBDrVBW8iYIDN6/NRY3CSMzHSuuD yBHtjgjEPRRZyy62svhOWqdpMTf2UsOafrTPKutiClPcBotkiRHqmVxrKBbr3AtYyck6 yO3PLw6Fj1Ud88gFZjasrXzNqEC8XgHWLweh1oqZvQqgikR/a9hNXtt1JsQqzF/uy1pz 2nSQ== X-Gm-Message-State: AOAM530AuJl8OiIKeDWfAn8y14adCC69lz6vlZ1oMRR0JrUKcFgdH3qT gZ2w3zd46OXaco8Y7y+DCBSKacp7Bm0= X-Google-Smtp-Source: ABdhPJyOIJnqzB6OSN5zP4tYKlPu2Jj5FALFGwdUUWEmxmK0Ap4v9pVkDT/o1ihNxRW/aBL+zShUFA== X-Received: by 2002:a50:bae1:: with SMTP id x88mr19322267ede.345.1631625711348; Tue, 14 Sep 2021 06:21:51 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:50 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 01/10] trace-cmd dump: Add helpers for processing trace file version 7 Date: Tue, 14 Sep 2021 16:21:39 +0300 Message-Id: <20210914132148.3968401-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org New global variables are added, that hold trace file context: - trace file version - compression context Also a few helper functions for reading compressed data. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 88 ++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index 2334b57e..d0278f7e 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -26,6 +26,9 @@ static struct tep_handle *tep; static unsigned int trace_cpus; static int has_clock; +static unsigned long file_version; +static bool read_compress; +static struct tracecmd_compression *compress; enum dump_items { SUMMARY = (1 << 0), @@ -52,46 +55,69 @@ enum dump_items verbosity; tracecmd_plog(fmt, ##__VA_ARGS__); \ } while (0) -static int read_file_string(int fd, char *dst, int len) +static int read_fd(int fd, char *dst, int len) { size_t size = 0; int r; do { - r = read(fd, dst+size, 1); + r = read(fd, dst+size, len); if (r > 0) { - size++; - len--; + size += r; + len -= r; } else break; - if (!dst[size - 1]) - break; - } while (r > 0 && len); + } while (r > 0); - if (!size || dst[size - 1]) + if (len) return -1; - return 0; + return size; } -static int read_file_bytes(int fd, char *dst, int len) +static int read_compressed(int fd, char *dst, int len) +{ + + if (read_compress) + return tracecmd_compress_read(compress, dst, len); + return read_fd(fd, dst, len); +} + +static int do_lseek(int fd, int offset, int whence) +{ + if (read_compress) + return tracecmd_compress_lseek(compress, offset, whence); + return lseek64(fd, offset, whence); +} + +static int read_file_string(int fd, char *dst, int len) { size_t size = 0; int r; do { - r = read(fd, dst+size, len); + r = read_compressed(fd, dst+size, 1); if (r > 0) { - size += r; - len -= r; + size++; + len--; } else break; - } while (r > 0); + if (!dst[size - 1]) + break; + } while (r > 0 && len); - if (len) + if (!size || dst[size - 1]) return -1; return 0; } +static int read_file_bytes(int fd, char *dst, int len) +{ + int ret; + + ret = read_compressed(fd, dst, len); + return ret < 0 ? ret : 0; +} + static void read_dump_string(int fd, int size, enum dump_items id) { char buf[DUMP_SIZE]; @@ -146,7 +172,6 @@ static void dump_initial_format(int fd) char magic[] = TRACECMD_MAGIC; char buf[DUMP_SIZE]; int val4; - unsigned long ver; do_print(SUMMARY, "\t[Initial format]\n"); @@ -168,11 +193,11 @@ static void dump_initial_format(int fd) die("no version string"); do_print(SUMMARY, "\t\t%s\t[Version]\n", buf); - ver = strtol(buf, NULL, 10); - if (!ver && errno) + file_version = strtol(buf, NULL, 10); + if (!file_version && errno) die("Invalid file version string %s", buf); - if (!tracecmd_is_version_supported(ver)) - die("Unsupported file version %lu", ver); + if (!tracecmd_is_version_supported(file_version)) + die("Unsupported file version %lu", file_version); /* get file endianness*/ if (read_file_bytes(fd, buf, 1)) @@ -234,6 +259,27 @@ static void dump_header_event(int fd) read_dump_string(fd, size, HEAD_EVENT); } +static void uncompress_reset(void) +{ + if (compress && file_version >= FILE_VERSION_COMPRESSION) { + read_compress = false; + tracecmd_compress_reset(compress); + } +} + +static int uncompress_block(void) +{ + int ret = 0; + + if (compress && file_version >= FILE_VERSION_COMPRESSION) { + ret = tracecmd_uncompress_block(compress); + if (!ret) + read_compress = true; + + } + return ret; +} + static void dump_ftrace_events_format(int fd) { unsigned long long size; @@ -578,7 +624,7 @@ static void dump_options(int fd) default: do_print(OPTIONS, " %d %d\t[Unknown option, size - skipping]\n", option, size); - lseek64(fd, size, SEEK_CUR); + do_lseek(fd, size, SEEK_CUR); break; } } From patchwork Tue Sep 14 13:21:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C378C433EF for ; Tue, 14 Sep 2021 13:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9FDE60F11 for ; Tue, 14 Sep 2021 13:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233143AbhINNXL (ORCPT ); Tue, 14 Sep 2021 09:23:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXL (ORCPT ); Tue, 14 Sep 2021 09:23:11 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 994B2C061574 for ; Tue, 14 Sep 2021 06:21:53 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id c22so18473833edn.12 for ; Tue, 14 Sep 2021 06:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XuGRDg06q73jbPgmeD6b8pH/4xE6jY0heKZ3XoehWA8=; b=Ns/dsRD6rb08K4Kq7e8pnBWQSA2kY0EQk1kzv9T06ItqnVjVGcza3iciWdalWlBuPY eYCUhSzbeisOPpk90fUIN/GcY+fmWL+viti6E2QSBG+XFWW4Bdpi1HJeRFuMBeZFGzlk lh1HJyGieiaPDT4NR8uk17bwEpOBKSkEPFX+KiI/bZXZ0T6vDo6KWjQak/T7/trRaaAh kaMAWnlVHZcDbNqXYcX904ixF8DDSitqL5mf4UNJFSioPp5SoMDhIrLp1gCaQ+eOFf0A 3XvIwZQfG3/gxNZfy7XLHqXGg17LHkvWsnJJoLLYRYMi5ezrlDRDrMh6/MTV5L8fQkbK TjuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XuGRDg06q73jbPgmeD6b8pH/4xE6jY0heKZ3XoehWA8=; b=2yN1Zzq3NQ+Gihrdjh5r5CocFaBvi6GEufHUGVpsgZQ9m4LdS3A6UomhtUMsetEN6Q J116VAmZleNG/AJX7gSkNIKAXarzNzWzp9+v99pjkQuMNwBYbsmY/BL/y+cpoh6k2k8R Mxp7B+Ui5/2/BE3LUCQcVf9o43PmEcJN3ePmPNFtinivqk58LFs52rs2OkTO96KE2vyv g4gmXgkZZzyjcpA9jtz22QVIVqai21XhNXogqHsd6R6eUaetTSqSLpDDLOMXWeFI59N0 BNgVeA5lKMkq7luwRhrxe/bH9LYq/bvgk/p2T5jQVcxwUxp19MmZAj7rGE98Bie9BpyG 119Q== X-Gm-Message-State: AOAM530RxViNqiwNwnPRIizCmIvriDS7pkRj+VP+RTH2z6+yyiTFEX3V SGrmUOcij0O/blCF2OFUDVj5uLfZOPk= X-Google-Smtp-Source: ABdhPJwpUlhVZpIJ350gEkL3e5q0uYjfaGemASPkxGIueRzrxXxfVgeeHhMzerxjaV0Rtne5pBbNkw== X-Received: by 2002:a05:6402:26c6:: with SMTP id x6mr19304097edd.10.1631625712209; Tue, 14 Sep 2021 06:21:52 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:51 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 02/10] trace-cmd dump: Print compression header Date: Tue, 14 Sep 2021 16:21:40 +0300 Message-Id: <20210914132148.3968401-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Dump the compression header of trace file version 7 Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index d0278f7e..3cce231f 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -217,6 +217,29 @@ static void dump_initial_format(int fd) do_print(SUMMARY, "\t\t%d\t[Page size, bytes]\n", val4); } +static void dump_compress(int fd) +{ + char zname[DUMP_SIZE]; + char zver[DUMP_SIZE]; + + if (file_version < FILE_VERSION_COMPRESSION) + return; + + /* get compression header */ + if (read_file_string(fd, zname, DUMP_SIZE)) + die("no compression header"); + if (read_file_string(fd, zver, DUMP_SIZE)) + die("no compression version"); + do_print((SUMMARY), "\t\t%s\t[Compression algorithm]\n", zname); + do_print((SUMMARY), "\t\t%s\t[Compression version]\n", zver); + + if (strcmp(zname, "none")) { + compress = tracecmd_compress_alloc(zname, zver, fd, tep, NULL); + if (!compress) + die("cannot uncompress the file"); + } +} + static void dump_header_page(int fd) { unsigned long long size; @@ -715,6 +738,7 @@ static void dump_file(const char *file) do_print(SUMMARY, "\n Tracing meta data in file %s:\n", file); dump_initial_format(fd); + dump_compress(fd); dump_header_page(fd); dump_header_event(fd); dump_ftrace_events_format(fd); From patchwork Tue Sep 14 13:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9ADC433FE for ; Tue, 14 Sep 2021 13:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A272A60F11 for ; Tue, 14 Sep 2021 13:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233145AbhINNXM (ORCPT ); Tue, 14 Sep 2021 09:23:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXL (ORCPT ); Tue, 14 Sep 2021 09:23:11 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9646AC061574 for ; Tue, 14 Sep 2021 06:21:54 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id t6so18463045edi.9 for ; Tue, 14 Sep 2021 06:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yh40ZYgMwbP81n6hFixo15LEQgbd5DixHArPEoYRm6A=; b=VN23/9iZgUlqiCK2Rj9Wi5+FHwarr/BZJJo1t36dWyebjjwQH9slUMz6IeESriLfuG l0J/NtWiIecsRQ2TZKfACiFgYVf4DRqMCaRS6jxEvGA+Mlb9WO8+WI5J3LO+1EmTWypJ QNnntkOnxybh30ETrUm4+6IPvtvOOLGagLf+eCvoiCsedQ0Dv+dr/2uahSb80UhvtMUk 50lccoxt7vDopZl/uXvoWvvOy+KBgu2Bc7q1qjrTIBeAa/O1lmDJ7kUZCb806rvK7SZw CWGc9LYLsJ8QIZOOW/LQ6RfozvCPGKgvmXf3EY7dtDFQJaOqGqlSshI2HWR8i43Z49ua hNVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yh40ZYgMwbP81n6hFixo15LEQgbd5DixHArPEoYRm6A=; b=vO7IcKpG2V8m85//90SSh1JGqfwYE6s8KV5OxZxhH1bIt2HocTv8bfp63FhrXaKZyx EJsEouS3QNzxxG6tMssCuA80iZ1+1KjFO1Jo4MJkvOOPv1LOdj/XtLLMFz8lSv7YpohJ PDukJ41JEYjt/dFpEzGzsVnhiYKjM9JfvYMI2MWdhMjrRFWlVhMNLOuOQcHjeTHEDVVz VjCNRD8TdEuKwFdkYI8c8HTekneigfQbnIFUoDTY6Vdl+0/+ZXmKBxjWl28jYgHyJkIp NKMXP9lt64RZbB4sjtxd2kleKEvD/vIRlJnSOxXJjWNM9az3ph7qrXbw9Xz+JTnUteO4 MgKQ== X-Gm-Message-State: AOAM531jTe2juzKqd9ZkCBMllbhJK4AiU6GIxFaLOyHDDntOZ56IJjL1 zjAPszmUYi6feIBaNE6yBkzRigZ3S80= X-Google-Smtp-Source: ABdhPJzmzYX1rVpyA2I/x/zYwF9T5NOlTA+pL6dc+5pfZuNsGtxR9sCPAkQzVnfEzjAKabkNWrqIcw== X-Received: by 2002:aa7:cdc8:: with SMTP id h8mr10545594edw.272.1631625713164; Tue, 14 Sep 2021 06:21:53 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:52 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 03/10] trace-cmd dump: Add helpers for processing trace file sections Date: Tue, 14 Sep 2021 16:21:41 +0300 Message-Id: <20210914132148.3968401-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Added a new local database for storing sections, found in trace file version 7. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index 3cce231f..f7284436 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -43,8 +43,18 @@ enum dump_items { OPTIONS = (1 << 9), FLYRECORD = (1 << 10), CLOCK = (1 << 11), + SECTIONS = (1 << 12), }; +struct file_section { + int id; + unsigned long long offset; + struct file_section *next; + enum dump_items verbosity; +}; + +static struct file_section *sections; + enum dump_items verbosity; #define DUMP_CHECK(X) ((X) & verbosity) @@ -723,6 +733,17 @@ static void dump_therest(int fd) } } +static void free_sections(void) +{ + struct file_section *del; + + while (sections) { + del = sections; + sections = sections->next; + free(del); + } +} + static void dump_file(const char *file) { int fd; @@ -748,7 +769,7 @@ static void dump_file(const char *file) dump_cmdlines(fd); dump_cpus_count(fd); dump_therest(fd); - + free_sections(); tep_free(tep); tep = NULL; close(fd); From patchwork Tue Sep 14 13:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C533BC433F5 for ; Tue, 14 Sep 2021 13:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A88DA60ED8 for ; Tue, 14 Sep 2021 13:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233105AbhINNXN (ORCPT ); Tue, 14 Sep 2021 09:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXM (ORCPT ); Tue, 14 Sep 2021 09:23:12 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AC55C061574 for ; Tue, 14 Sep 2021 06:21:55 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id x22so334385ejj.8 for ; Tue, 14 Sep 2021 06:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wg0a57cr/r26Fm3sybPaTjbWfq8hx070vW8oQ3zhuAQ=; b=bZ+wDUmhDWtZNgSqHzKVG7shM0gFDAtVl/x0sZzWnQguvtwHhBQgR/EGD8DNEt35pa QL9XXapCVJaoe58G7J63Z+uplk31K81Y4lgU/6GOmbmD/oDCSzHFYonTGFGZHzsnzf3X m0vWf0xUfXIhNUtBGa2uq26q5BpGpi37Xda7ahMu0t77hJHbkXlyBvY7Jn405BmZrvtl odT4aoNI5KPqx+O/C5lWwh1ZT4NlS/R0k+VXY/8jWWnY5BZlm0RmTxR+bdhvmy01845h VUgWBywBKSFlm8rI1oXS7Jr3L7e8FDF98r22Jpjfi/pozulVVaMLy2Hn3juxlde97TSj CReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wg0a57cr/r26Fm3sybPaTjbWfq8hx070vW8oQ3zhuAQ=; b=QrecU2GQVQ5rqCyRUW/KZxtg2oLc4ehSWdJX4O3gla7KjrRLaESbnXmkcQS/UI0YsP wjldNGk/CPWlblRbdY01Vf7FVJCoEgZUtzxJo/Wl6jb3zkCjFRlJPm2WutQBrNvSdNqx YthRIyQ7kk2TwQvDEOUSLpKF2eb5zemGGA6U95dYoViHnJO3u72WdoBIHUg7jHReARc4 /r9Pou5l0EANZRi74VVoy/msyimnoqo2iZjuAsqpYVmcVWsLq7s4JJARXoI6hmjTIRkH lcxRfAub30XRvVLPdk+dLfFFAJOcTrNsf/jU8sfEnFwf+kXNc7b0dxWu6ERXXgTh4qbg Bf5g== X-Gm-Message-State: AOAM531RQIsTD8eDigW76h/CMaCZWfEZ5EjNOCBZMgJ/mg9R7+XAVbZE gIy9eYjRzfG6uIDNp9RQapBpaPR6V64= X-Google-Smtp-Source: ABdhPJzWeKH9wOmkgirtZgPu3uUlqk5GO1ryN7Wilvia1D9DAQ0K4b1J70kCE6DrrRFJLtbKk2Ugbw== X-Received: by 2002:a17:906:31d7:: with SMTP id f23mr18467844ejf.190.1631625714004; Tue, 14 Sep 2021 06:21:54 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:53 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 04/10] trace-cmd dump: Read recursively all options sections Date: Tue, 14 Sep 2021 16:21:42 +0300 Message-Id: <20210914132148.3968401-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Trace file version 7 supports multiple options sections in the file. The DONE option is extended to hold the offset to the next options section. A new logic for handling the extended DONE option and to read recursively all options sections is added. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 76 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index f7284436..dcc41030 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -422,6 +422,30 @@ static void dump_option_string(int fd, int size, char *desc) read_dump_string(fd, size, OPTIONS); } +static void dump_section_header(int fd, enum dump_items v, unsigned short *flags) +{ + unsigned long long offset; + unsigned short fl; + char buf[DUMP_SIZE]; + unsigned short id; + int size; + + offset = lseek64(fd, 0, SEEK_CUR); + if (read_file_number(fd, &id, 2)) + die("cannot read the section id"); + if (read_file_string(fd, buf, DUMP_SIZE)) + die("no section description"); + if (read_file_number(fd, &fl, 2)) + die("cannot read the section flags"); + if (read_file_number(fd, &size, 4)) + die("cannot read section size"); + do_print(v, "\t[Section %d @ %lld: \"%s\", flags 0x%X, %d bytes]\n", + id, offset, buf, fl, size); + + if (flags) + *flags = fl; +} + static void dump_option_buffer(int fd, int size) { unsigned long long offset; @@ -591,25 +615,48 @@ void dump_option_tsc2nsec(int fd, int size) do_print(OPTIONS, "%d %d %llu [multiplier, shift, offset]\n", mult, shift, offset); } -static void dump_options(int fd) +static int dump_options_read(int fd); + +static int dump_option_done(int fd, int size) { + unsigned long long offset; + + do_print(OPTIONS, "\t\t[Option DONE, %d bytes]\n", size); + + if (file_version < FILE_VERSION_SECTIONS || size < 8) + return 0; + if (read_file_number(fd, &offset, 8)) + die("cannot read the next options offset"); + do_print(OPTIONS, "%lld\n", offset); + if (!offset) + return 0; + + if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) + die("cannot goto next options offset %lld", offset); + return dump_options_read(fd); +} + +static int dump_options_read(int fd) +{ + unsigned short flags = 0; unsigned short option; unsigned int size; int count = 0; + if (file_version >= FILE_VERSION_SECTIONS) + dump_section_header(fd, OPTIONS, &flags); + if ((flags & TRACECMD_SEC_FL_COMPRESS) && uncompress_block()) + die("cannot uncompress file block"); + for (;;) { if (read_file_number(fd, &option, 2)) die("cannot read the option id"); - if (!option) + if (option == TRACECMD_OPTION_DONE && file_version < FILE_VERSION_SECTIONS) break; if (read_file_number(fd, &size, 4)) die("cannot read the option size"); count++; - if (!DUMP_CHECK(OPTIONS) && !DUMP_CHECK(CLOCK) && !DUMP_CHECK(SUMMARY)) { - lseek64(fd, size, SEEK_CUR); - continue; - } switch (option) { case TRACECMD_OPTION_DATE: dump_option_string(fd, size, "DATE"); @@ -621,7 +668,8 @@ static void dump_options(int fd) dump_option_buffer(fd, size); break; case TRACECMD_OPTION_TRACECLOCK: - dump_option_string(fd, size, "TRACECLOCK"); + do_print(OPTIONS, "\t\t[Option TRACECLOCK, %d bytes]\n", size); + read_dump_string(fd, size, OPTIONS | CLOCK); has_clock = 1; break; case TRACECMD_OPTION_UNAME: @@ -654,6 +702,10 @@ static void dump_options(int fd) case TRACECMD_OPTION_TSC2NSEC: dump_option_tsc2nsec(fd, size); break; + case TRACECMD_OPTION_DONE: + uncompress_reset(); + count += dump_option_done(fd, size); + return count; default: do_print(OPTIONS, " %d %d\t[Unknown option, size - skipping]\n", option, size); @@ -661,8 +713,16 @@ static void dump_options(int fd) break; } } - do_print(SUMMARY, "\t[%d options]\n", count); + uncompress_reset(); + return count; +} + +static void dump_options(int fd) +{ + int count; + count = dump_options_read(fd); + do_print(SUMMARY|OPTIONS, "\t[%d options]\n", count); } static void dump_latency(int fd) From patchwork Tue Sep 14 13:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F709C433EF for ; Tue, 14 Sep 2021 13:21:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87460606A5 for ; Tue, 14 Sep 2021 13:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233146AbhINNXO (ORCPT ); Tue, 14 Sep 2021 09:23:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXN (ORCPT ); Tue, 14 Sep 2021 09:23:13 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88363C061574 for ; Tue, 14 Sep 2021 06:21:56 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id q3so19870766edt.5 for ; Tue, 14 Sep 2021 06:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EQImAUfB8hEyGOBENCgXjmTM8Q/S6OcGuARs0lMu7IE=; b=l+BNfwv5/siFrPZpUqUSWSkdkIqMmdmSq/hYpVOzWCJvkJNGo6GFovA0B3POnvGGj/ h2h0YOWXCfkzuN0kLYdQ7m3Aq0xPIvryktEO5mYVxIvWn+829+wGDngiCwMTYhwiEAfN TCHAgcHOl7pvrh5bKlOk8mavYST0XFTuyUWVd9/4b4PlB9hYy2s5xZXaUwl/9ZOmZb+e lqXF1NnWrNO78JMeNRFVUGgpkLElM6XXjdAP9t5L58zUrC61ML6LPO3HKEjBOW2tNQxF tJO6UNwvVWIUz/VSHYKNQzXx5L4P1t0tC4tMScJm7Y2gdUh5P69+iz0uTFIcOPPwLgaW dEcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EQImAUfB8hEyGOBENCgXjmTM8Q/S6OcGuARs0lMu7IE=; b=EViLvteoc6p0undt2bTj5yk5WuggZ6Rg7kAEYw0S1L1ysN1zJjEx1qXzc1R6PvyRAo HeqrXy5zGuJu1EpRiNN33Zcu5Ta23xHDw68nNJMa69xa6YDZpnGhbaz/9RTFGj70urNr teGhaSRk89nzsykQqOrmLgaop9+jpHFLOePXLWeeTbPd1Nab1JRU7Mv60LaurXjhu6VS 6h7pX2fg4CB8Ga1WnqbHTWT02trJCb3l1ihIm3RmsatJ1/xIrBkJMYUVho3nP0xYvqCh vBCv3pNKILAbgBOf2lrq06orZOueQXuaY+zoCY+j7c0/sxMIjqb9WPXvutzj+d4R5f69 ClOw== X-Gm-Message-State: AOAM532eL4SREvWpzITNC63BAaTcwQ1NPLL8GUp0FeMPpf3bh42B069J OJkCzXVnpZLmwlGUO6PklTI9txDzKRs= X-Google-Smtp-Source: ABdhPJxA7dlkGttynuHUmSbnZ+jd1OLjGDanhZVRtRQbyypZfHEs8cbJGlVMgSTVPPfbSaYucqubWw== X-Received: by 2002:a05:6402:510f:: with SMTP id m15mr19186883edd.257.1631625715123; Tue, 14 Sep 2021 06:21:55 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:54 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 05/10] trace-cmd dump: Read extended BUFFER option Date: Tue, 14 Sep 2021 16:21:43 +0300 Message-Id: <20210914132148.3968401-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org In trace file version 7 the BUFFER option is extended to hold a trace metadata, related to the recorded instance. Also, a new BUFFER_TEXT option is added for latency trace data. Implemented logic for reading and printing these extended options. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 64 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index dcc41030..c44870c4 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -446,19 +446,72 @@ static void dump_section_header(int fd, enum dump_items v, unsigned short *flags *flags = fl; } -static void dump_option_buffer(int fd, int size) +static void dump_option_buffer(int fd, unsigned short option, int size) { + unsigned long long total_size = 0; + unsigned long long data_size; + unsigned long long current; unsigned long long offset; + unsigned short flags; + char clock[DUMP_SIZE]; + char name[DUMP_SIZE]; + int cpus = 0; + int id; + int i; if (size < 8) die("broken buffer option with size %d", size); if (read_file_number(fd, &offset, 8)) die("cannot read the offset of the buffer option"); + if (read_file_string(fd, name, DUMP_SIZE)) + die("cannot read the name of the buffer option"); + if (file_version < FILE_VERSION_SECTIONS) { + do_print(OPTIONS|FLYRECORD, "\t\t[Option BUFFER, %d bytes]\n", size); + do_print(OPTIONS|FLYRECORD, "%lld [offset]\n", offset); + do_print(OPTIONS|FLYRECORD, "\"%s\" [name]\n", name); + return; + } + + current = lseek64(fd, 0, SEEK_CUR); + if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) + die("cannot goto buffer offset %lld", offset); + + dump_section_header(fd, FLYRECORD, &flags); + + if (lseek64(fd, current, SEEK_SET) == (off_t)-1) + die("cannot go back to buffer option"); + + do_print(OPTIONS|FLYRECORD, "\t\t[Option BUFFER, %d bytes]\n", size); + do_print(OPTIONS|FLYRECORD, "%lld [offset]\n", offset); + do_print(OPTIONS|FLYRECORD, "\"%s\" [name]\n", name); + + if (read_file_string(fd, clock, DUMP_SIZE)) + die("cannot read clock of the buffer option"); + do_print(OPTIONS|FLYRECORD, "\"%s\" [clock]\n", clock); + if (option == TRACECMD_OPTION_BUFFER) { + if (read_file_number(fd, &cpus, 4)) + die("cannot read the cpu count of the buffer option"); + + do_print(OPTIONS|FLYRECORD, "%d [CPUs]:\n", cpus); + for (i = 0; i < cpus; i++) { + if (read_file_number(fd, &id, 4)) + die("cannot read the id of cpu %d from the buffer option", i); + if (read_file_number(fd, &offset, 8)) + die("cannot read the offset of cpu %d from the buffer option", i); + if (read_file_number(fd, &data_size, 8)) + die("cannot read the data size of cpu %d from the buffer option", i); + total_size += data_size; + do_print(OPTIONS|FLYRECORD, " %d %lld\t%lld\t[id, data offset and size]\n", + id, offset, data_size); + } + do_print(SUMMARY, "\t\[buffer \"%s\", \"%s\" clock, " + "%d cpus, %lld bytes flyrecord data]\n", + name, clock, cpus, total_size); + } else { + do_print(SUMMARY, "\t\[buffer \"%s\", \"%s\" clock, latency data]\n", name, clock); + } - do_print(OPTIONS, "\t\t[Option BUFFER, %d bytes]\n", size); - do_print(OPTIONS, "%lld [offset]\n", offset); - read_dump_string(fd, size - 8, OPTIONS); } static void dump_option_int(int fd, int size, char *desc) @@ -665,7 +718,8 @@ static int dump_options_read(int fd) dump_option_string(fd, size, "CPUSTAT"); break; case TRACECMD_OPTION_BUFFER: - dump_option_buffer(fd, size); + case TRACECMD_OPTION_BUFFER_TEXT: + dump_option_buffer(fd, option, size); break; case TRACECMD_OPTION_TRACECLOCK: do_print(OPTIONS, "\t\t[Option TRACECLOCK, %d bytes]\n", size); From patchwork Tue Sep 14 13:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6051C433F5 for ; Tue, 14 Sep 2021 13:21:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 917A4610A6 for ; Tue, 14 Sep 2021 13:21:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbhINNXP (ORCPT ); Tue, 14 Sep 2021 09:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXO (ORCPT ); Tue, 14 Sep 2021 09:23:14 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F2FC061574 for ; Tue, 14 Sep 2021 06:21:57 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id t6so18463357edi.9 for ; Tue, 14 Sep 2021 06:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w07ei+vuellAhsrpRQKM7ECaOSyrjL1xjJLvVhkLfpg=; b=B36t3CYQ7ybtV/cb/cfPr25D4audCWy56hxu2l63h011B+B/KmCvELItN1lisvDQjX foS6XJZlw+SHkjwHaaQEyyE10qc1DfpfC7rMOfLtlXwenouXpHamucwkz45dda/VBfaG d6fmiMb5UX8GeIkfEcnG65v8ZTTyVl+NErpg5jZXdc0h4/Qf1zSVXhB+2qscVYHkw0I1 pt1UsANTslOS+pppdsOrcRuc2huorkP085o32aaxj3PIM+OeULKseazJUKqPMUyTHfTJ izdVBlQjvk4NmqTZl4ZDsGuax4WkiJD6y5vx41HUou/VzMovg4oZiF99dNxL+r3Pkez1 0zwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w07ei+vuellAhsrpRQKM7ECaOSyrjL1xjJLvVhkLfpg=; b=HJXNPLbfhIk9wVAjc+kiNA/c63ag4/8B8wTbnjgmnkDNC+wJ/xXGhZMm0txr4vm51d Hw7izGHLPVicb9nz4O7atVPLOqajGufYQENOpOIVfLe70ddNcoXg2FWY+//0GtdPVF88 b9IU74J0kF1YZsAIshrSQLVIZSKuv4X+dXnWG/Ed/JBVSU4szEVc8ZjxRxm3Pbi+o99D q3Gwl4KoLW8lB3JTD+v6DKqByyhph1PpcroRiuIDmFxhUEdwgDIq343isBlL0+OaEdrZ cmV89/UveCRg/D5I8c2UlJ1ILa/dQVDKR/vvzsrjJ+Q6d2EBkqLEsZzsbgfrF0aZYCYn uCPQ== X-Gm-Message-State: AOAM530t3g5ZJQmze7k0WGmfTfUWzTB0KatbE9pRlg7eWffakrhgwQta CSpfhiZG/aoAn6ITEu9x1eSOCTcUOGg= X-Google-Smtp-Source: ABdhPJzbQj/5dgYOTWnNxeUkSsnIeXU0KSXPd9RoCZJ8FIk6f05bC/6kaV+2yExAX3wIg8KhxKkDTQ== X-Received: by 2002:a50:aa9c:: with SMTP id q28mr18979677edc.199.1631625716103; Tue, 14 Sep 2021 06:21:56 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:55 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 06/10] trace-cmd dump: Dump sections Date: Tue, 14 Sep 2021 16:21:44 +0300 Message-Id: <20210914132148.3968401-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org In trace file version 7, headers are stored as sections. This allows their position in the file not to be fixed. Pointers to these sections are stored as trace options. Add logic to handle these new options: HEADER_INFO FTRACE_EVENTS EVENT_FORMATS KALLSYM PRINTK CMDLINES Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index c44870c4..3394847c 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -668,6 +668,24 @@ void dump_option_tsc2nsec(int fd, int size) do_print(OPTIONS, "%d %d %llu [multiplier, shift, offset]\n", mult, shift, offset); } +static void dump_option_section(int fd, unsigned int size, + unsigned short id, char *desc, enum dump_items v) +{ + struct file_section *sec; + + sec = calloc(1, sizeof(struct file_section)); + if (!sec) + die("cannot allocate new section"); + sec->next = sections; + sections = sec; + sec->id = id; + sec->verbosity = v; + if (read_file_number(fd, &sec->offset, 8)) + die("cannot read the option %d offset", id); + do_print(OPTIONS, "\t\t[Option %s, %d bytes]\n", desc, size); + do_print(OPTIONS, "%lld\n", sec->offset); +} + static int dump_options_read(int fd); static int dump_option_done(int fd, int size) @@ -756,6 +774,25 @@ static int dump_options_read(int fd) case TRACECMD_OPTION_TSC2NSEC: dump_option_tsc2nsec(fd, size); break; + case TRACECMD_OPTION_HEADER_INFO: + dump_option_section(fd, size, option, "HEADERS", HEAD_PAGE | HEAD_EVENT); + break; + case TRACECMD_OPTION_FTRACE_EVENTS: + dump_option_section(fd, size, option, "FTRACE EVENTS", FTRACE_FORMAT); + break; + case TRACECMD_OPTION_EVENT_FORMATS: + dump_option_section(fd, size, option, + "EVENT FORMATS", EVENT_SYSTEMS | EVENT_FORMAT); + break; + case TRACECMD_OPTION_KALLSYMS: + dump_option_section(fd, size, option, "KALLSYMS", KALLSYMS); + break; + case TRACECMD_OPTION_PRINTK: + dump_option_section(fd, size, option, "PRINTK", TRACE_PRINTK); + break; + case TRACECMD_OPTION_CMDLINES: + dump_option_section(fd, size, option, "CMDLINES", CMDLINES); + break; case TRACECMD_OPTION_DONE: uncompress_reset(); count += dump_option_done(fd, size); From patchwork Tue Sep 14 13:21:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2596C433FE for ; Tue, 14 Sep 2021 13:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D84160E9B for ; Tue, 14 Sep 2021 13:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233172AbhINNXQ (ORCPT ); Tue, 14 Sep 2021 09:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbhINNXP (ORCPT ); Tue, 14 Sep 2021 09:23:15 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A558C061574 for ; Tue, 14 Sep 2021 06:21:58 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id qq21so22990381ejb.10 for ; Tue, 14 Sep 2021 06:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XBqB9KoV1o24qWOyKjje4CKxWGz3YUwcOPKCLKEWJ0Y=; b=pVlgUcYwGqtEpwL+sTWqjhOjYfaguHh/gTweZnv8Uq6vnaK+Idp7QXhX2UiUGPsvNZ GcdY7w4500yhYuvUWRY8bOCAuB+qvfX/RUg/s2YB4EvuW5ypZ3I+V9kFh7WouLzV04AY 9vax45GAv6i35x1Djo6TSwViZkY+vusCZv57ZHX7wjs46Xye3YmSZz9LpxoivC0ujwMc qIpO3tp+hgPP48VA1k53YZ4/l9/TkrvrP4HH3PWB5cNrF1js23nLm1CD4OLBbXYcc5I+ 97Y20s8Fw27xt2eYYsyUeZc5E5c1CZUqYYsipckx+y6/p1c4J47mCW2R7sKmbHz5dRWd +lqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XBqB9KoV1o24qWOyKjje4CKxWGz3YUwcOPKCLKEWJ0Y=; b=vWrmMmEL09QVVuDNztQyx94320STa1snFfBcnYLvg4X96Tm2sZMsVmItLa/ZyZq2e9 f/vTL+j5oKxQKB9m2xCieGHLTWb8KJMZvdTo8Ye05MRZR9OFE+vSjlmeMlOJU8238/e+ tSJJ6WpA7L7l5DZixDkY3PC+/6E6ZcGYa5isC5Tw9UOMopWPVKa/qVX6jLJM4oIuS0Lx 4XCZLgrUfDMRto/hqLAoWTXOz0pOhbchu3RCaumehfYEaj/F9DTHLnvrUfCvkANV3h1R q36j1SNt9ZDXU5/eLyQWw7SNHvqKvGD6mD83yagztzN9zV0TfCoE4Og4xZqnIcpBohoC iv3A== X-Gm-Message-State: AOAM531QabbHXsLpmLp7yvjgWPS63JAuCziDJYFXusHOntp86Ah02yFk /BclHfCO2v6XDZywxSxuThLYUTxM8Wc= X-Google-Smtp-Source: ABdhPJyWWmUyedR1MDqWO2+Ua123MSKvZMl4wvB8W3L8euMIRQTTJC7+a+wyJGyfL62x1TU5N2hpgw== X-Received: by 2002:a17:906:8450:: with SMTP id e16mr19018934ejy.305.1631625717081; Tue, 14 Sep 2021 06:21:57 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:56 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 07/10] trace-cmd dump: Dump trace file version 7 Date: Tue, 14 Sep 2021 16:21:45 +0300 Message-Id: <20210914132148.3968401-8-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Trace file version 7 has different structure than version 6. Separates parsing both versions in different flows. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index 3394847c..44f103d8 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -884,6 +884,31 @@ static void dump_therest(int fd) } } +static void dump_v6_file(int fd) +{ + dump_header_page(fd); + dump_header_event(fd); + dump_ftrace_events_format(fd); + dump_events_format(fd); + dump_kallsyms(fd); + dump_printk(fd); + dump_cmdlines(fd); + dump_cpus_count(fd); + dump_therest(fd); +} + +static void dump_v7_file(int fd) +{ + long long offset; + + if (read_file_number(fd, &offset, 8)) + die("cannot read offset of the first option section"); + + if (lseek64(fd, offset, SEEK_SET) == (off64_t)-1) + die("cannot goto options offset %lld", offset); + dump_options(fd); +} + static void free_sections(void) { struct file_section *del; @@ -911,15 +936,10 @@ static void dump_file(const char *file) dump_initial_format(fd); dump_compress(fd); - dump_header_page(fd); - dump_header_event(fd); - dump_ftrace_events_format(fd); - dump_events_format(fd); - dump_kallsyms(fd); - dump_printk(fd); - dump_cmdlines(fd); - dump_cpus_count(fd); - dump_therest(fd); + if (file_version < FILE_VERSION_SECTIONS) + dump_v6_file(fd); + else + dump_v7_file(fd); free_sections(); tep_free(tep); tep = NULL; From patchwork Tue Sep 14 13:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0B36C433EF for ; Tue, 14 Sep 2021 13:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8929960ED8 for ; Tue, 14 Sep 2021 13:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233184AbhINNXR (ORCPT ); Tue, 14 Sep 2021 09:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233181AbhINNXQ (ORCPT ); Tue, 14 Sep 2021 09:23:16 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB63C061574 for ; Tue, 14 Sep 2021 06:21:59 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id x11so28945234ejv.0 for ; Tue, 14 Sep 2021 06:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84CJPvhzlFAC7i9Uo9LZqs10p/gs28x2Da/5/NO4GPU=; b=YInYjSFnjTdWRaKGFnyNFMo8maxsQPsENUDrhXVD9fXoV83tCsJACuvT9oICiEPxqJ K46REcR1bE8YSVWvPixgnnHPR7r/kh55qXXFUGK5HXLCx4aq8d3aD1NbJGQbPv8TUxvT 9oHGSuFFtKOO/CdZRyX4MeBak/dGOvVhPRwJnrbE8+QyxwoUFWxyCLG+fZtobc2vBDyZ Yt7RnZjziIqjH5Ond5ElWH/GGHJ66oH/kfdR3gUbbozEyrX9HmbKq7HV/tyhecNXBlaR 9w3k2QxGJAWkEt9U46miqhlmMXHgQ0p0oTA1Y26pQtLXOsbSIM7PobWE5YYfzDlRv6dE 1NXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=84CJPvhzlFAC7i9Uo9LZqs10p/gs28x2Da/5/NO4GPU=; b=79zDJ+M8aOU0DC8Sfzvf66V4jdJL2E3s93TjRO9c/jfQqAmofuBYFfJ/c/n9ay0w4g xE5SvcRDLiUFHww10z5noJKvWdxa/e+XuVkEXwdOFpzbBR4iPy7ok5J2MO7GGyfSPI3R CWUmMHjN6QtOxBO/FpmbAP5KCljxfcdz9UvRnjoqJlLE2wtNAK+uN+jil9bDfSdWxYji wo2FHTaxfZOL7jR8q2czKncczR4xsfIa8S3c1AffcPrFEBHU/gJVeznyVl3w/cen+wXn /0CpE5IraSRhY7oLb/UNhrhirc0qe3ni6sKI3uIyLLOdrhPkJJ+6pokK4RDkP+nYK7xQ wx7w== X-Gm-Message-State: AOAM531Qb8eY6b5q8gVm5QkY2xRxyGhjXa6TvC5WPqVbx3/EugCb47k5 9rqF4XaMX/HORll0Ha8HfcTamQPhR/0= X-Google-Smtp-Source: ABdhPJwao4dlkxNdFKlDLcvbHv+4dtn4szbaec0evrE5SpHhWY8S5rk/XGU0q8mT+cPhCMDTELhTJQ== X-Received: by 2002:a17:906:1d41:: with SMTP id o1mr19124581ejh.232.1631625718086; Tue, 14 Sep 2021 06:21:58 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:57 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 08/10] trace-cmd dump: Dump sections content Date: Tue, 14 Sep 2021 16:21:46 +0300 Message-Id: <20210914132148.3968401-9-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org In trace file version 7, dump the content of the headers content, that are stored as sections. Added logic to dump these headers: HEADER_INFO FTRACE_EVENTS EVENT_FORMATS KALLSYM PRINTK CMDLINES Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index 44f103d8..c222cd66 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -686,6 +686,46 @@ static void dump_option_section(int fd, unsigned int size, do_print(OPTIONS, "%lld\n", sec->offset); } +static void dump_sections(int fd) +{ + struct file_section *sec = sections; + unsigned short flags; + + while (sec) { + if (lseek64(fd, sec->offset, SEEK_SET) == (off_t)-1) + die("cannot goto option offset %lld", sec->offset); + + dump_section_header(fd, sec->verbosity, &flags); + + if ((flags & TRACECMD_SEC_FL_COMPRESS) && uncompress_block()) + die("cannot uncompress section block"); + + switch (sec->id) { + case TRACECMD_OPTION_HEADER_INFO: + dump_header_page(fd); + dump_header_event(fd); + break; + case TRACECMD_OPTION_FTRACE_EVENTS: + dump_ftrace_events_format(fd); + break; + case TRACECMD_OPTION_EVENT_FORMATS: + dump_events_format(fd); + break; + case TRACECMD_OPTION_KALLSYMS: + dump_kallsyms(fd); + break; + case TRACECMD_OPTION_PRINTK: + dump_printk(fd); + break; + case TRACECMD_OPTION_CMDLINES: + dump_cmdlines(fd); + break; + } + uncompress_reset(); + sec = sec->next; + } +} + static int dump_options_read(int fd); static int dump_option_done(int fd, int size) @@ -907,6 +947,7 @@ static void dump_v7_file(int fd) if (lseek64(fd, offset, SEEK_SET) == (off64_t)-1) die("cannot goto options offset %lld", offset); dump_options(fd); + dump_sections(fd); } static void free_sections(void) From patchwork Tue Sep 14 13:21:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F332CC433F5 for ; Tue, 14 Sep 2021 13:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBEBE60E9B for ; Tue, 14 Sep 2021 13:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233196AbhINNXS (ORCPT ); Tue, 14 Sep 2021 09:23:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233174AbhINNXR (ORCPT ); Tue, 14 Sep 2021 09:23:17 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 733C0C061574 for ; Tue, 14 Sep 2021 06:22:00 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id j13so19844349edv.13 for ; Tue, 14 Sep 2021 06:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ouUPdX/PFfDz4Wyg9WnRuXzTY+cYqywgfcxBHCDWMBY=; b=d9kV1yJ9FUCwM8ssjedfnUapDakKTE4i4xNr4cB0/lK3H49MYdUYFNa63Ed+ugrQAK +WqhngSQdUR/jELhfSBr0stq3nLqUy+SP8rfNYzg9vFvDrnsy6aZawXVHWKvxlOO6Rcm FLOOdPgjEDhbZvPpsDe3Wc2NICDckeoDFNcTw3S8AMAZGCdfAJxKFy1icVZMuO3x88yE N2ajCuB5Nu6TW7ldy55h93V85NUmLPPZNGnUJhQqRSZ1P4pc0QQJjt7xqmf8HaBIx5eI 1C4kNTbkQqIayd0OIekkPJOQnUjkYHcsF9s9z0JxAbl6OA3+rMvYPyA/ZHYJc4OTSZ81 zvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ouUPdX/PFfDz4Wyg9WnRuXzTY+cYqywgfcxBHCDWMBY=; b=2tAl4IVVoSYez5zNm0ETSKClB+90D/BjZZCwlEAALdteCdXuGLwYKheC5uoriIK6CW HdKJoZ2hcYMLzyKMd69zVmG2rfO3gY1sDnEukKy57XwsqEVIvknS96nVkwP03RwiZUkt O4cXOVhbnUkEN2g5BvbIHcMb05juUK2mUfMOCLCFIhtoI0gmEbo7l9Nf73nU1Mru70B7 bA0W9r00NyiFVC8EoRVg0lotEYCNfr0lPG1NhdJYuJLsJ5HyR75vzOAM8Dzhj3FZ3UsQ UIU6baaQdvsv6t1FDwQHy0CwxZEGrSGFOW/wmy03wE10RFNVK9nk5UNJiwVRt2hIflvY SH5g== X-Gm-Message-State: AOAM530pNzEopWufiKYXpL2MmrleRVfRsTzVDm/jgrRMaHiRBe2aSnjU Gbzl5JYUW0wmHeJnHkj1zfJ+wINyN20= X-Google-Smtp-Source: ABdhPJzk06wOQ8q7l/WajcxkpgY6M5t+bBDNvm/9klTO9S6YR4wXyeTsY55EHnm2gWw8OPgzq9Lmaw== X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr9822282edd.82.1631625718934; Tue, 14 Sep 2021 06:21:58 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:58 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 09/10] trace-cmd dump: Add new argument --sections Date: Tue, 14 Sep 2021 16:21:47 +0300 Message-Id: <20210914132148.3968401-10-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The new "trace-cmd dump --sections" argument walks through the sections from a trace file version 7 and prints their headers. The logic does not rely on the options, describing these sections. It could be useful to dump broken or incomplete trace files. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 71 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index c222cd66..ab2fa2e5 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -686,7 +686,7 @@ static void dump_option_section(int fd, unsigned int size, do_print(OPTIONS, "%lld\n", sec->offset); } -static void dump_sections(int fd) +static void dump_sections(int fd, int count) { struct file_section *sec = sections; unsigned short flags; @@ -724,6 +724,7 @@ static void dump_sections(int fd) uncompress_reset(); sec = sec->next; } + do_print(SUMMARY|SECTIONS, "\t[%d sections]\n", count); } static int dump_options_read(int fd); @@ -937,17 +938,76 @@ static void dump_v6_file(int fd) dump_therest(fd); } +static int walk_v7_sections(int fd) +{ + unsigned long long offset, soffset; + unsigned short fl; + char buf[DUMP_SIZE]; + unsigned short id; + int size, csize, rsize; + int count = 0; + + offset = lseek64(fd, 0, SEEK_CUR); + do { + soffset = lseek64(fd, 0, SEEK_CUR); + if (read_file_number(fd, &id, 2)) + break; + if (id >= TRACECMD_OPTION_MAX) + die("Unknown section id %d", id); + if (read_file_string(fd, buf, DUMP_SIZE)) + die("cannot read section description"); + if (read_file_number(fd, &fl, 2)) + die("cannot read section flags"); + if (read_file_number(fd, &size, 4)) + die("cannot read section size"); + if (size <= 4) + die("Section %d (%s) is too small, %d bytes", id, buf, size); + count++; + if (fl & TRACECMD_SEC_FL_COMPRESS) { + if (id == TRACECMD_OPTION_BUFFER || + id == TRACECMD_OPTION_BUFFER_TEXT) { + do_print(SECTIONS, + "\t[Section %2d @ %-16lld\t\"%s\", flags 0x%X, " + "%d compressed bytes]\n", + id, soffset, buf, fl, size); + } else { + if (read_file_number(fd, &csize, 4)) + die("cannot read section size"); + if (read_file_number(fd, &rsize, 4)) + die("cannot read section size"); + do_print(SECTIONS, "\t[Section %2d @ %-16lld\t\"%s\", flags 0x%X, " + "%d compressed, %d uncompressed]\n", + id, soffset, buf, fl, csize, rsize); + size -= 8; + } + } else { + do_print(SECTIONS, "\t[Section %2d @ %-16lld\t\"%s\", flags 0x%X, %d bytes]\n", + id, soffset, buf, fl, size); + } + + if (lseek64(fd, size, SEEK_CUR) == (off_t)-1) + break; + } while (1); + + if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) + die("cannot restore the original file location"); + return count; +} + static void dump_v7_file(int fd) { long long offset; + int sections; if (read_file_number(fd, &offset, 8)) die("cannot read offset of the first option section"); - if (lseek64(fd, offset, SEEK_SET) == (off64_t)-1) + sections = walk_v7_sections(fd); + + if (lseek64(fd, offset, SEEK_SET) == (off_t)-1) die("cannot goto options offset %lld", offset); dump_options(fd); - dump_sections(fd); + dump_sections(fd, sections); } static void free_sections(void) @@ -988,6 +1048,7 @@ static void dump_file(const char *file) } enum { + OPT_sections = 241, OPT_verbose = 242, OPT_clock = 243, OPT_all = 244, @@ -1031,6 +1092,7 @@ void trace_dump(int argc, char **argv) {"options", no_argument, NULL, OPT_options}, {"flyrecord", no_argument, NULL, OPT_flyrecord}, {"clock", no_argument, NULL, OPT_clock}, + {"sections", no_argument, NULL, OPT_sections}, {"validate", no_argument, NULL, 'v'}, {"help", no_argument, NULL, '?'}, {"verbose", optional_argument, NULL, OPT_verbose}, @@ -1094,6 +1156,9 @@ void trace_dump(int argc, char **argv) if (trace_set_verbose(optarg) < 0) die("invalid verbose level %s", optarg); break; + case OPT_sections: + verbosity |= SECTIONS; + break; default: usage(argv); } From patchwork Tue Sep 14 13:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12493389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76164C433FE for ; Tue, 14 Sep 2021 13:22:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F2B560ED8 for ; Tue, 14 Sep 2021 13:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233079AbhINNXU (ORCPT ); Tue, 14 Sep 2021 09:23:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233199AbhINNXS (ORCPT ); Tue, 14 Sep 2021 09:23:18 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AC46C061574 for ; Tue, 14 Sep 2021 06:22:01 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id t6so18463745edi.9 for ; Tue, 14 Sep 2021 06:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84YBfQkP8YMHELb1tKO3NWhuSj1uaCA+g4kG3U3Va6g=; b=GTeypRUKCQWi0uP1B1EZ3E306WTwu9hwv0KGptN0y2miOYZDIH8TitptLUmc5Qa+1m o7Ag2xI/4xCetNKV+RPOApSK2GqFf+Wq2mWcwfHmWodrcLM5nZ3/U3DqbyFWm2cBJnT9 iGRdjFUXRY4G0uKeIF7Lzt2cP6dY9WKt8Ghs6LzBZSPyTabmsZgfdqUcvqjOISjsrOL4 nCiM0w3VRTt9VTxxUZJ3b9cuKI8j3YLezjHaJEciNXVEMIZyOETl13TUUiTsnaS3taNZ tnFASk4y0bF+6+Kyk4iiwtvWA4f0S9Yi6lVzZiLvbbw/zD61VxCh61n1lrm2RnLnu1u4 BYdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=84YBfQkP8YMHELb1tKO3NWhuSj1uaCA+g4kG3U3Va6g=; b=qlJ+6RLpL+eGTMnLCOsbzZeFWw3QdZ8KMPgd7L2Fn9dHonvBjmTvcwCsouQ+Jm4t/W Yv7m3UDoOaMunI3xsHoBusvYPK3uTFw2uaRd8YCQNiGaWruZC6PsZHnO+kSt3k6PBWx/ KjXXsfuEdO4OqIX9bBnrCrdo8Y8P1dlvmbiOwWEpYw/P6/Uw7xHn5m0b1NxJGA3zY7iL cC2xd74odABHEiY9JslV7N0nMTI0YAf1lHXPt8MWmmNunMY+2DTEMxKzaSTisJ7j8vT2 m3ASSOTBJS00GI3iixhiXiY48/GxY/kLO9BnpIqNKg24d23AlCP9CTC+QpbX/Vd4h+XD N5PA== X-Gm-Message-State: AOAM532H42JfJ5WnhTyNkdredqcF3mHcLIvZWzo0F/P1xRM+Q7LZdttF eU2uCb2WjxyrqfUxQWwBgh0gV3+rraU= X-Google-Smtp-Source: ABdhPJwalzVytd0jaHlRwtBFsrn6ooUx4uTwXLdC9I6eLG7OSA95UxOL+LRu+OKWzxkgJWTuhacrdg== X-Received: by 2002:a05:6402:34c2:: with SMTP id w2mr19015112edc.36.1631625719903; Tue, 14 Sep 2021 06:21:59 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id l7sm5708431edb.26.2021.09.14.06.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 06:21:59 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 10/10] trace-cmd dump: Align better the output of flyrecord dump Date: Tue, 14 Sep 2021 16:21:48 +0300 Message-Id: <20210914132148.3968401-11-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210914132148.3968401-1-tz.stoyanov@gmail.com> References: <20210914132148.3968401-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The flyrecord dump prints various file offsets and sizes, that can be huge numbers. Add format arguments to align better the output. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c index ab2fa2e5..6a148cae 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -898,7 +898,7 @@ static void dump_flyrecord(int fd) die("cannot read the cpu %d offset", i); if (read_file_number(fd, &cpu_size, 8)) die("cannot read the cpu %d size", i); - do_print(FLYRECORD, "\t\t %lld %lld\t[offset, size of cpu %d]\n", + do_print(FLYRECORD, "\t %10.lld %10.lld\t[offset, size of cpu %d]\n", cpu_offset, cpu_size, i); } dump_clock(fd);