commit 70f031528d033562ae93cb97677cab060948fd8e Author: David Goulet dgoulet@torproject.org Date: Thu Jan 9 11:41:23 2020 -0500
trace: Hook lib/trace as a subsystem
Signed-off-by: David Goulet dgoulet@torproject.org --- src/app/main/subsystem_list.c | 3 +++ src/lib/trace/.may_include | 1 + src/lib/trace/include.am | 6 ++++-- src/lib/trace/trace.c | 8 +++++++- src/lib/trace/trace.h | 9 +++++---- src/lib/trace/trace_sys.c | 33 +++++++++++++++++++++++++++++++++ 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 e32083537..c6da6f489 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 45cd13676..1ed533cc7 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 1669943dc..312fd4e87 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 4e5c66b4c..10d11c17c 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 5e24678c3..94cbbc1e4 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 000000000..d6e59f4c3 --- /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 000000000..e9c97c08f --- /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) */
tor-commits@lists.torproject.org