babeltrace2/integer-range-set-const.h \
babeltrace2/integer-range-set.h \
babeltrace2/logging.h \
+ babeltrace2/logging-defs.h \
babeltrace2/property.h \
babeltrace2/types.h \
babeltrace2/util.h \
#undef __BT_IN_BABELTRACE_H
#undef __BT_UPCAST
#undef __BT_UPCAST_CONST
+#undef __BT_LOGGING_LEVEL_TRACE
+#undef __BT_LOGGING_LEVEL_DEBUG
+#undef __BT_LOGGING_LEVEL_INFO
+#undef __BT_LOGGING_LEVEL_WARNING
+#undef __BT_LOGGING_LEVEL_ERROR
+#undef __BT_LOGGING_LEVEL_FATAL
+#undef __BT_LOGGING_LEVEL_NONE
#endif /* BABELTRACE2_BABELTRACE_H */
--- /dev/null
+/*
+ * No include guards here: it is safe to include this file multiple
+ * times.
+ */
+
+/*
+ * Copyright (c) 2019 EfficiOS Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __BT_IN_BABELTRACE_H
+# error "Please include <babeltrace2/babeltrace.h> instead."
+#endif
+
+/*
+ * This is NOT part of the API.
+ *
+ * These macros are used internally in preprocessor conditions to define
+ * logging macros.
+ */
+
+#ifndef __BT_LOGGING_LEVEL_TRACE
+# define __BT_LOGGING_LEVEL_TRACE 1
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_DEBUG
+# define __BT_LOGGING_LEVEL_DEBUG 2
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_INFO
+# define __BT_LOGGING_LEVEL_INFO 3
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_WARNING
+# define __BT_LOGGING_LEVEL_WARNING 4
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_ERROR
+# define __BT_LOGGING_LEVEL_ERROR 5
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_FATAL
+# define __BT_LOGGING_LEVEL_FATAL 6
+#endif
+
+#ifndef __BT_LOGGING_LEVEL_NONE
+# define __BT_LOGGING_LEVEL_NONE 0xff
+#endif
# error "Please include <babeltrace2/babeltrace.h> instead."
#endif
+#include <babeltrace2/logging-defs.h>
+
#ifdef __cplusplus
extern "C" {
#endif
*/
typedef enum bt_logging_level {
/// Additional, low-level debugging context information.
- BT_LOGGING_LEVEL_TRACE = 1,
+ BT_LOGGING_LEVEL_TRACE = __BT_LOGGING_LEVEL_TRACE,
/**
Debugging information, only useful when searching for the
cause of a bug.
*/
- BT_LOGGING_LEVEL_DEBUG = 2,
+ BT_LOGGING_LEVEL_DEBUG = __BT_LOGGING_LEVEL_DEBUG,
/**
Non-debugging information and failure to load optional
subsystems.
*/
- BT_LOGGING_LEVEL_INFO = 3,
+ BT_LOGGING_LEVEL_INFO = __BT_LOGGING_LEVEL_INFO,
/**
Errors caused by a bad usage of the library, that is, a
The library's and object's states remain consistent when a
warning is issued.
*/
- BT_LOGGING_LEVEL_WARNING = 4,
+ BT_LOGGING_LEVEL_WARNING = __BT_LOGGING_LEVEL_WARNING,
/**
An important error from which the library cannot recover, but
the executed stack of functions can still return cleanly.
*/
- BT_LOGGING_LEVEL_ERROR = 5,
+ BT_LOGGING_LEVEL_ERROR = __BT_LOGGING_LEVEL_ERROR,
/**
The library cannot continue to work in this condition: it must
terminate immediately, without even returning to the user's
execution.
*/
- BT_LOGGING_LEVEL_FATAL = 6,
+ BT_LOGGING_LEVEL_FATAL = __BT_LOGGING_LEVEL_FATAL,
/// Logging is disabled.
- BT_LOGGING_LEVEL_NONE = 0xff,
+ BT_LOGGING_LEVEL_NONE = __BT_LOGGING_LEVEL_NONE,
} bt_logging_level;
/**
#include <string.h>
#include <babeltrace2/babeltrace.h>
+/* Access private __BT_LOGGING_LEVEL_* macros. */
+#define __BT_IN_BABELTRACE_H
+#include <babeltrace2/logging-defs.h>
+#undef __BT_IN_BABELTRACE_H
+
#include "common/macros.h"
#include "common/assert.h"
* should be empty or very small. Choosing a right log level is as important as
* providing short and self descriptive log message.
*/
-#define BT_LOG_TRACE BT_LOGGING_LEVEL_TRACE
-#define BT_LOG_DEBUG BT_LOGGING_LEVEL_DEBUG
-#define BT_LOG_INFO BT_LOGGING_LEVEL_INFO
-#define BT_LOG_WARNING BT_LOGGING_LEVEL_WARNING
-#define BT_LOG_ERROR BT_LOGGING_LEVEL_ERROR
-#define BT_LOG_FATAL BT_LOGGING_LEVEL_FATAL
-#define BT_LOG_NONE BT_LOGGING_LEVEL_NONE
+#define BT_LOG_TRACE __BT_LOGGING_LEVEL_TRACE
+#define BT_LOG_DEBUG __BT_LOGGING_LEVEL_DEBUG
+#define BT_LOG_INFO __BT_LOGGING_LEVEL_INFO
+#define BT_LOG_WARNING __BT_LOGGING_LEVEL_WARNING
+#define BT_LOG_ERROR __BT_LOGGING_LEVEL_ERROR
+#define BT_LOG_FATAL __BT_LOGGING_LEVEL_FATAL
+#define BT_LOG_NONE __BT_LOGGING_LEVEL_NONE
/* "Current" log level is a compile time check and has no runtime overhead. Log
* level that is below current log level it said to be "disabled".
ast.h \
objstack.h \
parser.h \
+ parser-wrap.h \
scanner.h \
scanner-symbols.h \
decoder.c \
#define TSDL_MAGIC 0x75d11d57
-extern
-int yydebug;
-
struct ctf_metadata_decoder {
struct ctf_visitor_generate_ir *visitor;
bt_uuid_t uuid;
#include "decoder.h"
#include "scanner.h"
#include "logging.h"
+#include "parser-wrap.h"
#define TSDL_MAGIC 0x75d11d57
-extern
-int yydebug;
-
struct ctf_metadata_decoder {
struct ctf_scanner *scanner;
GString *text;
}
}
+#if YYDEBUG
if (BT_LOG_ON_TRACE) {
yydebug = 1;
}
+#endif
/* Save the file's position: we'll seek back to append the plain text */
BT_ASSERT(fp);
}
end:
+#if YYDEBUG
yydebug = 0;
+#endif
if (fp && close_fp) {
if (fclose(fp)) {
#include <stdio.h>
#include <ctype.h>
#include "scanner.h"
-#include "parser.h"
+#include "parser-wrap.h"
#include "ast.h"
#define YY_FATAL_ERROR(_msg) BT_LOGF_STR(_msg)
--- /dev/null
+#ifndef BABELTRACE_PLUGINS_CTF_COMMON_METADATA_PARSER_WRAP_H
+#define BABELTRACE_PLUGINS_CTF_COMMON_METADATA_PARSER_WRAP_H
+
+/*
+ * Copyright 2019 EfficiOS Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Small wrapper around the bison-generated parser.h to conditionally define
+ * YYDEBUG (and therefore the yydebug declaration).
+ */
+
+#include "logging/log.h"
+
+#if BT_LOG_ENABLED_TRACE
+# define YYDEBUG 1
+# define YYFPRINTF(_stream, _fmt, args...) BT_LOGT(_fmt, ## args)
+#else
+# define YYDEBUG 0
+#endif
+
+#define ALLOW_INCLUDE_PARSER_H
+#include "parser.h"
+#undef ALLOW_INCLUDE_PARSER_H
+
+#endif
#include "common/list.h"
#include "common/assert.h"
#include "scanner.h"
-#include "parser.h"
#include "ast.h"
#include "objstack.h"
-#if BT_LOG_ENABLED_TRACE
-# define YYDEBUG 1
-# define YYFPRINTF(_stream, _fmt, args...) BT_LOGT(_fmt, ## args)
-#else
-# define YYDEBUG 0
-#endif
+#include "parser-wrap.h"
/* Join two lists, put "add" at the end of "head". */
static inline void
%}
+/*
+ * This ends up in parser.h and makes sure those who want to include it pass
+ * through parser-wrap.h.
+ */
+%code requires {
+#ifndef ALLOW_INCLUDE_PARSER_H
+# error "Don't include parser.h directly, include parser-wrap.h instead."
+#endif
+}
+
+
%define api.pure
/* %locations */
%error-verbose
#include "logging.h"
#include "scanner.h"
-#include "parser.h"
#include "ast.h"
#include "decoder.h"
#include "ctf-meta.h"
#include "common/macros.h"
#include "common/list.h"
#include "scanner.h"
-#include "parser.h"
#include "ast.h"
#include "logging.h"
#include <errno.h>
#include "common/list.h"
#include "scanner.h"
-#include "parser.h"
#include "ast.h"
#include "logging.h"