barectf_platform_linux_fs_init(): accept DS file path, not trace dir.
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 24 Sep 2020 02:45:24 +0000 (22:45 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 24 Sep 2020 02:45:24 +0000 (22:45 -0400)
This patch changes the Linux FS platform's
barectf_platform_linux_fs_init() function so that it accepts the data
stream file path instead of its trace directory.

This makes it possible to initialize many Linux FS platform contexts for
the same trace, each one targeting a distinct data stream file.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
examples/barectf-tracepoint/barectf-tracepoint-linux-fs.h
examples/linux-fs-simple/linux-fs-simple.c
platforms/linux-fs/README.adoc
platforms/linux-fs/barectf-platform-linux-fs.c
platforms/linux-fs/barectf-platform-linux-fs.h

index f68231bdc491198539b1b3aa1249371f2f1cb0a3..270e3fc5b0b7ee13e53c720200992dac232d90dd 100644 (file)
@@ -50,7 +50,8 @@ static void init_tracing(void)
 {
        /* initialize platform */
        global_barectf_platform_ctx =
-               barectf_platform_linux_fs_init(512, "ctf-linux-fs", 1, 2, 7);
+               barectf_platform_linux_fs_init(512, "ctf-linux-fs/stream",
+                       1, 2, 7);
 
        if (!global_barectf_platform_ctx) {
                fprintf(stderr, "Error: could not initialize platform\n");
index e19d305d2741edd12d5ce7c747842f145b28208d..d50ce34eb87776ea23046f8862235f2c5e8da823 100644 (file)
@@ -73,7 +73,8 @@ int main(const int argc, const char * const argv[])
        int exit_status = 0;
 
        /* Initialize platform */
-       platform_ctx = barectf_platform_linux_fs_init(512, "trace", 1, 2, 7);
+       platform_ctx = barectf_platform_linux_fs_init(512, "trace/stream",
+               1, 2, 7);
 
        if (!platform_ctx) {
                fprintf(stderr,
index 486cb11aa4f5655a5548c0fd30904e44ea246146..919e01de732bbf44d2c535257c7cf3ee27923d0a 100644 (file)
@@ -2,7 +2,7 @@
 
 = barectf Linux FS platform
 Philippe Proulx
-16 September 2020
+23 September 2020
 :toc: left
 
 The barectf Linux FS platform is a very simple platform used to
@@ -64,8 +64,9 @@ trace:
 [source,c]
 ----
 struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
-    unsigned int buf_size, const char *trace_dir, int simulate_full_backend,
-    unsigned int full_backend_rand_max, unsigned int full_backend_rand_lt);
+    unsigned int buf_size, const char *data_stream_file_path,
+    int simulate_full_backend, unsigned int full_backend_rand_max,
+    unsigned int full_backend_rand_lt);
 ----
 
 ==== Parameters
@@ -77,9 +78,8 @@ struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
 |`buf_size`
 |Size of the packet buffer to allocate (bytes).
 
-|`trace_dir`
-|Path of the directory to which to write the single data stream file
- named `stream`.
+|`data_stream_file_path`
+|Path of the data stream file to which to append packets.
 
 |`simulate_full_backend`
 |
@@ -196,7 +196,8 @@ int main(void)
     struct barectf_default_ctx *barectf_ctx;
     unsigned int i;
 
-    platform_ctx = barectf_platform_linux_fs_init(256, "trace", 0, 0, 0);
+    platform_ctx = barectf_platform_linux_fs_init(256, "trace/stream",
+                                                  0, 0, 0);
     assert(platform_ctx);
     barectf_ctx = barectf_platform_linux_fs_get_barectf_ctx(platform_ctx);
 
index 3418a16b176bcf6e8d4f3ddb4ee7b8d97cafc2c4..29123b34811c42b022223e7d6a22f20a321b68a2 100644 (file)
@@ -101,12 +101,11 @@ static void close_packet(void * const data)
 }
 
 struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
-       const unsigned int buf_size, const char * const trace_dir,
+       const unsigned int buf_size, const char * const data_stream_file_path,
        const int simulate_full_backend,
        const unsigned int full_backend_rand_lt,
        const unsigned int full_backend_rand_max)
 {
-       char stream_path[256];
        uint8_t *buf = NULL;
        struct barectf_platform_linux_fs_ctx *platform_ctx;
        struct barectf_platform_callbacks cbs;
@@ -128,8 +127,7 @@ struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
                goto error;
        }
 
-       sprintf(stream_path, "%s/stream", trace_dir);
-       platform_ctx->fh = fopen(stream_path, "wb");
+       platform_ctx->fh = fopen(data_stream_file_path, "wb");
 
        if (!platform_ctx->fh) {
                goto error;
index b216a634b0bb0e56f7d6e1cc6c219080b704aa21..6380393481c8dbff3d445277cabdafdc561dbc1e 100644 (file)
@@ -36,8 +36,9 @@ struct barectf_default_ctx;
 struct barectf_platform_linux_fs_ctx;
 
 struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init(
-       unsigned int buf_size, const char *trace_dir, int simulate_full_backend,
-       unsigned int full_backend_rand_max, unsigned int full_backend_rand_lt);
+       unsigned int buf_size, const char *data_stream_file_path,
+       int simulate_full_backend, unsigned int full_backend_rand_max,
+       unsigned int full_backend_rand_lt);
 
 void barectf_platform_linux_fs_fini(struct barectf_platform_linux_fs_ctx *ctx);
 
This page took 0.027537 seconds and 4 git commands to generate.