Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace: use global trace log #965

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ libre.*dylib
libre.pc
libre.so*
*.gcov
re_trace.json

# Windows build folder
Win32/*
Expand Down
6 changes: 0 additions & 6 deletions rem/aubuf/ajb.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ static void destructor(void *arg)
struct ajb *ajb = arg;

mem_deref(ajb->lock);
#if DEBUG_LEVEL >= 6
(void)re_trace_close();
#endif
}


Expand Down Expand Up @@ -274,9 +271,6 @@ struct ajb *ajb_alloc(double silence, size_t wish_sz)
ajb->as = AJB_GOOD;
ajb->silence = silence;
ajb->wish_sz = wish_sz;
#if DEBUG_LEVEL >= 6
(void)re_trace_init("ajb.json");
#endif

out:
if (err)
Expand Down
7 changes: 0 additions & 7 deletions src/jbuf/jbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ static void jbuf_destructor(void *data)
/* Free all packets in the pool list */
list_flush(&jb->pooll);
mem_deref(jb->lock);
#ifdef RE_JBUF_TRACE
(void)re_trace_close();
#endif
}


Expand Down Expand Up @@ -269,10 +266,6 @@ int jbuf_alloc(struct jbuf **jbp, uint32_t min, uint32_t max)
DEBUG_INFO("alloc: adding to pool list %u\n", i);
}

#ifdef RE_JBUF_TRACE
(void)re_trace_init("jbuf.json");
#endif

out:
if (err)
mem_deref(jb);
Expand Down
9 changes: 9 additions & 0 deletions src/main/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <re_net.h>
#include <re_sys.h>
#include <re_main.h>
#include <re_trace.h>
#include <re_btrace.h>
#include "main.h"

Expand Down Expand Up @@ -167,6 +168,10 @@ int libre_init(void)
return err;
}

#if RE_TRACE_ENABLED
re_trace_init("re_trace.json");
#endif

err = re_thread_init();

return err;
Expand All @@ -178,6 +183,10 @@ int libre_init(void)
*/
void libre_close(void)
{

#if RE_TRACE_ENABLED
re_trace_close();
#endif
(void)fd_setsize(0);
net_sock_close();
re_thread_close();
Expand Down
3 changes: 3 additions & 0 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ int re_trace_init(const char *json_file)
if (!json_file)
return EINVAL;

if (trace.init)
return EALREADY;

trace.event_buffer = mem_zalloc(
TRACE_BUFFER_SIZE * sizeof(struct trace_event), NULL);
if (!trace.event_buffer)
Expand Down
15 changes: 0 additions & 15 deletions test/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ int test_trace(void)
if (test_mode == TEST_THREAD)
return ESKIPPED;

err = re_trace_init("test_trace.json");
TEST_ERR(err);

RE_TRACE_PROCESS_NAME("retest");
RE_TRACE_THREAD_NAME("test_trace");
RE_TRACE_BEGIN("test", "Test Loop Start");
Expand All @@ -54,18 +51,6 @@ int test_trace(void)

RE_TRACE_END("test", "Test Loop End");

err = re_trace_close();
TEST_ERR(err);

/* Test TRACE after close - should do nothing */
RE_TRACE_BEGIN("test", "test after close");

#ifdef WIN32
(void)_unlink("test_trace.json");
#else
(void)unlink("test_trace.json");
#endif

out:
return err;
}
Loading