From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 04/10] trace-cmd library: New API for setting a custom kallsyms to an output handler
Date: Fri, 8 Oct 2021 07:13:15 +0300 [thread overview]
Message-ID: <20211008041321.973755-5-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211008041321.973755-1-tz.stoyanov@gmail.com>
The new API associates an output file handler with a custom kernel symbols
file. It is used when creating the trace file instead of the system default
kernel symbols file.
tracecmd_output_set_kallsyms()
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
.../include/private/trace-cmd-private.h | 1 +
lib/trace-cmd/trace-output.c | 32 +++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index ad9d5265..8ef448eb 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -273,6 +273,7 @@ struct tracecmd_output *tracecmd_output_allocate(int fd);
int tracecmd_output_set_msg(struct tracecmd_output *handler,
struct tracecmd_msg_handle *msg_handle);
int tracecmd_output_set_trace_dir(struct tracecmd_output *handler, const char *tracing_dir);
+int tracecmd_output_set_kallsyms(struct tracecmd_output *handler, const char *kallsyms);
struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus);
struct tracecmd_output *
tracecmd_create_init_file_glob(const char *output_file,
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index a5d7ed5f..c654561a 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -54,6 +54,7 @@ struct tracecmd_output {
int cpus;
struct tep_handle *pevent;
char *tracing_dir;
+ char *kallsyms;
int nr_options;
bool quiet;
unsigned long file_state;
@@ -767,8 +768,8 @@ static int read_proc_kallsyms(struct tracecmd_output *handle,
return -1;
}
- if (kallsyms)
- path = kallsyms;
+ if (handle->kallsyms)
+ path = handle->kallsyms;
ret = stat(path, &st);
if (ret < 0) {
@@ -968,6 +969,33 @@ int tracecmd_output_set_trace_dir(struct tracecmd_output *handler, const char *t
return 0;
}
+/**
+ * tracecmd_output_set_kallsyms - Set a custom kernel symbols file, instead of system default
+ * @handle: output handler to a trace file.
+ * @tracing_dir: full path to a file with kernel symbols
+ *
+ * This API associates an output file handler with a custom kernel symbols file, to be used when
+ * creating the trace file instead of the system default kernel symbols file.
+ * This API must be called before tracecmd_output_write_init().
+ *
+ * Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state.
+ */
+int tracecmd_output_set_kallsyms(struct tracecmd_output *handler, const char *kallsyms)
+{
+ if (!handler || handler->file_state != TRACECMD_FILE_ALLOCATED)
+ return -1;
+
+ free(handler->kallsyms);
+ if (kallsyms) {
+ handler->kallsyms = strdup(kallsyms);
+ if (!handler->kallsyms)
+ return -1;
+ } else
+ handler->kallsyms = NULL;
+
+ return 0;
+}
+
static int select_file_version(struct tracecmd_output *handle,
struct tracecmd_input *ihandle)
{
--
2.31.1
next prev parent reply other threads:[~2021-10-08 4:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-08 4:13 [PATCH 00/10] Refactor APIs for creating output handler Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 01/10] trace-cmd library: New API for allocating an " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 02/10] trace-cmd library: New API for setting a message context to " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 03/10] trace-cmd library: New API for setting a custom trace directory " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` Tzvetomir Stoyanov (VMware) [this message]
2021-10-08 4:13 ` [PATCH 05/10] trace-cmd library: New API to inherit parameters from an existing trace file Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 06/10] trace-cmd library: New API tracecmd_output_write_init Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 07/10] trace-cmd library: New API to write headers of a trace file Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 08/10] trace-cmd library: Use the new flow when creating output handler Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 09/10] trace-cmd: " Tzvetomir Stoyanov (VMware)
2021-10-08 4:13 ` [PATCH 10/10] trace-cmd library: Remove deprecated APIs for creating an " Tzvetomir Stoyanov (VMware)
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=20211008041321.973755-5-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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).