From patchwork Mon Sep 13 12:50:30 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: 12488897 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 02EAEC433FE for ; Mon, 13 Sep 2021 12:50:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D860561029 for ; Mon, 13 Sep 2021 12:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235604AbhIMMv7 (ORCPT ); Mon, 13 Sep 2021 08:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMv7 (ORCPT ); Mon, 13 Sep 2021 08:51:59 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6626C061574 for ; Mon, 13 Sep 2021 05:50:43 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so6518570wml.3 for ; Mon, 13 Sep 2021 05:50:43 -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=GWcy1y1cbtG9nbAgscNMXSEvMGAGFFSUVksYl+b/FR5XCaBNPPxLO4c5gp7IxtQXvT H/Je0nyUKQxAWgQFcDwVDq5ad9whT0uk9lUp+tiZk2KcTTyUVAy+DzF/9kZTtveqi3QU EbzlpgvhAzK7Y1hRL14aC2+WCz+LXjGCgmWt57yhwZmuizT95NDed63nh1SHZxkE81FZ rNpWJQBV1XoJU5RuXrvpuTShXzc4ZdyOWGb0hk/KMVJAFLExUiVaF6dmBQ4TMB95etFa UcIIerdJukyG8vQUxUJUj80xNCwIWdAaviwrPVxOxhMOuDi0C5NqFVsul2+W/kAbzI5z gAxQ== 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=KbIlhTQ6PLYFAsLSLFf9YF4EBlg4QpzuoookDtiaAyKwIOzuibIv6QObvYoon2svVT dYyaVJeBrnD/Bc3W1ForiICW0fFmucUyR5tkThctKWKIB1hRpj7ow1HGa3BV/Jd9UTwz ZEA2P2nAfcswigjfnEv3fjd1YujbRnScXdyaSeJi5EXSufoODp9edTyhh9GXpYaEoIup WWJjPFChjeLFhVr5IwaMJ9J8daCfiw0+sjHSy8XbjU73DBUqAupSREm2fIgGeyoAGBQf iwdpdIJYwVBMcNfHum7PspjFwZB2wTikNWVZFvLrjj3Xq5DIndJVoz+XXMWmmxcZOiQO mOUw== X-Gm-Message-State: AOAM533FWU7MqHPcGwwqtAehfNvWcFv/TFRzbpCA/wSvhc+DoRxbBGeK Fnev1VsFZCEq1o8ZQvqFvWApmdWoUCI= X-Google-Smtp-Source: ABdhPJzgdv4328iX4JEeKuKjUsKD06UvUJkk9WSm4wGyYatB1G8PUeL+Ed6YJOeBenlNKrOnDfUhcw== X-Received: by 2002:a7b:cbc4:: with SMTP id n4mr11150837wmi.93.1631537442320; Mon, 13 Sep 2021 05:50:42 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:41 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 01/10] trace-cmd dump: Add helpers for processing trace file version 7 Date: Mon, 13 Sep 2021 15:50:30 +0300 Message-Id: <20210913125039.3680986-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:31 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: 12488899 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 AF79CC4332F for ; Mon, 13 Sep 2021 12:50:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9165A60FBF for ; Mon, 13 Sep 2021 12:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235622AbhIMMwA (ORCPT ); Mon, 13 Sep 2021 08:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwA (ORCPT ); Mon, 13 Sep 2021 08:52:00 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AF99C061574 for ; Mon, 13 Sep 2021 05:50:44 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id b21-20020a1c8015000000b003049690d882so4049061wmd.5 for ; Mon, 13 Sep 2021 05:50:44 -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=EZNh+/wAEhroEmroiDPq+t/VAkvZJyc9BiVdXjMcOKROXe4U3TZwTKOSwLjqDez9HS 9gtTkOoQaETH1nZ4mkCfSFHAQRHmYZ8oJrN2kf9NpDmG6NzEzGFRg7F0erHkn254e4cT Rhj5XJjrYBGEP7sUlDmr9T6srWUXMJBGvsDl0Nahno/Fq2XHPWIhjjMQhfKnH4f+DMIF NPbUFb+VV3sUSoxx5kWsYaZCjvXB4PWg8w1zoApNWeuWd6ORvNUp9aIJ0z1WkStObIe0 3wD3o7yC56MDveITHyM76ATJy0eOubCpgF1LVewIHX97P52fqfFEQfbl5QpYX6LNu9EE SVRg== 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=jlGFy6WSesqfWNpLJfAWUDu7b7pPWJwcr/zKV4SEWSBHl6DOlhuQ4Bt+d8kGWrxp/B 9tShCS/GmRoVRl2XwyDwpYZB2a1rvGZpbE9MGkII8KUTWKq8H2b/WAdp6I5LbH1zZQ5m mlgP0Ym62mP0FfG6+/b2LL1UAY106mRTFRWS6wJuU+85FZMBt+U3/o+kZ/ExWWGfxqUr +Bd81EXbxH5iHD5avCcaHTyQmCWoQxJKIDhzZPoCIDw1CXjb0B+RGmcaWedsP90nXQRp QE/yVbab/nzH0IHMoVIln2Pl57GXIbiuYtW/nEvGbUf8UtQyhYefZaKp0i2vi8W5jTJO LoEw== X-Gm-Message-State: AOAM533+eC2CksQEK6bKiMxRM8XKBvcTgoVb2Q8bItbFqKKf5JLGRitk QWJjddVTC5itAHw8HQo6crln7h6sreY= X-Google-Smtp-Source: ABdhPJxLvGt+I9R9Lonu7YMAqLMUj8BfPAHsngdPINJEfJbA7XqcF9HJZlWJbUdNUaeg9e1xDHmM/A== X-Received: by 2002:a1c:2141:: with SMTP id h62mr10154410wmh.117.1631537443224; Mon, 13 Sep 2021 05:50:43 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:42 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 02/10] trace-cmd dump: Print compression header Date: Mon, 13 Sep 2021 15:50:31 +0300 Message-Id: <20210913125039.3680986-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:32 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: 12488901 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 9ABACC433F5 for ; Mon, 13 Sep 2021 12:50:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 808006101B for ; Mon, 13 Sep 2021 12:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235629AbhIMMwB (ORCPT ); Mon, 13 Sep 2021 08:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwB (ORCPT ); Mon, 13 Sep 2021 08:52:01 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 702E4C061574 for ; Mon, 13 Sep 2021 05:50:45 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso1364325wme.0 for ; Mon, 13 Sep 2021 05:50:45 -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=EY3H9TgJUkvhHoE7k0g1RqojIJCLGXv7k7b2+bf95vidpZvRc8CfiEBUsjGN206WgG A/63NPIBQJr0DRzA5OBb4OmiJBk+Na2qydlwgRhqAXppSz0AC/bFZx3OXn+sL8gMNbug XEiJl1snKpNz/Cu8emxlN4//iD03HysqeQL37zcCYqHMx/RXC1zo9Ce/4UokCc4KiSB4 hN2bxWqpwAoi0UgvjKgBHrMmhslF6dqoaR/ozVeF+Xq0rBD6G69u7LKDLyj7QCMSBQ+V DrdCSdFxXGwWEee2DTqWl2ZlRLBoquk8C4kZ1TO2LXog4QttoyFT0t8jCstGD34gbyVr zExQ== 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=wk3PeuYETwe2LdGUEcK4YbbponwZBxiX1SU29SSDpYxl89PDNYxuaDgtxcjprtxlC6 /B2wslG0r4m+8ws1U/BSdbyE0l75f3XL7vv+eJVOolW4t0V98UedYDK6/W1y6mNWdf8S RdhJRWDPXCI1K0/JEctizV99J6fo49ybEfrAv8e0vWxtUTOqq6ISa4gyhj0vxf3XKcQk XXwU0pDKUqBpn6XhS7/UwcN/rd8wfAOHLSroRApSIPCKKivTmoDgPjK/WXPaRTc2Exzm sSww2MsSx+x1u7xHH9iHrkNSWJNQPom6kg7ZBegRS6IDeB3iOjy9HEleoHHM8YwyNZ2X jemg== X-Gm-Message-State: AOAM5304q6AWDu0Naat0xVB77+W2HPdNyvYPTNJhiyefVKe9JyWvcF1x t8g1kNYJ/WFhD5qBf3Je/YmsnNNag3U= X-Google-Smtp-Source: ABdhPJwmayJeVnBEZqU82EiHdT+uTmoHB8C7eTC9mkZD2zMNAcWbYJrTY75RVymDKrImZ0VNcrz6vw== X-Received: by 2002:a7b:c767:: with SMTP id x7mr11173291wmk.62.1631537444121; Mon, 13 Sep 2021 05:50:44 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:43 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 03/10] trace-cmd dump: Add helpers for processing trace file sections Date: Mon, 13 Sep 2021 15:50:32 +0300 Message-Id: <20210913125039.3680986-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:33 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: 12488903 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 2ECC1C433F5 for ; Mon, 13 Sep 2021 12:50:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DC5861029 for ; Mon, 13 Sep 2021 12:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235651AbhIMMwD (ORCPT ); Mon, 13 Sep 2021 08:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwC (ORCPT ); Mon, 13 Sep 2021 08:52:02 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E42C061574 for ; Mon, 13 Sep 2021 05:50:46 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso1364356wme.0 for ; Mon, 13 Sep 2021 05:50:46 -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=kwbVVq0vXo6vYKHLJe5k96JyUh02kybHkCTSHz5M09AIce/c/YMZnsd+vTpe1LoM76 eanWscb0WVEQTD8082lcGkEToW06GmUJ31YVQGCtKsunZtbJm3N8bi27fTPBbVoOyJ5F a9GSTTXvPfdPhHPvLrL5lPk2+Nioi/uZTWcI+l2gV60j6cLRAdqNak+ppWUs6ojIw4CC HxzU4S0epsRBEBXnJ5WIQJdVPho8UtPQoXDSqYzxZDIKo6LgcixY0j45kPQCuEhZMMJh IeJs2Ms6sBmfCZG8fNQJCR/DYZfulB7FJIwV/0DRRG8szr5eKUJLown0WEl7YypCeJco aq3g== 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=KEphhHLdJABM8MvzJztkwEHAqPhl1+hd6yg6FiYo4CtDgB11o40nl8R3ftY//X0URO AguXPsyr08JbqJk2oGZDeGCb4XrkeSe31L2IhV+1xiih9Ft10l3il8EOujNd2vux8VGz MPhnX/IGaCOZTsDzoSM5CYM3H5GsLrAu8GiJEqOno3iNtQRYZdB1h0z6T7U6i7q4dVxp 2SoZp1er8n6GjtpJ0fCxU3muU2Ei+CDv8JAH7ODCmqZhgF3Ex94mM1ohB0HM0BXF6Bue XbrIaovepKKk/5C/hW1JqyC0GR3YmFqQVxULllk1f921u2QbJECZcOVVz1XcwYrMxiOQ r3kA== X-Gm-Message-State: AOAM532PnPDFFrYl07v4WqvOtuRc+78CCe8SqFwNhRhBaFTxHTOt3vTp jVx4v9eegcP9GxJgX4cdAKXpWxKo/cs= X-Google-Smtp-Source: ABdhPJyDt488O/daOEOAQ9ZI7JOQf5MGxVI6t2w6rqmS+qyaJlcgYyW21IH2Iqy8JmMSv1Uy/LKrEw== X-Received: by 2002:a1c:a78d:: with SMTP id q135mr11072827wme.36.1631537445011; Mon, 13 Sep 2021 05:50:45 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:44 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 04/10] trace-cmd dump: Read recursively all options sections Date: Mon, 13 Sep 2021 15:50:33 +0300 Message-Id: <20210913125039.3680986-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:34 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: 12488905 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 41484C433EF for ; Mon, 13 Sep 2021 12:50:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25F6D60FBF for ; Mon, 13 Sep 2021 12:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbhIMMwE (ORCPT ); Mon, 13 Sep 2021 08:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235668AbhIMMwD (ORCPT ); Mon, 13 Sep 2021 08:52:03 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0FEC061760 for ; Mon, 13 Sep 2021 05:50:47 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so6518745wml.3 for ; Mon, 13 Sep 2021 05:50:47 -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=IrTozp3butQRTdtigysr57u4tOZ1e1XnN9PaWYEZmDNqqAydi5lB3QZSb8pyUo+6qQ jFwg/DTpg+z3UwQKBHDq4n98qWWSM8/VH0cRobNOijAFL5mgcy2iZozea+TOv1lZO4LK DFTX99nUHF6RLt24RRi0o6lAsNCUxQ/U9MGRP1kPIrDchhoTz7+PD1FZtgfBfCIRWikW kjzUwNv8zdM3p/F5Ko2pd7/jw3fTVDwg/Zv1Oi/6VTfEgMGaxH9ePa0HHAhW8Eyjc6p5 mWIKu0yqUIshfOG/7/DMgbI/Bod9hDqOPV/xm6ocu6jfJsBtZiWDsS4xdmTCB0FpViWR //WQ== 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=g5T5qqZGdgp2lEhd0rPm/fxl+XVUom3m6QGkZMQBLzxSZGMi3++4aYFIPk4W2aqDH6 aUrIvb65qRgCANCL5H+tlvzyhgc9V7IXyk09HL7E73zmp5lue09N7OQ2uLO9NkLfeans MbJRk0kObRxz+0mVB0ioPEMVJHzb7lZZGiCekOyRxV86ovp2Ux/lNnBn6OiUAYb6O9A3 h/pbozUyUZn8NeLg4k7lbWy8ptaCZ6rHi3cFVnupWDRNcKR2Qx7SDj/Edas54sab4wOC 8XLvygbvmsVWSDaCbe3KwH2Kned2lm0D/VbBrHO24wX6hVt5folE9/Im6hywHiC3vZ/g mf6A== X-Gm-Message-State: AOAM531/h/Ce1QkgqlPQu6SGQGc1TeOcbh8WRA0Ccu2/BAP+n414Exrd udQwZN1zj+WAFoTHUEUIcxNgHcYSa5Q= X-Google-Smtp-Source: ABdhPJyD1WUCOkpFkkIr13BM+4n9yG6xL5w10A9OUWuNaVZUFfENTqg0l0ZgIMMfUQFlCJvjVpxVbA== X-Received: by 2002:a1c:f613:: with SMTP id w19mr10843899wmc.9.1631537445940; Mon, 13 Sep 2021 05:50:45 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:45 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 05/10] trace-cmd dump: Read extended BUFFER option Date: Mon, 13 Sep 2021 15:50:34 +0300 Message-Id: <20210913125039.3680986-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:35 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: 12488907 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 DA30BC433F5 for ; Mon, 13 Sep 2021 12:50:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B78226101B for ; Mon, 13 Sep 2021 12:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbhIMMwF (ORCPT ); Mon, 13 Sep 2021 08:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwE (ORCPT ); Mon, 13 Sep 2021 08:52:04 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B8DC061574 for ; Mon, 13 Sep 2021 05:50:48 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id g128so2136600wma.5 for ; Mon, 13 Sep 2021 05:50:48 -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=DbK3ASlCFry+hUXZoMIhP7+tgDeyZakbIVWsPTvOui/HYKd3o+z9YDLQzWXsRLs+C3 IRB3mJ9c+RYTAEKZcvOxHO/mLaBAeO/k4Vp38RCQDDlnfgplcs2LpLvhgHdYe1Cjdgtm 2WYrgwzeIPFfxAdlUIOdiG+xp/fIG3FtA5PxYR6TuM0NTzM1rI1BrdJENFxh1MMqbKAv LPsKqpx97L2jm27ZaSv6Ib4n/whFPYVUKuHBxkzg6BR8K6to/KEUhkyASZQlMor3ynEN a0zKbjZDtPlH35T703NX7pmMPhaLfW8Z5mg+QuEC5X+jxsJCtX3epBMnc8R9wkqJ7m7s Nm1A== 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=Mh7ASr5jWA0Oo5ASPaO8u8+3ykIP8tefKQzHLA6JB1AqOj2f4U8RVUimNXRudMzJQC BFtUE7WqGZJiS3Ari/z74p4hZ16baofdVhSTNip/ofjDA7sjHCe3UuAgc5z3WyjFcSBT T7OirE/e1mMiJH9+xqE23Vcf1WqB09zCPeGgSW+ckofEdzLd5COjj3EWdQS2E2sunPPT yFErTE20UI3xoR5xPyDm9V1G/S3Ix/fMVnYPKnLXwwnFtuNCXw3DhAT5SUybu+rvmQZ8 IbCEc6Z/VTLbBjBKlJYMYPF4tzWypxYXBap5VLYLxa9XrB1Xf/9qWuLqFORenC4CyGLC Mh8Q== X-Gm-Message-State: AOAM530Mrqwtr7n8mU8FMz4qhVD0YHe2k4JtNpzILP8gfxu8jQN6lBl4 A6oepwZtB/UR1aqZBU8ve6du22OWioA= X-Google-Smtp-Source: ABdhPJwzP2m6cR3GYvo08lFITUYQRQ6FO4oooVEW4FTPOdn+hkm0gAel5xTCI3PNDZoNzes6yI0TNg== X-Received: by 2002:a05:600c:4f85:: with SMTP id n5mr10858464wmq.1.1631537446901; Mon, 13 Sep 2021 05:50:46 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:46 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 06/10] trace-cmd dump: Dump sections Date: Mon, 13 Sep 2021 15:50:35 +0300 Message-Id: <20210913125039.3680986-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:36 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: 12488911 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 25E28C433FE for ; Mon, 13 Sep 2021 12:50:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0932760FBF for ; Mon, 13 Sep 2021 12:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235759AbhIMMwF (ORCPT ); Mon, 13 Sep 2021 08:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235736AbhIMMwF (ORCPT ); Mon, 13 Sep 2021 08:52:05 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 333ADC061760 for ; Mon, 13 Sep 2021 05:50:49 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id n7-20020a05600c3b8700b002f8ca941d89so6525607wms.2 for ; Mon, 13 Sep 2021 05:50:49 -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=YASa7JpeEqHPKUOc5kUiX5zexD17YdfkCMUA+1JW2KvHnzmGX5w3MbIRbZRuk4STFp iGKLRq0267FdAXgBY/K8skWMB03EtATjmqEoi//LfMBdSNgif1wyA8jfB9otFQT1T1Ed qhgT7CUxMAdHtZ4jVez3hUi0kAYGJTGGVLlBQLJMKZslPJBxX/kvCLuX3p7gTccnVjOa kUB0lgXp3yLUngcAgBIajf5ZueNjfKVwwP5EdJxMLqFvw4V8phOIgtD7Qmy20Pcw3QsA Taxaz849lXMscq8FlbSarYp6k04U/nFMhWlyVHshcIyvLyTJ1/EUqrKbwSvshcd5WCCo 35NQ== 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=rf0I+Q7mBkvXDjEWZxhJ0rsEPK+ioEg8JOTJ0VKI4In2gSh80/ShpJpNOHNeerAsRk 2NSW2GscwMh/pCx5wTRSlBz/qH/jWGsFPU03YNwECJfQf2fvByc/2Esj3rnYkrs743Xc h5xzEIzlDAE0xtlYQbhdm+JQLvDSXslFliMnCv0xvYFtbHYDp2CS9duRjMx5IP4cC8wz kMX9LUaU4FVMnxDgLCJeo+NGv9XK3s3eujFfCa+vnPcpxYCliRgSGAbYg4fKgqKv7TLi Q63HgImbGikfoa8ZQoSAhcp7TOcmLWgNNF7Nctq5YAHKxlnp3/ZxXLw2zfs3+mu2KMHe 0cRg== X-Gm-Message-State: AOAM533itD3ONLx0q+A2mZgXtQDSnD6vx1lR13MTlUACuAZ/e/uZzQRr wOvoYRbRhjA1p4OTyQmTDLYwAm1KpZo= X-Google-Smtp-Source: ABdhPJyj7OZxw4G+Z/fgjVmH6nVcd7MeemDCK6Y1k6sDELkACdcczPlbdNfiC+i7wRngn1lcSQAmEQ== X-Received: by 2002:a1c:7f84:: with SMTP id a126mr10863161wmd.33.1631537447799; Mon, 13 Sep 2021 05:50:47 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:47 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 07/10] trace-cmd dump: Dump trace file version 7 Date: Mon, 13 Sep 2021 15:50:36 +0300 Message-Id: <20210913125039.3680986-8-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:37 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: 12488909 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 7A177C4332F for ; Mon, 13 Sep 2021 12:50:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6057960FBF for ; Mon, 13 Sep 2021 12:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235736AbhIMMwG (ORCPT ); Mon, 13 Sep 2021 08:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwF (ORCPT ); Mon, 13 Sep 2021 08:52:05 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14483C061574 for ; Mon, 13 Sep 2021 05:50:50 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id x6so14492210wrv.13 for ; Mon, 13 Sep 2021 05:50:50 -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=COCxXX7ANE+opzglp2j+ihn+V0x5ZJHIeRNqd7WXPgxj14zh0P2Q0Vq1OKLepiU/+v Jgz69Fy41Ql5jens563nJpsGWvS7n1ZWORSXJsRqvWT62aN+ntHAxMKCsggL15fkJCj9 e1Nkt4mCKTgJN5U5pA4iKc9Ms+ep4yp+lbVTxnMEYs+Vkt1g+IfJ9P4Otlc2+pw9lJhy RNsUPPHyEPVjEQk7QcqYQvgOJcWCQPpJGW0kWRm/sdB7PE2zDsREHRO7czoH/tw5Nv1d Wmk2oLeSXUzOAWtEyao2uMG0XtWFCEjMHqcxJCCjJPweCZHunjS7sMThCKn+e+wQEQoQ ZLsw== 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=jtjuprVC9Shj/Yj9oporpi7MRniuAckVPoR4EDI6LjvBDSY9gXW8E0fq6v3t8KL1wq ocSdL/jVD8F0TT2oWjbJh0UsqWG2YsyGl1+sP+TgCLIUvRPpBMSSLzbM+2NWmqCmaXcu wWOBj/3QVkXrV5cQhaLGWxIOmY8NJh5EcUlOpIkGY7l4GeHBhfQFsIvOxB0aerawHW1S LJ4XpVooHXDGqfooBHOoRF218u0rN4L5brSJKpBKarcy4cNi5Yn2Jc1ehESyQy0PRfaj 9IJtXXo5oP9xjUrcwJYAlLih1/Ow0PYjOSrPK5koAbK5tL4ymoHRHmrISu4CvgC0g0iT ixFQ== X-Gm-Message-State: AOAM532RBxRbvtMEXVhWFRFejCa6X6+6JtvsDQRLyrINHI6z8xN/3eLI KW7GrpC6rA9wnRspY84pLJ4EaPXagK0= X-Google-Smtp-Source: ABdhPJwgHJ5jg++VQ/yNtaTFAiO8pCcVReRkVp/9VybI6xQgpvYpyrINHg/m2qzibdDvLMu19Mo2fQ== X-Received: by 2002:adf:90d0:: with SMTP id i74mr12557463wri.185.1631537448735; Mon, 13 Sep 2021 05:50:48 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:48 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 08/10] trace-cmd dump: Dump sections content Date: Mon, 13 Sep 2021 15:50:37 +0300 Message-Id: <20210913125039.3680986-9-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50:38 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: 12488913 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 658E9C433F5 for ; Mon, 13 Sep 2021 12:50:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5141761029 for ; Mon, 13 Sep 2021 12:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235776AbhIMMwH (ORCPT ); Mon, 13 Sep 2021 08:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwG (ORCPT ); Mon, 13 Sep 2021 08:52:06 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06DD3C061574 for ; Mon, 13 Sep 2021 05:50:51 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id m9so14541442wrb.1 for ; Mon, 13 Sep 2021 05:50:50 -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=JjDdfN+9Qqr03YbmKx1DxwnHWC2qDl+ev+4wpUgPTT8PDJE/KYByc3LnDUW94Mmzy3 oKO2OPiTDbj5IwW4bwWDUkoxALA3E+FgvW3A7yiSldG/3YktJ2Os1pIjTH7m099yn8Yc hzMSEtXpNbzZH26lq3ijY0ZQIOjwXEWXvc4kc1gH/vCgtC25zIXMRNTHBFBNZUE259FM nvYDYFv0XijTHGnSxIDIPz25j5m9VJk5IqvRtbSe4fpDD9NY8ir3zIiyUn9XDczrTUL6 JoQfbg4nDhOo+8jzABIpF6vPOl7E1+h+BzID6vIamgXybEhStrVzM7bJStDoMGO0om7a MjbA== 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=ce/o/1CGQNKx0FPph8LknRuUhQuTpGhFuiVbDsIIttTdVIeUACWjTA1rQSUbSRB2z8 hht2T8YdVqK1VcO+OGDUi/QR0jM+WnKq3BqSSGIhKLpRNRKVO5IKcnAi4/VWEQ+wJayO Di2twOmQgPHpKAVvH2vlZ2J6iTFXkG0rg1NpsmCSA5zZbibgNg52Uo5DdpzoUGowIlrw ko34jRhcodBieCNHMOLQeeYxYOtAQzIF2XheY/FnYVLEg2EYSHqz1YD6Q5jKBAjtq8J2 LUCtiZ2+QmBly2X3IG11a7y6lAyY+GBeuj/sHUYs++1fwB6yscJGpFmLS1FwM491yy/E P81w== X-Gm-Message-State: AOAM531EaElo4JFe96EUxwKpYztqAK6LcAVcxJNop6HGXte/5NBqggS/ C1ZHw2LVOY5S6VieuXi0/khdrRUFG7E= X-Google-Smtp-Source: ABdhPJwo+GzpGBoNFIBVBva/fZh1lR8IyLpX6Jy6Fk6tfZi7VAZZ0bshk2w3QXeVlcbkIHJAW+a4wA== X-Received: by 2002:a5d:56c4:: with SMTP id m4mr12525866wrw.225.1631537449616; Mon, 13 Sep 2021 05:50:49 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:49 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 09/10] trace-cmd dump: Add new argument --sections Date: Mon, 13 Sep 2021 15:50:38 +0300 Message-Id: <20210913125039.3680986-10-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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 Mon Sep 13 12:50: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: 12488915 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 2A5F2C433FE for ; Mon, 13 Sep 2021 12:50:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1892D6103B for ; Mon, 13 Sep 2021 12:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235818AbhIMMwI (ORCPT ); Mon, 13 Sep 2021 08:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbhIMMwH (ORCPT ); Mon, 13 Sep 2021 08:52:07 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4373C061574 for ; Mon, 13 Sep 2021 05:50:51 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id x6so14492392wrv.13 for ; Mon, 13 Sep 2021 05:50:51 -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=e+wr4oXhtZfvH2atrv4E66yY9NTEhu3ayS69PgpfArSZf4p/u4zYekOYrc1GPsbmfA Wxess+/6XVEEujqiBmumNFncuzlWoNiT9tb+nTC/pE/9qkz8vxzrsZGQXsQ3UCdYJgRM YbDVecYc1PedCOKxB9xl11W+Zzhcw1Om797murpnNWEPeX/ddIsFBAbvRTVTb88sOrP7 2Do5e8g1qmiZvijZURMuBKF7oJ0rRk9mWEA+TbUq8+mZkm32DGioegW9Au+cHr1HjF9r H7SA8G8ZrxIHLznH/1dsFoagjCGNqNZW2Xbb3T524vyjUTxv10lr1vRsXlAZSwCaCmlz ydow== 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=uY3v1yxxhZMeBn2MKOVcWup9bjN4QpPEOwkf7hbgIZHSoHOR+kskV2xfGOR/r+xG6Q X02vZedno4f8UgOZtPurTsTE2+SLLTJwN55NsNoEpmu0K5m0J99Tz+d7tfGBNlriUJ18 txnqXyuqXwg9cUxDzGx1WTscVHTczKCkO8QYe2m4HR57MofTxjy0kVo8HyrCEtJsdR4E XYB/n3WSMOK9hvaSOzs5TSFNeVHtwBZQJCCdybVfd9ZcF5lUo8/JdBFk+AWtgvvntIko tD9fxuOdlbmyf4GGrSD6t4PrPfaC/F+X/3S5UMMPocDDUdsJeJm871Zv7L89ID0heOyW KF9Q== X-Gm-Message-State: AOAM5315NkG68cCIhGCs/0PHYab8oO96ZCuxJAUMFlpphd3BYVuVSsIs MWyxqTyoLbtbb4t2xYK1GUJHMdGSYqQ= X-Google-Smtp-Source: ABdhPJx1mVwl9zrC9gMZPcwfO/GSCCJm9vqr2gvXz7ah/w34/zkVzhOCyXwuH/jlMcJp9bkO6RFF+g== X-Received: by 2002:a05:6000:1b82:: with SMTP id r2mr10941760wru.113.1631537450435; Mon, 13 Sep 2021 05:50:50 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id u27sm7756448wru.2.2021.09.13.05.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 05:50:50 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 10/10] trace-cmd dump: Align better the output of flyrecord dump Date: Mon, 13 Sep 2021 15:50:39 +0300 Message-Id: <20210913125039.3680986-11-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913125039.3680986-1-tz.stoyanov@gmail.com> References: <20210913125039.3680986-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);