From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/5] trace-cmd: Make read_file_string() non static
Date: Thu, 3 Dec 2020 08:02:23 +0200 [thread overview]
Message-ID: <20201203060226.476475-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20201203060226.476475-1-tz.stoyanov@gmail.com>
This helper function is used to read strings from a binary file locally
in trace-dump.c context. The same functionality could be useful for
other trace-cmd logics. Made the function non static and prefix it with
"trace_", so it could be used in trace-cmd application context.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
tracecmd/include/trace-local.h | 1 +
tracecmd/trace-dump.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index 8b2d4c21..109c3328 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -318,4 +318,5 @@ struct pid_addr_maps {
int trace_debug_get_filemap(struct pid_addr_maps **file_maps, int pid);
void trace_debug_free_filemap(struct pid_addr_maps *maps);
+int trace_read_file_string(int fd, char *dst, int len);
#endif /* __TRACE_LOCAL_H */
diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c
index 5642f12a..c55e2389 100644
--- a/tracecmd/trace-dump.c
+++ b/tracecmd/trace-dump.c
@@ -49,7 +49,7 @@ enum dump_items verbosity;
tracecmd_plog(fmt, ##__VA_ARGS__); \
} while (0)
-static int read_file_string(int fd, char *dst, int len)
+int trace_read_file_string(int fd, char *dst, int len)
{
size_t size = 0;
int r;
@@ -160,7 +160,7 @@ static void dump_initial_format(int fd)
die("wrong tracing string: %s", buf);
/* get file version */
- if (read_file_string(fd, buf, DUMP_SIZE))
+ if (trace_read_file_string(fd, buf, DUMP_SIZE))
die("no version string");
do_print(SUMMARY, "\t\t%s\t[Version]\n", buf);
@@ -260,7 +260,7 @@ static void dump_events_format(int fd)
while (systems) {
- if (read_file_string(fd, buf, DUMP_SIZE))
+ if (trace_read_file_string(fd, buf, DUMP_SIZE))
die("cannot read the name of the $dth system", systems);
if (read_file_number(fd, &events, 4))
die("cannot read the count of the events in system %s",
--
2.28.0
next prev parent reply other threads:[~2020-12-03 6:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 6:02 [PATCH 0/5] Initial trace-cmd perf support Tzvetomir Stoyanov (VMware)
2020-12-03 6:02 ` [PATCH 1/5] trace-cmd: Internal refactoring of pid address map logic Tzvetomir Stoyanov (VMware)
2020-12-03 6:02 ` Tzvetomir Stoyanov (VMware) [this message]
2020-12-03 6:02 ` [PATCH 3/5] trace-cmd: New internal APIs for reading ELF header Tzvetomir Stoyanov (VMware)
2020-12-03 6:02 ` [PATCH 4/5] trace-cmd: Add a new option in trace.dat file for the address to function name mapping Tzvetomir Stoyanov (VMware)
2020-12-03 6:02 ` [PATCH 5/5] [WIP] trace-cmd: Add new subcomand "trace-cmd perf" Tzvetomir Stoyanov (VMware)
2021-02-19 2:03 ` Steven Rostedt
2021-02-19 3:53 ` Steven Rostedt
2021-02-19 17:51 ` Dario Faggioli
2021-02-19 7:16 ` Tzvetomir Stoyanov
2021-02-19 14:36 ` Steven Rostedt
2021-02-19 17:56 ` Tzvetomir Stoyanov
2021-02-19 19:11 ` Steven Rostedt
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=20201203060226.476475-3-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).