From patchwork Thu Dec 2 12:28:58 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: 12652503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 158DAC433F5 for ; Thu, 2 Dec 2021 12:29:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbhLBMcg (ORCPT ); Thu, 2 Dec 2021 07:32:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240508AbhLBMcf (ORCPT ); Thu, 2 Dec 2021 07:32:35 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4F9C061757 for ; Thu, 2 Dec 2021 04:29:11 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id w1so115550127edc.6 for ; Thu, 02 Dec 2021 04:29:11 -0800 (PST) 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=9oXXCwAzmHcpVWjxzfY8kimTg/T2kFD6d0BsjQXDCWI=; b=b2GN4TJIVcdlHiDTaEJznvV92ZH8nl2fWoPffw/jTqzsWJ9jVQaFzntcLIFzUjC9qg 5jJjlcY1qpHd/YVyQE8oqdTQpAjovhPhFxGkuA/M+qIvp2eEfHBr/baiCaTHldMHBGRc ZOxPn6eJmcqhMOPiVGFAm4O5ynkpBh/JBU4mRGSeDNXYaXnNOWyJLumcKPLNYubl3PNp Q0Y7H7LdNMug/2Y6cyxtvHr1EN/TNF4VaVEZRvcMU3XCb7lBLzqMeXkghdwEQAoYE7zv DLXgv9O37FkO37FV0wrB6buB16Y3MYHedvQx2/N4Uu+gAjcFTHluiYM/iZP6nPgCdW0K 0hbg== 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=9oXXCwAzmHcpVWjxzfY8kimTg/T2kFD6d0BsjQXDCWI=; b=RCY1f/Ccdj9dapTWapVtCaOHFFvDMLMwoySUqcGLwtHe/oeyjChjPIEzUMi1X9WRus Whucl4/Buzfvo/64d4gQvHey7l6wIYageVu6tV8KSpciqiiE0I8wSW1vbT5enwfFuzpp R4f2wJqPWtGN9zB7SPqlWaT4jy7yrofQuHGkEFsbnMOrChcBfVhvFNq0PB0HrsSb2pSu wff36T0DguXSXc3y23VFyc2zfdHPma5ZcnIWupa2Zi8wwL7I7JpXYdAfLhBBwsN5mEH9 mpsNSIirjjUjcZX6+YKaejU8LAC2ajVOHJ5HtdCkrQyR0itLdXs6wJqWlJZMsPMR5Phm 5gHQ== X-Gm-Message-State: AOAM5339tvmvh+li53PPNudYOpOo+o45cfuATy/l2nxmekXPK9pRweOb iy69iYq92MJTp0tarvEPbyaPDXMzj7SEaQ== X-Google-Smtp-Source: ABdhPJwIYt8CXb8GfnWz4sSiRJaXKhZuMPjWuIp6ybX7RjZE0rK4ES17HZ/lfwbR5r5ODfQKHHLmmA== X-Received: by 2002:a17:906:d550:: with SMTP id cr16mr15255463ejc.544.1638448149688; Thu, 02 Dec 2021 04:29:09 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:09 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 01/10] trace-cmd dump: Add helpers for processing trace file version 7 Date: Thu, 2 Dec 2021 14:28:58 +0200 Message-Id: <20211202122907.44008-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 b19ce89a..75e40911 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; @@ -623,7 +669,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 Thu Dec 2 12:28:59 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: 12652507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1088C433FE for ; Thu, 2 Dec 2021 12:29:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346826AbhLBMch (ORCPT ); Thu, 2 Dec 2021 07:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346814AbhLBMcf (ORCPT ); Thu, 2 Dec 2021 07:32:35 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 311FEC061759 for ; Thu, 2 Dec 2021 04:29:12 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id o20so114625972eds.10 for ; Thu, 02 Dec 2021 04:29:12 -0800 (PST) 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=2pB8ZvqNIlqoaTXy8qeSvxTG+PBih+zcah2HllOhwAE=; b=Pnh3sMYCwG5q99AVaU+lui6MYmYvZ9Z4iLOWMqKPYV6T6mr4LDD1hIodYzZmKqsCOI QbqcYB/V0ZbEfqXm9OPkeR+J8IDgR6Uf5DM7FVZtXPDWZoI/e1DrCSTKdp+wgPifcOEx BQdOa0hj3vdBnF5MboeLBM9WcD7yKLpk/E86BvNs8JWbtZde8cPDBaeOlsowGqbcJ3Ve AKuOnZBge7ih3y4f8ARk4dPh24ONjdwXxCS7XW5liJ/LlZ1e7f5SO0jqTkJyUt6d4OEY aV0pcPmlCtIG05jfmbXbIa5Ms3dNooePtXeRWY+FCKhz9XE6DnKl5zqzPPnn6nSSXHSu xhZQ== 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=2pB8ZvqNIlqoaTXy8qeSvxTG+PBih+zcah2HllOhwAE=; b=t+g/zxQcsUHqQcNNJR0I7Zj3B7yV8sMfZ+RkhtRnck/1bFPK2MNhog2fCiZNh2J/FQ xFTpqTJpovQ9WlbwWXGZL4pjLVEh8uot4hcHHo0XlxUUzjLBv4SRCl+/SL2RckV3RurV 1oSv012QsU3PSfWNr0yU7hagtA32qsPsCmLMod5CoRr7V1VXd3GtG39WbBr87CygKHOw sz3ao5Qe/ryRGhoXAu9/y5ztaxeEmWJfq/NnrrUoMNskdmv1SJpwAcO4YkQFdEoD5ZOU zJjtW8aU2xTaShDunRj1dAGUUnbH3b35Z3VW/t7bs3zF7XINKga5OMgT+FmeOBMM6vvx 3KEQ== X-Gm-Message-State: AOAM530R1nteg25B6hSG0vd0P/1jAgLg4iEC0TX2Z/CaQdBulF8qvRNO 4VZ1gtnIap1TEiJ9w1r/h4vigo5izGG4+Q== X-Google-Smtp-Source: ABdhPJyeEUXFU98CB//5UMjs+bsaGKVNGx4iNFJEURvJWkyEBSEzCnh8cyuSiXCxtP2hxXqizBAkGg== X-Received: by 2002:a50:fb16:: with SMTP id d22mr17608481edq.367.1638448150814; Thu, 02 Dec 2021 04:29:10 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:10 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 02/10] trace-cmd dump: Print compression header Date: Thu, 2 Dec 2021 14:28:59 +0200 Message-Id: <20211202122907.44008-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 75e40911..a1fc6d7b 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; @@ -760,6 +783,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 Thu Dec 2 12:29:00 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: 12652505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E593C4332F for ; Thu, 2 Dec 2021 12:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbhLBMch (ORCPT ); Thu, 2 Dec 2021 07:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346825AbhLBMcf (ORCPT ); Thu, 2 Dec 2021 07:32:35 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4599FC06175B for ; Thu, 2 Dec 2021 04:29:13 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id z5so50321468edd.3 for ; Thu, 02 Dec 2021 04:29:13 -0800 (PST) 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=/LcOcTAQq/E0EFpf44euFOpIpRgzGloaNazoVxOO5cs=; b=MwAPTxv9ToiollQ4thYvKi2cnOaM9oXqne8T3cbKlYc72HR2ssPAVOw5QCbTitOE0A Ay4Z+ZhQvhrDxPZ7KyQFsGpj9mFwxriG28W+BjqvA16HBA+ipwpRDN20vNxrqafLJlW+ gfpi3NnwD0rJl+JYa8fTP/QGkqGi1toV9l4kfpV1wq/IslSnWCfCYszAHnX3fmNtMXpj PPkJ280BqgCEZvSExugMgHjr4xRGXb93Sz69O9AAXUQrQ9DnWN14F/CElt2xr1wAHmQj PhGb1FbAIiWa2jjkKU56DkuxA94LH5gwGlEIvpCwY6D6FqtyI18R/GL0K5Qvv9Me80J1 j7pg== 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=/LcOcTAQq/E0EFpf44euFOpIpRgzGloaNazoVxOO5cs=; b=5F8nIF5L7R2EOIGsgnkV40NvXB8HDORTN7LLLvuARNgagU9N78ITYkmXrCyzNP2Nkd rtu21UvO9YJtxX7M8elmJBMPRBOJDPn5lEM2bKJRnAtSnKAPzVsHBlAmxc3FN8H8Bs5r BYCJ2ivIwrAYdWgfHG9ojseSwagTcau/6fwPFIsjvjD0C+vhMu9YC9oMxE/DV3ltXQfG ckmZDva3RyCGOxHbfhFePJSf0Px9z5w0l2/g/5DZvdxWBmWzs5XHhGv4lS32NnVFNwur ETjquDLO4JPIy1zPbRqLMg3Wt13TXfLg3nCdsRGVM06wPazhdywuTqEZstMIYrTAgLX4 lLlA== X-Gm-Message-State: AOAM533ZnZ40GCUDr8pgukziGpVZb15Db5alc/7wj4F1gmi6cJQXtDs5 RvrBbpITvbd7bJ0S5TSt0gbmBvdu7b1Xfw== X-Google-Smtp-Source: ABdhPJzBP+oWImuv+kMnvCJg7TA3msOXlcSj+lBncmfPYRF6FVPQ7LcO66HzayQ79omnLONgrVWgcA== X-Received: by 2002:a17:906:794e:: with SMTP id l14mr15490463ejo.64.1638448151831; Thu, 02 Dec 2021 04:29:11 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:11 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 03/10] trace-cmd dump: Add helpers for processing trace file sections Date: Thu, 2 Dec 2021 14:29:00 +0200 Message-Id: <20211202122907.44008-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 a1fc6d7b..e3c40a0d 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) @@ -768,6 +778,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; @@ -793,7 +814,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 Thu Dec 2 12:29:01 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: 12652509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4019C43219 for ; Thu, 2 Dec 2021 12:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346808AbhLBMci (ORCPT ); Thu, 2 Dec 2021 07:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240508AbhLBMcg (ORCPT ); Thu, 2 Dec 2021 07:32:36 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 318F8C06174A for ; Thu, 2 Dec 2021 04:29:14 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id y13so115259775edd.13 for ; Thu, 02 Dec 2021 04:29:14 -0800 (PST) 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=PH/XyhHdUEZTPFiWA1EBnh+dtXsTepoAuGsqMwaJ0o0=; b=Rdz/wMP0Fg0Lv7o8PQkZhLheMTm/aL+ZsLvWimFdDP+If9Hh5TebVKq6ydxgQytTHL 0WVM4w5gur7dss+zEFfsivQRSwFK0PIQigs8qFHhT1rFRwGMnUMIc2D1i1wpFT3ppWV3 +kzT105A8z3VGorDcwPsaKZRXpULI7ByA62Bv7ol4kBmnOrQmwwEk+xRn9jrjt6e5CU4 cVm3zF6Whzj0Tj8P4Xr4RpBQzB02u8FxVrSuCILBg0DbvN2NHzdCaV8SbsudJcz7P+Vf NEPEmFDmBoM3AkvMtGbDg9GqJRFFViG2cAq5Wgs3B0MV/EjALxUsJozMbsJBxRaroZam evBA== 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=PH/XyhHdUEZTPFiWA1EBnh+dtXsTepoAuGsqMwaJ0o0=; b=4A5iY2Oyw1B9QhQMFg4b+nrFuwtcBechwUIOtrYFoLQUi6y6SJHHvy+rL7nWArEUv4 FTJP5KNgcMKAd0+Iwx+fh+m2HXDMDGiZCGKOXGl7T4oPSttWqBVeViCZC7M+EUSDhbqF +hUyEkAmbVpHpxcADozfxWIPBiCO93Ee42dlmBZVM06g6sO/oN534CXIas54HFHLxaJz pACdI6T8d30zqG/evLVpOrb2iQOkCPe2Pco7YTSq2V6CmpwEStSiYY45nEmYXZ5EsMO9 XurArsNw1LejB6Oe8O2lUVREfmf3yUGJUUo+csJkt7s41393p2FSg6iRCuseZXYPBmOI 1Hwg== X-Gm-Message-State: AOAM532X+KHvIpd+sb2ambo5JUILfWjo5ONBTjLizEWGHcjXUXBGsQV+ kRQL6I4MLvXvq9hkdc1Bm0ixjDFUhO6u2w== X-Google-Smtp-Source: ABdhPJxoojIphzMCUMQSc51vOviys3bZEGTOcNkuVolxKe+wFWmCYpIhYMgcxCAD8lw5A7PMJb89kQ== X-Received: by 2002:a05:6402:12c1:: with SMTP id k1mr17209044edx.355.1638448152814; Thu, 02 Dec 2021 04:29:12 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:12 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 04/10] trace-cmd dump: Read recursively all options sections Date: Thu, 2 Dec 2021 14:29:01 +0200 Message-Id: <20211202122907.44008-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 e3c40a0d..a808c7d7 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; @@ -636,25 +660,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"); @@ -666,7 +713,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: @@ -699,6 +747,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); @@ -706,8 +758,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 Thu Dec 2 12:29:02 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: 12652511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E1E8C433EF for ; Thu, 2 Dec 2021 12:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346810AbhLBMci (ORCPT ); Thu, 2 Dec 2021 07:32:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241394AbhLBMch (ORCPT ); Thu, 2 Dec 2021 07:32:37 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FE99C06174A for ; Thu, 2 Dec 2021 04:29:15 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id g14so115310698edb.8 for ; Thu, 02 Dec 2021 04:29:15 -0800 (PST) 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=QPIUFJpkqiAuUFuCW3190ZdxIDY1q5QX69WLW69uC4o=; b=QozDMcuJJYoJ0j+tzPIjWHZlDTHFQR/UUimLtdE2JTyyVd5+w78U7VjFVZcdRYlfnD KETSIRVQRKYdMsGiFnQKaCCFxkxhOvyL47zUqJl3AHs0WdONdhdVPuYSKNlTptq6x7xI hfBWuPtPgB2E/VplmdmOPhJwV6mjx+umTbNMM0PWov5jhNCV1vfYNdgjYDrdoOen+xUj G/xPm4XrBmcvKY2ZDmt6A2P8zX3dUuk9a8ol+JECQ9QPYYSzrGD00t5RAtqTuYZ/yxt5 qzFJKDQ/vfc641lFEqZafpBnDY1Y1+5BqlQ4X0ZrKYZ1d1FzQYkLdjkPko5FvWyLquVU fwfg== 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=QPIUFJpkqiAuUFuCW3190ZdxIDY1q5QX69WLW69uC4o=; b=CtpPuLwZNeomeb2l9XRoAAEvhRrMKOE8su31ye251fY3sMK9e6yGYP5qw1LKkORrWg 6m8ri18MZjVRksaSBUkywCY9a/i2VGqE1004xw9Hm9nIe2BJPDy5XTR6P8FuE8JBNRX+ AaAuEXudn9rgUo8MO7OedjWCM2drsKu0TZEPmv6iDz9cZgH4j+VVtYlZhjjKC1BAQytF A22EF8W90Jvg6kV1p5lMxMbSudXGFwPvBQAAzUVdecFW3G++NhUPcHgCySa/GLwJdui0 3ahCfpO/YjoXkUokJReQhQRWrxPOKLfwjO1iG7nT4p2KHsOtcJtpbRh7b6kV5mGerK+N usDg== X-Gm-Message-State: AOAM530ph+a0T84HnfetIn0+SjtUJUE17SIiQ0WDrcN8JjYicsAWS+vJ TJ3/n5Y6XyCnYbPJNEIqTesD1ot+LvI5OA== X-Google-Smtp-Source: ABdhPJwy2nhHTh/fYnJuYAn825z/hmGq1IYqjwIots/nZKRey/2jyG2LN5l6+nSKYUgLgVF+9ShB4w== X-Received: by 2002:a05:6402:710:: with SMTP id w16mr17628462edx.218.1638448153757; Thu, 02 Dec 2021 04:29:13 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:13 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 05/10] trace-cmd dump: Read extended BUFFER option Date: Thu, 2 Dec 2021 14:29:02 +0200 Message-Id: <20211202122907.44008-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 a808c7d7..f8909faa 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) @@ -710,7 +763,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 Thu Dec 2 12:29:03 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: 12652513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A606C43217 for ; Thu, 2 Dec 2021 12:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241394AbhLBMcj (ORCPT ); Thu, 2 Dec 2021 07:32:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240508AbhLBMci (ORCPT ); Thu, 2 Dec 2021 07:32:38 -0500 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 31C70C06174A for ; Thu, 2 Dec 2021 04:29:16 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id w1so115550982edc.6 for ; Thu, 02 Dec 2021 04:29:16 -0800 (PST) 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=NHfFRdwp2KHFwMpvZOIB10k6MKj2ejsBTBRhj6Zgd5E=; b=pXyP+qCh+VjIyqi1MBYYz1nV6Wfeqeod+r1awasDBNrhY6kGFu7jyQn3zb2mSwoCj/ MGwj2MsXv3UFrRBWs0HcvK2PtY/RwhROSiujDiZpWYK6m+i38qiw3ruF0VGqn86MrUCr ijbMHfjPXhWjT2sWcdQPvKP9n7sWQH9jrXeYAH3n7GHrtGEoE8WxnFkOKnbHrcQCHbL/ vk80N+WZdTdoChgIZ3MFjIYyzR/yv8hg8JP0vKCtBSVt839ahv8+OPh0Tiey8AkftfXp 6C6G8+EXiLiu0pqucmEdHaq3dGAYmJF39mKQzwdXzXXYALj+cgBZ4vg0y70y+bTLiN9f LQbg== 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=NHfFRdwp2KHFwMpvZOIB10k6MKj2ejsBTBRhj6Zgd5E=; b=21sTkcKfyYcJEU/hF+HZ4oFC4KXeRmnEv1ypCK7DNZBuhoDCY6IGIS1DZuJH8ghW5U Ytdw2iwWoaxEq2DCmSmOGpU6TuSudW1zy2e10Kq/pElbnITcDwZHXXSi19pAyS+Z7Df7 6ot017BOm6rZms0fg6O5PGt9mcJivOH+ZmvT8ARTrH3WhKNzK/iPJS+m8dgRxHoZJQSg f10iOp5ZDzsa/SAfqlKoYsK0ej7CMLS3YBi99EQ7qeMBSPhwAbtF8TcMhmmPxInDIGry KlJEbyC4VejGehU8iOpdFVEW0Tg2O0qO1jE6TwKgJpZcKnQK83PmVhuTcpBO8xAPsnwx Okig== X-Gm-Message-State: AOAM5337roKSo10ljmtriuyvjRiAa+AXUnVKPpCp3QxWfGZ+V3Xarume iCJueyjn2wPK0dAZt0YIaiyzCk1S+RrXdw== X-Google-Smtp-Source: ABdhPJwUQEIbszbAvFlSLEded0DTz0leWLEJrFmXQAMy7Sr80mnNQfikw0nX4WLJNG2JSfDLk7Ft5Q== X-Received: by 2002:a17:906:2c16:: with SMTP id e22mr15129506ejh.501.1638448154768; Thu, 02 Dec 2021 04:29:14 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:14 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 06/10] trace-cmd dump: Dump sections Date: Thu, 2 Dec 2021 14:29:03 +0200 Message-Id: <20211202122907.44008-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 f8909faa..2f8cd5fb 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -713,6 +713,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) @@ -801,6 +819,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 Thu Dec 2 12:29:04 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: 12652515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EB18C433F5 for ; Thu, 2 Dec 2021 12:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346825AbhLBMck (ORCPT ); Thu, 2 Dec 2021 07:32:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346814AbhLBMcj (ORCPT ); Thu, 2 Dec 2021 07:32:39 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28113C06174A for ; Thu, 2 Dec 2021 04:29:17 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id y13so115260398edd.13 for ; Thu, 02 Dec 2021 04:29:17 -0800 (PST) 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=8gCpS+fcA3sOrLSl9R3BhH9qJggh8STZ7fo9+83uT00=; b=kWimwHVV825SGYiYe5ABqgo8sEqp71Yd2WhDYox4r8tdiqpZYHzVh4z3TYEcT+deWk HzPVAJ3wyyGnZBPzwmW6bHwhtDdXJcvh44+Vu7pqTkmlD3jE67jueb2nM+y7qIUB4+1M WYDA+f/e45CciXRdjQQPqv+Chp1sRWV8S3UhotxNhT+pxK+QqPKa+kt4eKTnRtEal51e 0SVa11XDc0omuU5jN7AkijheFYoDwbtwpwY4f2g0FFcULZmptX2atNNzCm+ZHbskWpMP 6eg0OzJV9MBcI1TsATpZtZrUb7ojJKJ4nEReEMSPxYGiaW0hyhb0Rk45oBhMD833l0gu avqw== 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=8gCpS+fcA3sOrLSl9R3BhH9qJggh8STZ7fo9+83uT00=; b=EYt9O+EjobpBMFJmYpStp7u2LH5R+84fTbFymxexerhqgqmuT9RLN+pGVh5cgRgOGH mLK5KRSGQCjO10h8yC+cmFdo+ymR1vdpejHSb90B+nKXHvdo0ywcdHZ60qw4LmiE1B6x i0RgcGz7CMn8JyV/TUPqfQWVdddKiw18IHyJjpzdVVB1Lp4I7728SnFNts6W/W5wvlI1 ThKpZmwUvm6FJ3wVWloSIbw7O+irjwQQTNBB4VA5SKfLkpmQypQ1Ner08eVatKOpeZUS k8uOCIZm99K1UBLLlBb08j9Wi9d+gkLU+OLSh4JqTv8dvrvvsq7qWTkBFm7fWwbO3mBe m1KQ== X-Gm-Message-State: AOAM531Hu2X1Nha92WQgBwN1pZ570D30AZeW9K+f9qVAqakxC85Hv1sU P4iFPAIS6Ou5r01TeLx5jDJbblB7djU+8g== X-Google-Smtp-Source: ABdhPJzBIq2bRrHdoTkvddxvXMrfq6MgvUqglufg8xKQy/yeFjZ++yPdnA6XyCUYF50EXHFGI5Joig== X-Received: by 2002:a17:906:48cd:: with SMTP id d13mr14565228ejt.35.1638448155807; Thu, 02 Dec 2021 04:29:15 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:15 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 07/10] trace-cmd dump: Dump trace file version 7 Date: Thu, 2 Dec 2021 14:29:04 +0200 Message-Id: <20211202122907.44008-8-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 2f8cd5fb..11a6e1df 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -929,6 +929,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; @@ -956,15 +981,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 Thu Dec 2 12:29:05 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: 12652517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C12FC433FE for ; Thu, 2 Dec 2021 12:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346827AbhLBMcl (ORCPT ); Thu, 2 Dec 2021 07:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240508AbhLBMck (ORCPT ); Thu, 2 Dec 2021 07:32:40 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299B6C06174A for ; Thu, 2 Dec 2021 04:29:18 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id t5so115494825edd.0 for ; Thu, 02 Dec 2021 04:29:18 -0800 (PST) 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=5tO/vriOUpiSa2W8k4G1fuBKcjRtAbnryAqq55gN4qY=; b=H1DjLbyrjPrlIG7oRTT1l52jsTGC/U5wgwNeAy5qOt5P5toO09s/uvEqEKgglfWjW+ KLCPK1WDL10tSiL5QV6OQvpwkaohnBJ+HhEI/4DDND1KLpXLganXyi25asEYaMmoICPx kWA90xdSCh6mBWGXl1dn6gDps5bC0rxIQ0iHfZyFSDghopYf51fk+bOVFjf9XcFGb/dZ 8YfdtrQ/dhy6I1sXu1tjoP5NUPGrk++GGrcm2iWIYTaQoji//LDnxW8pOozjtBnLDDs4 c0NhrNjuayoYji7nH8/k25Dm7qD1liZFfcmUEw7IB2bzcKG063oONotn5jJLHQz0v0dS ueKQ== 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=5tO/vriOUpiSa2W8k4G1fuBKcjRtAbnryAqq55gN4qY=; b=162Uuqlq8rOlCSRLebLhbDLjJVNPy4uonL8da45YdjmbfMSxZ/MEOoEC0X4YD0b73s xsp8E+pyLrnr0k/RhSQkQYNAHW4220nwUWnwT6cn+q/2T7VPaK8cqUIzU8NcZFPnElWO VY0nnAgSRftatId7jDjOdadKZvDZVKhYJKW4ZpcmQ5awIv8tMSJKg+H92W2C2dU+ZNHU vvC6DcHQXagCeJssjqY7SoD8n72UJrr/XkK1W+dSxN6T+kFEXA80K/RiRAGPVFEFmUPX FyjG4DjP2bo4n2i76YyvQ4uTtL7o3LiGs2qaLROApnOHhY2YpKBYbn8PxV0UW3XlGK+R z4Jw== X-Gm-Message-State: AOAM533t97DqBG0EQn2mEBoagxkjUI84Skr7MxisgTwfEZTg67eXmSAc J0r8pld/pXkpH7FykD+rOMB/QDKv4aY9qg== X-Google-Smtp-Source: ABdhPJxW33jWmBE+r3iWm3oqPTTRTLNTPdbvgGxbkyY7uUCX1+eTTjVvQAhlZyjUSkIPELL5tNNBCw== X-Received: by 2002:a05:6402:60c:: with SMTP id n12mr17791386edv.17.1638448156738; Thu, 02 Dec 2021 04:29:16 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:16 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 08/10] trace-cmd dump: Dump sections content Date: Thu, 2 Dec 2021 14:29:05 +0200 Message-Id: <20211202122907.44008-9-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 11a6e1df..b2670744 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -731,6 +731,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) @@ -952,6 +992,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 Thu Dec 2 12:29:06 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: 12652519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E813C433EF for ; Thu, 2 Dec 2021 12:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346833AbhLBMcn (ORCPT ); Thu, 2 Dec 2021 07:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346814AbhLBMcm (ORCPT ); Thu, 2 Dec 2021 07:32:42 -0500 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 AFB36C06174A for ; Thu, 2 Dec 2021 04:29:19 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id l25so115169981eda.11 for ; Thu, 02 Dec 2021 04:29:19 -0800 (PST) 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=YrVrPP534jX6fRrmD3ChIy6tMTByr1OJWLRo+Vo8E6A=; b=fouPx5iX9MezG25aQQ5KRt43zVS9AhRhLVTQ9KBnR2v9FuEmcw7ExE9IJJQY0XcG6/ qO2tdUtGYYJ5AV21OCnaS3gupybXEtXpgsrnCOTyKFrH5LCghT91ixNV1C0MmeJTqhPz aY1KfHXxAzx5lE1QoqfIKyZGHCV+xE+OctExHNDarJRi4NcUNJQXyxd5WwJqTapRuwVw TkIV6Wzf3rEMcpdvbzssbZKlqw61xlf91Y4imgsLCrQfpv6+OLmD6/ePhwT4RaTOvSR3 3Fw/NYnt84aOn3oZ8errHSVXfnyT7gAi+zV3+67gMHh2g1WV2M7aopziS2vH4LGIfAuX VqsA== 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=YrVrPP534jX6fRrmD3ChIy6tMTByr1OJWLRo+Vo8E6A=; b=XPO+wRnF32R+aH7LzTEhti+N9lo2XVUT3vc7KL8C0XBdYKJ2Ni4pOQj6pOMTYgq3DE ZYfzn9StMzk2xba9mHYv2D4reW7CMax8Ht9BAAgI/Y81gRqof5JVaB+Kh/7nqCVGdNvk m1jFDFkx49COk1cAW7T6L1pPch3tK6Vb+rNVaUsxbrZPACwpGLIaajFZcpX9/nBhDB4L 95/0BvRGbFPqGhqejJ28Ey1Tjm9qpu15qh9+sJuFu1jPkfaEwLUBOFkyJVoZ9G/BIs5e VUSBm4UnVuZcQKMQm0HbCzYEBPFGvDlngP0FKwJ+1+bzbZt2rTHosZR7ITb4Cy9GXxzX /fSA== X-Gm-Message-State: AOAM5336mQW9lVBO3WcMz9pW1Xz3lvK7sktYVl8hsYY4JbE1DaxSIGfz Vtj0Bq5BIxnMUTyL4z8Y2rst01t8s0DqKA== X-Google-Smtp-Source: ABdhPJwvoxi119t5tyA6Oad94xNoGjzIa1ZYzzvv2WelYo8zitsMBH3BlXw4St07gHHxhbOYDTl5LA== X-Received: by 2002:a50:950c:: with SMTP id u12mr17845415eda.361.1638448157694; Thu, 02 Dec 2021 04:29:17 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:17 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 09/10] trace-cmd dump: Add new argument --sections Date: Thu, 2 Dec 2021 14:29:06 +0200 Message-Id: <20211202122907.44008-10-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 b2670744..8986f9b0 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -731,7 +731,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; @@ -769,6 +769,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); @@ -982,17 +983,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) @@ -1033,6 +1093,7 @@ static void dump_file(const char *file) } enum { + OPT_sections = 241, OPT_verbose = 242, OPT_clock = 243, OPT_all = 244, @@ -1076,6 +1137,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}, @@ -1139,6 +1201,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 Thu Dec 2 12:29:07 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: 12652521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CF5FC433FE for ; Thu, 2 Dec 2021 12:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346814AbhLBMcn (ORCPT ); Thu, 2 Dec 2021 07:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346836AbhLBMcn (ORCPT ); Thu, 2 Dec 2021 07:32:43 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73680C061757 for ; Thu, 2 Dec 2021 04:29:20 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id l25so115170142eda.11 for ; Thu, 02 Dec 2021 04:29:20 -0800 (PST) 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=Y1DZI9vkFNa4Z9XGNeMzOagH15AKNe1aTIBjcQnDKcg=; b=mP2M17dyUKx0afBZMtwXJBfCLsIwKgjYWpXAGsPA/vPo1hR+WXviOI0r6om8Ja2d7Z 0IYWUXvk3Ipwjv/rGPQPOXYuIpBXzKBa2bzmrDzluQsWaecum+mwyMPgm82m8BD1+hlu F5IxcAN4wt7zft5/BoxkxFoGqIqpR8gb8tuazBePR8KTl9/q3Ac+ULoBtvYhZHkLd+ZU rvIXWhwD7w63rsljuoapKPIo4i4Meq3jQMjlNAm0FN70nhnbfgH+xKpwE1TDxdl3luut LExINxQ10mBz+b+bkj5R0BwC8/KJiuuLps1kzF6BjJrl/ukMn7MwgUhzPrPEgfjZ5q8Y qqNw== 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=Y1DZI9vkFNa4Z9XGNeMzOagH15AKNe1aTIBjcQnDKcg=; b=kxmyEdRW0WySwxOYO0Fjz+Bt92Ttndtpfh8/O75G2t52woBCh05AmylX4hkhxF2Lx+ zfkUZby+beWY4pd1fNr+Fb7YR6+5gUHsYLwg3usRKZ6WkG1lleRIemKvKBHsHXF49/ko K6bM7VLMAQ6alcLMVJ764ck3rlBPKZEkXdPKEqOknf1LP1e0o14qsy8z+VnGgbOu0xny 4Th8tQrwazfvg+fH1q8J/0WU/MrbDLVZ35AykZkj8/IioN+lXKam/tePXXKI+CL1y9Q2 YXf3wGz7ir2GrHmANOJw8c+9xa+Gqcx2IaloM2vlHvQtRGUWMjw2jfZMAZPHPWzD6Tna QR1A== X-Gm-Message-State: AOAM533stRPmitDdd2CfjFj/80YEpngvW4zkCRSoLAdW6euPpAqFC9U8 IVtVdiL8pMjvIJ/dVlG4ay2/iA6R1ed+0Q== X-Google-Smtp-Source: ABdhPJxXgN36oRdvyBliBSLjFbc7SRSEAcg16aoLc9twasryxoYeUCta/sEDUTlHz3YZNU2Yugo/oQ== X-Received: by 2002:a05:6402:4404:: with SMTP id y4mr17069272eda.321.1638448158720; Thu, 02 Dec 2021 04:29:18 -0800 (PST) Received: from oberon.zico.biz.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id m16sm2182692edd.61.2021.12.02.04.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 04:29:18 -0800 (PST) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v5 10/10] trace-cmd dump: Align better the output of flyrecord dump Date: Thu, 2 Dec 2021 14:29:07 +0200 Message-Id: <20211202122907.44008-11-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211202122907.44008-1-tz.stoyanov@gmail.com> References: <20211202122907.44008-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 8986f9b0..9013f8b5 100644 --- a/tracecmd/trace-dump.c +++ b/tracecmd/trace-dump.c @@ -943,7 +943,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);