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

Update trace-plugin API #428

Merged
merged 1 commit into from
May 15, 2024
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
20 changes: 10 additions & 10 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,26 +1038,26 @@ int process_args(int argc, const char* argv[]) {
* core runtime.
*/
#ifdef LF_TRACE
static void check_version(version_t version) {
static void check_version(const version_t* version) {
#ifdef LF_SINGLE_THREADED
LF_ASSERT(version.build_config.single_threaded == TRIBOOL_TRUE ||
version.build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.single_threaded == TRIBOOL_TRUE ||
version->build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
"expected single-threaded version");
#else
LF_ASSERT(version.build_config.single_threaded == TRIBOOL_FALSE ||
version.build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.single_threaded == TRIBOOL_FALSE ||
version->build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
"expected multi-threaded version");
#endif
#ifdef NDEBUG
LF_ASSERT(version.build_config.build_type_is_debug == TRIBOOL_FALSE ||
version.build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.build_type_is_debug == TRIBOOL_FALSE ||
version->build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
"expected release version");
#else
LF_ASSERT(version.build_config.build_type_is_debug == TRIBOOL_TRUE ||
version.build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.build_type_is_debug == TRIBOOL_TRUE ||
version->build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
"expected debug version");
#endif
LF_ASSERT(version.build_config.log_level == LOG_LEVEL || version.build_config.log_level == INT_MAX,
LF_ASSERT(version->build_config.log_level == LOG_LEVEL || version->build_config.log_level == INT_MAX,
"expected log level %d", LOG_LEVEL);
// assert(!version.core_version_name || strcmp(version.core_version_name, CORE_SHA) == 0); // TODO: provide CORE_SHA
}
Expand Down
10 changes: 9 additions & 1 deletion trace/api/trace.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef TRACE_H
#define TRACE_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>

Expand All @@ -10,7 +14,7 @@
* @brief Return a description of the compile-time properties of the current
* plugin.
*/
version_t lf_version_tracing();
const version_t* lf_version_tracing();

/**
* Identifier for what is in the object table.
Expand Down Expand Up @@ -82,4 +86,8 @@ void lf_tracing_tracepoint(int worker, trace_record_nodeps_t* tr);
*/
void lf_tracing_global_shutdown();

#ifdef __cplusplus
}
#endif

#endif // TRACE_H
27 changes: 12 additions & 15 deletions trace/impl/src/trace_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ static lf_platform_mutex_ptr_t trace_mutex;
static trace_t trace;
static int process_id;
static int64_t start_time;
static version_t version = {.build_config =
{
.single_threaded = TRIBOOL_DOES_NOT_MATTER,
#ifdef NDEBUG
.build_type_is_debug = TRIBOOL_FALSE,
#else
.build_type_is_debug = TRIBOOL_TRUE,
#endif
.log_level = LOG_LEVEL,
},
.core_version_name = NULL};

// PRIVATE HELPERS ***********************************************************

Expand Down Expand Up @@ -192,21 +203,7 @@ static void stop_trace(trace_t* trace) {

// IMPLEMENTATION OF VERSION API *********************************************

version_t lf_version_tracing() {
return (version_t){
.build_config =
(build_config_t){
.single_threaded = TRIBOOL_DOES_NOT_MATTER,
#ifdef NDEBUG
.build_type_is_debug = TRIBOOL_FALSE,
#else
.build_type_is_debug = TRIBOOL_TRUE,
#endif
.log_level = LOG_LEVEL,
},
.core_version_name = NULL,
};
}
const version_t* lf_version_tracing() { return &version; }

// IMPLEMENTATION OF TRACE API ***********************************************

Expand Down
Loading