diff options
author | David Goulet <dgoulet@torproject.org> | 2020-01-09 11:41:23 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-08 09:10:08 -0400 |
commit | 70f031528d033562ae93cb97677cab060948fd8e (patch) | |
tree | 6f3ccbcebeb4266fdbb45184b32ab7376176328b | |
parent | 6fc6cbd9b347ee1f82a024a04c0276bbc6e82c99 (diff) | |
download | tor-70f031528d033562ae93cb97677cab060948fd8e.tar.gz tor-70f031528d033562ae93cb97677cab060948fd8e.zip |
trace: Hook lib/trace as a subsystem
Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r-- | src/app/main/subsystem_list.c | 3 | ||||
-rw-r--r-- | src/lib/trace/.may_include | 1 | ||||
-rw-r--r-- | src/lib/trace/include.am | 6 | ||||
-rw-r--r-- | src/lib/trace/trace.c | 8 | ||||
-rw-r--r-- | src/lib/trace/trace.h | 9 | ||||
-rw-r--r-- | src/lib/trace/trace_sys.c | 33 | ||||
-rw-r--r-- | src/lib/trace/trace_sys.h | 14 |
7 files changed, 67 insertions, 7 deletions
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c index e32083537f..c6da6f4893 100644 --- a/src/app/main/subsystem_list.c +++ b/src/app/main/subsystem_list.c @@ -26,6 +26,7 @@ #include "lib/thread/thread_sys.h" #include "lib/time/time_sys.h" #include "lib/tls/tortls_sys.h" +#include "lib/trace/trace_sys.h" #include "lib/wallclock/wallclock_sys.h" #include "lib/evloop/evloop_sys.h" @@ -47,6 +48,8 @@ const subsys_fns_t *tor_subsystems[] = { &sys_logging, &sys_threads, + &sys_tracing, + &sys_time, &sys_crypto, diff --git a/src/lib/trace/.may_include b/src/lib/trace/.may_include index 45cd13676b..1ed533cc7a 100644 --- a/src/lib/trace/.may_include +++ b/src/lib/trace/.may_include @@ -1,3 +1,4 @@ orconfig.h lib/log/*.h lib/trace/*.h +lib/subsys/*.h diff --git a/src/lib/trace/include.am b/src/lib/trace/include.am index 1669943dc5..312fd4e87d 100644 --- a/src/lib/trace/include.am +++ b/src/lib/trace/include.am @@ -4,11 +4,13 @@ noinst_LIBRARIES += \ # ADD_C_FILE: INSERT SOURCES HERE. LIBTOR_TRACE_A_SOURCES = \ - src/lib/trace/trace.c + src/lib/trace/trace.c \ + src/lib/trace/trace_sys.c # ADD_C_FILE: INSERT HEADERS HERE. TRACEHEADERS = \ - src/lib/trace/trace.h \ + src/lib/trace/trace.h \ + src/lib/trace/trace_sys.h \ src/lib/trace/events.h if USE_TRACING_INSTRUMENTATION_LOG_DEBUG diff --git a/src/lib/trace/trace.c b/src/lib/trace/trace.c index 4e5c66b4c6..10d11c17c5 100644 --- a/src/lib/trace/trace.c +++ b/src/lib/trace/trace.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2020, The Tor Project, Inc. */ +/* Copyright (c) 2020, The Tor Project, Inc. */ /* See LICENSE for licensing information */ /** @@ -15,3 +15,9 @@ void tor_trace_init(void) { } + +/** Free all the tracing library. */ +void +tor_trace_free_all(void) +{ +} diff --git a/src/lib/trace/trace.h b/src/lib/trace/trace.h index 5e24678c3c..94cbbc1e48 100644 --- a/src/lib/trace/trace.h +++ b/src/lib/trace/trace.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2020, The Tor Project, Inc. */ +/* Copyright (c) 2020, The Tor Project, Inc. */ /* See LICENSE for licensing information */ /** @@ -6,9 +6,10 @@ * \brief Header for trace.c **/ -#ifndef TOR_TRACE_TRACE_H -#define TOR_TRACE_TRACE_H +#ifndef TOR_LIB_TRACE_TRACE_H +#define TOR_LIB_TRACE_TRACE_H void tor_trace_init(void); +void tor_trace_free_all(void); -#endif /* !defined(TOR_TRACE_TRACE_H) */ +#endif /* !defined(TOR_LIB_TRACE_TRACE_H) */ diff --git a/src/lib/trace/trace_sys.c b/src/lib/trace/trace_sys.c new file mode 100644 index 0000000000..d6e59f4c3d --- /dev/null +++ b/src/lib/trace/trace_sys.c @@ -0,0 +1,33 @@ +/* Copyright (c) 2018-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file log_sys.c + * \brief Setup and tear down the tracing module. + **/ + +#include "lib/subsys/subsys.h" + +#include "lib/trace/trace.h" +#include "lib/trace/trace_sys.h" + +static int +subsys_tracing_initialize(void) +{ + tor_trace_init(); + return 0; +} + +static void +subsys_tracing_shutdown(void) +{ + tor_trace_free_all(); +} + +const subsys_fns_t sys_tracing = { + .name = "tracing", + .supported = true, + .level = -85, + .initialize = subsys_tracing_initialize, + .shutdown = subsys_tracing_shutdown, +}; diff --git a/src/lib/trace/trace_sys.h b/src/lib/trace/trace_sys.h new file mode 100644 index 0000000000..e9c97c08fb --- /dev/null +++ b/src/lib/trace/trace_sys.h @@ -0,0 +1,14 @@ +/* Copyright (c) 2018-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file log_sys.h + * \brief Declare subsystem object for the logging module. + **/ + +#ifndef TOR_TRACE_SYS_H +#define TOR_TRACE_SYS_H + +extern const struct subsys_fns_t sys_tracing; + +#endif /* !defined(TOR_TRACE_SYS_H) */ |