linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Slavomir Kaslev <kaslevs@vmware.com>
Cc: linux-trace-devel@vger.kernel.org, ykaradzhov@vmware.com,
	tstoyanov@vmware.com, slavomir.kaslev@gmail.com
Subject: Re: [PATCH] trace-cmd: Append metadata about trace-cmd's version when recording
Date: Tue, 4 Jun 2019 08:24:40 -0400	[thread overview]
Message-ID: <20190604082440.724d7d95@oasis.local.home> (raw)
In-Reply-To: <20190604121441.19305-1-kaslevs@vmware.com>

On Tue,  4 Jun 2019 15:14:41 +0300
Slavomir Kaslev <kaslevs@vmware.com> wrote:

> Add metadata when recording to the output trace about trace-cmd's version and
> git commit. When debugging this can be useful to know which version of trace-cmd
> recorded this trace.dat file.

Awesome! Some nits below...

> 
> Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=203547
> Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
> ---
>  Makefile                      |  3 +++
>  include/trace-cmd/trace-cmd.h |  1 +
>  tracecmd/trace-record.c       | 17 ++++++++++++++++-
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index cde45f8..2062d97 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -238,6 +238,9 @@ endif
>  override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR)
>  override CFLAGS += $(udis86-flags) $(blk-flags)
>  
> +# Append version define
> +override CFLAGS += -DTRACECMD_VERSION=\"$(TRACECMD_VERSION)\"
> +override CFLAGS += -DTRACECMD_VERSION_GIT=\"$(shell git log -1 --pretty=format:"%H")\"
>  
>  CMD_TARGETS = trace-cmd $(BUILD_PYTHON)
>  
> diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
> index ceb03f4..ca9fc44 100644
> --- a/include/trace-cmd/trace-cmd.h
> +++ b/include/trace-cmd/trace-cmd.h
> @@ -81,6 +81,7 @@ enum {
>  	TRACECMD_OPTION_HOOK,
>  	TRACECMD_OPTION_OFFSET,
>  	TRACECMD_OPTION_CPUCOUNT,
> +	TRACECMD_OPTION_VERSION,
>  };
>  
>  enum {
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 4523128..4c4840b 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -3145,6 +3145,21 @@ static void add_uname(struct tracecmd_output *handle)
>  	free(str);
>  }
>  
> +static void add_version(struct tracecmd_output *handle)
> +{
> +	char *str;
> +	int len;
> +
> +	len = strlen(TRACECMD_VERSION) + strlen(TRACECMD_VERSION_GIT) + 2;
> +	str = malloc(len);
> +	if (!str)
> +		return;
> +
> +	sprintf(str, "%s %s", TRACECMD_VERSION, TRACECMD_VERSION_GIT);

The above should use asprintf():

	ret = asprintf(&str, "%s %s", TRACECMD_VERSION, TRACE_cMD_VERSION_GIT);
	if (ret < 0)
		return;

But other than that, looks good!

-- Steve

> +	tracecmd_add_option(handle, TRACECMD_OPTION_VERSION, len, str);
> +	free(str);
> +}
> +
>  static void print_stat(struct buffer_instance *instance)
>  {
>  	int cpu;
> @@ -3182,7 +3197,7 @@ static void add_options(struct tracecmd_output *handle, struct common_record_con
>  	tracecmd_add_option(handle, TRACECMD_OPTION_TRACECLOCK, 0, NULL);
>  	add_option_hooks(handle);
>  	add_uname(handle);
> -
> +	add_version(handle);
>  }
>  
>  static void record_data(struct common_record_context *ctx)


  reply	other threads:[~2019-06-04 12:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 12:14 [PATCH] trace-cmd: Append metadata about trace-cmd's version when recording Slavomir Kaslev
2019-06-04 12:24 ` Steven Rostedt [this message]
2019-06-04 12:48   ` Slavomir Kaslev
2019-06-11  1:27     ` [PATCH] trace-cmd: Add trace-cmd report --version to extract version info Steven Rostedt
2019-06-11 12:40       ` Slavomir Kaslev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190604082440.724d7d95@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=kaslevs@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=slavomir.kaslev@gmail.com \
    --cc=tstoyanov@vmware.com \
    --cc=ykaradzhov@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).