X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmetadata%2Fparser.y;h=71f2d5fefc62eb453fa5d655ce7cb1424b096baa;hb=f82819ab5928febed746913168ac5d95909007d1;hp=3f993cefd333f9d35d9ad4a5e36e9e1c501decb5;hpb=350ad6c1c5f45a4e90c33e3c1354125c209bbf02;p=babeltrace.git diff --git a/src/plugins/ctf/common/metadata/parser.y b/src/plugins/ctf/common/metadata/parser.y index 3f993cef..71f2d5fe 100644 --- a/src/plugins/ctf/common/metadata/parser.y +++ b/src/plugins/ctf/common/metadata/parser.y @@ -25,6 +25,7 @@ * SOFTWARE. */ +#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level #define BT_LOG_TAG "PLUGIN/CTF/META/PARSER" #include "logging.h" @@ -40,16 +41,10 @@ #include "common/list.h" #include "common/assert.h" #include "scanner.h" -#include "parser.h" #include "ast.h" #include "objstack.h" -#if BT_LOG_ENABLED_VERBOSE -# define YYDEBUG 1 -# define YYFPRINTF(_stream, _fmt, args...) BT_LOGV(_fmt, ## args) -#else -# define YYDEBUG 0 -#endif +#include "parser-wrap.h" /* Join two lists, put "add" at the end of "head". */ static inline void @@ -164,7 +159,7 @@ int parse_base_sequence(const char *src, size_t len, size_t pos, return -1; } } - BT_ASSERT(nr_char > 0); + BT_ASSERT_DBG(nr_char > 0); buffer[nr_char] = '\0'; *buf_len = nr_char; return 0; @@ -317,7 +312,7 @@ static void push_scope(struct ctf_scanner *scanner) { struct ctf_scanner_scope *ns; - BT_LOGV("Pushing scope: scanner-addr=%p", scanner); + BT_LOGT("Pushing scope: scanner-addr=%p", scanner); ns = malloc(sizeof(struct ctf_scanner_scope)); init_scope(ns, scanner->cs); scanner->cs = ns; @@ -327,7 +322,7 @@ static void pop_scope(struct ctf_scanner *scanner) { struct ctf_scanner_scope *os; - BT_LOGV("Popping scope: scanner-addr=%p", scanner); + BT_LOGT("Popping scope: scanner-addr=%p", scanner); os = scanner->cs; scanner->cs = os->parent; finalize_scope(os); @@ -339,7 +334,7 @@ static int lookup_type(struct ctf_scanner_scope *s, const char *id) int ret; ret = GPOINTER_TO_INT(g_hash_table_lookup(s->classes, id)); - BT_LOGV("Looked up type: scanner-addr=%p, id=\"%s\", ret=%d", + BT_LOGT("Looked up type: scanner-addr=%p, id=\"%s\", ret=%d", s, id, ret); return ret; } @@ -350,20 +345,20 @@ int is_type(struct ctf_scanner *scanner, const char *id) struct ctf_scanner_scope *it; int ret = 0; - for (it = scanner->cs; it != NULL; it = it->parent) { + for (it = scanner->cs; it; it = it->parent) { if (lookup_type(it, id)) { ret = 1; break; } } - BT_LOGV("Found if ID is type: scanner-addr=%p, id=\"%s\", ret=%d", + BT_LOGT("Found if ID is type: scanner-addr=%p, id=\"%s\", ret=%d", scanner, id, ret); return ret; } static void add_type(struct ctf_scanner *scanner, char *id) { - BT_LOGV("Adding type: scanner-addr=%p, id=\"%s\"", + BT_LOGT("Adding type: scanner-addr=%p, id=\"%s\"", scanner, id); if (lookup_type(scanner->cs, id)) return; @@ -1041,8 +1036,30 @@ void ctf_scanner_free(struct ctf_scanner *scanner) free(scanner); } +/* + * The bison-provided version of strlen (yystrlen) generates a benign + * -Wnull-dereference warning. That version is used when building on cygwin, + * for example, but you can also enable it by hand (to test) by removing the + * preprocessor conditional around it. + * + * Define yystrlen such that it will always use strlen. As far as we know, + * strlen provided by all the platforms we use is reliable. + */ +#define yystrlen strlen + %} +/* + * 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 @@ -1304,7 +1321,7 @@ unary_expression: $$->u.unary_expression.type = UNARY_SIGNED_CONSTANT; $$->u.unary_expression.u.signed_constant = -($$->u.unary_expression.u.unsigned_constant); - } else if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) { + } else if ($$->u.unary_expression.type == UNARY_SIGNED_CONSTANT) { $$->u.unary_expression.u.signed_constant = -($$->u.unary_expression.u.signed_constant); } else {