From 4335aa7e4ec5976a0646bbdd2a07de17d65fc88d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Fri, 6 Mar 2020 16:47:26 +0100 Subject: Add a STRING_DEBUG facility... ...to identify string addresses and contents on stderr, which eases memory leak debugging. --- rcfile_l.l | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rcfile_l.l b/rcfile_l.l index a7052df9..d1786881 100644 --- a/rcfile_l.l +++ b/rcfile_l.l @@ -25,6 +25,11 @@ int prc_lineno = 1; #define YY_NO_INPUT +/* #define this to emit STRING pointers and contents to stderr while lexing. + * Useful with ASan/LSan (address/leak sanitizer) and its + * LSAN_OPTIONS=report_objects=1 to identify where the leaked strings go. */ +#undef STRING_DEBUG + #ifdef __cplusplus extern "C" #endif @@ -44,6 +49,9 @@ int yywrap(void) { return 1; } escapes(in, in); yylval.sval = in; SETSTATE(0); +#ifdef STRING_DEBUG + fprintf(stderr, "STRING1: %p %s\n", in, in); +#endif return STRING; } @@ -52,6 +60,9 @@ int yywrap(void) { return 1; } escapes(in, in); yylval.sval = in; SETSTATE(0); +#ifdef STRING_DEBUG + fprintf(stderr, "STRING2: %p %s\n", in, in); +#endif return STRING; } @@ -212,6 +223,9 @@ options {/* EMPTY */} char *in = xstrdup(yytext); escapes(in, in); yylval.sval = in; +#ifdef STRING_DEBUG + fprintf(stderr, "STRING3: %p %s\n", in, in); +#endif return STRING; } -- cgit v1.2.3