From patchwork Thu Sep 9 08:06:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12482625 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 D6555C433FE for ; Thu, 9 Sep 2021 08:06:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7E7161131 for ; Thu, 9 Sep 2021 08:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbhIIIID (ORCPT ); Thu, 9 Sep 2021 04:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbhIIIIB (ORCPT ); Thu, 9 Sep 2021 04:08:01 -0400 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 26D27C061575 for ; Thu, 9 Sep 2021 01:06:52 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id eb14so1459941edb.8 for ; Thu, 09 Sep 2021 01:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a1H6Ftx2grzx8WinZ9s3RVdbM7aApDYQSrkOOlpBqOQ=; b=ef62f97z1p6Y8rtilGSvhMWesQaHYocd2LFV8k3TVDNbYfG4rBBfUEHC7FXRYSD2Hx YPOW92iyNhqKScRvr31MYmYLrCE0hWHW5qiQ3BkcoDP4DdveRsSbPC+CI3pTBEASJyBp ThcvqVKM1BSIkhkL02Ws5rokqmwRJK3aitY3JzuYp0QwtFMPXA0n5PMCRfdv9GUCubt+ okPOukc+R8gUOkHLdWVGtyU9KdnozFadtKReoXhIyDfTKuKukkD/sak5tEUtn/jbkdpb gNCAhlwJM7LEqnOUmQA4AhnWn5vrFuHbFYo8ijC3VRM7Fe3zwd+Pm2hsptZNj3kiZAjn wjJA== 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=a1H6Ftx2grzx8WinZ9s3RVdbM7aApDYQSrkOOlpBqOQ=; b=qZwN2DcPIRrqWNM4Ci7oyJtu5MsFMo64Jy2djUjh4MYprsP03vTjBjpiyCu0JsOGO+ C9phfXgJi/0gWcQ/p9lRAZsL4Xi6pSriC4mnPUnuh8ataRRWORyn4Oe7wPjz0XF27w0x zQA+/mKnxTFpRRMCJIqnLXy5rQZkn4DMd4MtJFU10UaBA2QS50UBcXx0JSu7YaSdNmuO RcQw0vETIAUaCUyyxk3ttuJ30oVESmj/gnv1FqXMGA+5iNlvvy9DZRW2jNlzKK6tBrey hijDndR5p8iiNhMse9vX73kx6usuwPl+rW+1Q2TIagO0jdS2pknVgrnCrlQya0sN8MlT EVEQ== X-Gm-Message-State: AOAM530NDnSIo9/4RHk3cDIKmNH0u5PbEYPg17wdWJ4pfwZQYFNBrgiJ rFtSRSYVEIX58EdHTuq3S/zd4R2gO3g= X-Google-Smtp-Source: ABdhPJy7cFpFoNwTzcRk9Fi5c6pnRC3tbWGdyGAV5wVun5MaVbrAU0srGvh8b7NlXk4ygAdJ2oClZg== X-Received: by 2002:aa7:c790:: with SMTP id n16mr1883403eds.223.1631174810698; Thu, 09 Sep 2021 01:06:50 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id l8sm491821ejn.103.2021.09.09.01.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 01:06:50 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH v8 1/2] libtraceevent: Add APIs for printing the fields of a record Date: Thu, 9 Sep 2021 11:06:37 +0300 Message-Id: <20210909080638.259024-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909080638.259024-1-y.karadz@gmail.com> References: <20210909080638.259024-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The new methods can print all unique data fielsd, or only a subset of the fields of the trace event. The print format is derived from the parsing tokens (tep_print_parse objects) of the event. Signed-off-by: Yordan Karadzhov (VMware) --- src/event-parse.c | 51 +++++++++++++++++++++++++++++++++++++++++++---- src/event-parse.h | 7 +++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/event-parse.c b/src/event-parse.c index 51cb30b..8057fb5 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -5455,20 +5455,63 @@ void tep_print_field(struct trace_seq *s, void *data, print_field(s, data, field, NULL); } -void tep_print_fields(struct trace_seq *s, void *data, - int size __maybe_unused, struct tep_event *event) +static inline void +print_selected_fields(struct trace_seq *s, void *data, + struct tep_event *event, + unsigned long long ignore_mask) { struct tep_print_parse *parse = event->print_fmt.print_cache; struct tep_format_field *field; + unsigned long long field_mask = 1; field = event->format.fields; - while (field) { + for(; field; field = field->next, field_mask <<= 1) { + if (field_mask & ignore_mask) + continue; + trace_seq_printf(s, " %s=", field->name); print_field(s, data, field, &parse); - field = field->next; } } +void tep_print_fields(struct trace_seq *s, void *data, + int size __maybe_unused, struct tep_event *event) +{ + print_selected_fields(s, data, event, 0); +} + +/** + * tep_record_print_fields - print the field name followed by the + * record's field value. + * @s: The seq to print to + * @record: The record to get the event from + * @event: The event that the field is for + */ +void tep_record_print_fields(struct trace_seq *s, + struct tep_record *record, + struct tep_event *event) +{ + print_selected_fields(s, record->data, event, 0); +} + +/** + * tep_record_print_selected_fields - print the field name followed by the + * record's field value for a selected subset of record fields. + * @s: The seq to print to + * @record: The record to get the event from + * @event: The event that the field is for + * @select_mask: Bit mask defining the fields to print + */ +void tep_record_print_selected_fields(struct trace_seq *s, + struct tep_record *record, + struct tep_event *event, + unsigned long long select_mask) +{ + unsigned long long ignore_mask = ~select_mask; + + print_selected_fields(s, record->data, event, ignore_mask); +} + static int print_function(struct trace_seq *s, const char *format, void *data, int size, struct tep_event *event, struct tep_print_arg *arg) diff --git a/src/event-parse.h b/src/event-parse.h index d4a876f..0833893 100644 --- a/src/event-parse.h +++ b/src/event-parse.h @@ -545,6 +545,13 @@ int tep_cmdline_pid(struct tep_handle *tep, struct tep_cmdline *cmdline); void tep_print_field(struct trace_seq *s, void *data, struct tep_format_field *field); +void tep_record_print_fields(struct trace_seq *s, + struct tep_record *record, + struct tep_event *event); +void tep_record_print_selected_fields(struct trace_seq *s, + struct tep_record *record, + struct tep_event *event, + unsigned long long select_mask); void tep_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct tep_event *event); int tep_strerror(struct tep_handle *tep, enum tep_errno errnum, From patchwork Thu Sep 9 08:06:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12482627 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 6690AC4332F for ; Thu, 9 Sep 2021 08:06:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E1FE61132 for ; Thu, 9 Sep 2021 08:06:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbhIIIID (ORCPT ); Thu, 9 Sep 2021 04:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbhIIIIC (ORCPT ); Thu, 9 Sep 2021 04:08:02 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF074C061757 for ; Thu, 9 Sep 2021 01:06:52 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 9so1453411edx.11 for ; Thu, 09 Sep 2021 01:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Jh35QPcE8A+X/dKjCSF429kpZHz2xl4nXSql3ZOWHs=; b=j7U6NmOaC2BaTnekLhssENJyCPLHn4qnqWLKIpJKLkzF4RGR/0Nwln1EZEaYsARS35 nEyqLCy2r3alvERPJlGy7rZPr8kOMCtM2RSYvIdhgc1D/4fPCIbv0TKyG1Pj97kzCqiF s2G+ATuXGCr2Sa/VXvbiqTWyztTKGBxFH2++FyxBGi8PGaBlo3akVmR2ntNjJfOQVSoT icAuOzlZE1pXD4U3LevCkSqlXbT3Ojl0cqAsFTJOOl3ZsiFA1eKrW4o1zhzgsIz0XKql YYm/lsgKXkfepOwZLGQbteeD3RreV3yojEzrqCE/6snyVQd74LlTEu2PpUe8bT9OwTcA 1xDg== 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=7Jh35QPcE8A+X/dKjCSF429kpZHz2xl4nXSql3ZOWHs=; b=zw1COTniN1qCriyitFofnGH+r5CCWCPF4cL6oi1LL2CG1k1tUaD42RLyPEiGw104vU JgQiyqBC058N5J0hprz5+fzL6zEaV2lCt00a2ZH/qBmTmvye7xGn2t6SDRSCK33119eb cjiLeZtg2stwqQggmpGgog6zz8h+OGQNKrw37QPATQNRFQb8UKnRLTtQZhK3J6J2K7JV faw0wxuSXe8eXheWN/lNdiPrKzUKUl7ToTgUh61uLW2TQ71FIMqWF+68T1jwGvLN3uZ9 jvJS7WaKN2+I+DxyTvpcqoOOMtqmZ0mHkaWmqFTPjenvnlbSfWK6DaNkmDANUyvUUZWg +Faw== X-Gm-Message-State: AOAM533sdjrkR22Hekp1ru2Yt0vppp7dlOPQCq4Z8fE8rOrhT5FIxjYZ IGQcpchONpCdOAeKjhQDLMy/aVDjvv8= X-Google-Smtp-Source: ABdhPJxY+3Ne2lIg8huyLgWLQrbh3vrOSM1+dgqsAU5wn+FxDpqBcVX2wNpV5lRGOkEyYGembTWxAw== X-Received: by 2002:a05:6402:1438:: with SMTP id c24mr1404247edx.22.1631174811623; Thu, 09 Sep 2021 01:06:51 -0700 (PDT) Received: from crow.. ([95.87.199.93]) by smtp.gmail.com with ESMTPSA id l8sm491821ejn.103.2021.09.09.01.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 01:06:51 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH v8 2/2] libtraceevent: Add documentation for the new printing APIs Date: Thu, 9 Sep 2021 11:06:38 +0300 Message-Id: <20210909080638.259024-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909080638.259024-1-y.karadz@gmail.com> References: <20210909080638.259024-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org 'tep_record_print_fields()' and 'tep_record_print_selected_fields()' are documented. Signed-off-by: Yordan Karadzhov (VMware) --- Documentation/libtraceevent-field_print.txt | 11 ++++++++++- Documentation/libtraceevent.txt | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/libtraceevent-field_print.txt b/Documentation/libtraceevent-field_print.txt index 2c2cf6c..c201c13 100644 --- a/Documentation/libtraceevent-field_print.txt +++ b/Documentation/libtraceevent-field_print.txt @@ -3,7 +3,7 @@ libtraceevent(3) NAME ---- -tep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field - +tep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field, tep_record_print_fields, tep_record_print_selected_fields - Print the field content. SYNOPSIS @@ -17,6 +17,8 @@ void *tep_print_field*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, struct void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_); int *tep_print_num_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); int *tep_print_func_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); +void *tep_record_print_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_); +void *tep_record_print_selected_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_, int _select_mask_); -- DESCRIPTION @@ -49,6 +51,13 @@ function. The function name (if found) and its address are printed in the _s_, according to the given format string _fmt_. If the argument _err_ is non-zero, and an error occures - it is printed in _s_. +The _tep_record_print_fields()_ prints the field's name followed by its value +for all record's field. + +The _tep_record_print_selected_fields()_ prints the field's name followed by +its value for selected subset of record field. The fields to be printed are +defined by the _select_mask_ bit mask. + RETURN VALUE ------------ The _tep_print_num_field()_ and _tep_print_func_field()_ functions return 1 diff --git a/Documentation/libtraceevent.txt b/Documentation/libtraceevent.txt index d42b5c9..01014b7 100644 --- a/Documentation/libtraceevent.txt +++ b/Documentation/libtraceevent.txt @@ -80,6 +80,8 @@ Event fields printing: void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_); int *tep_print_num_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); int *tep_print_func_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_); + void *tep_record_print_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_); + void *tep_record_print_selected_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_, int _select_mask_); Event fields finding: struct tep_format_field pass:[*]*tep_find_common_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_);