Skip to content

Commit 0f4afb9

Browse files
committed
filterx/filterx-expr: add expr level detail to perf stacktraces
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
1 parent 8f2726c commit 0f4afb9

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/filterx/filterx-expr.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
#include "mainloop.h"
2929
#include "stats/stats-registry.h"
3030
#include "stats/stats-cluster-single.h"
31+
#include "perf/perf.h"
32+
33+
static inline gboolean
34+
_extract_source_text(void)
35+
{
36+
return debug_flag || perf_is_enabled();
37+
}
3138

3239
void
3340
filterx_expr_set_location_with_text(FilterXExpr *self, CFG_LTYPE *lloc, const gchar *text)
@@ -36,7 +43,7 @@ filterx_expr_set_location_with_text(FilterXExpr *self, CFG_LTYPE *lloc, const gc
3643
self->lloc = g_new0(CFG_LTYPE, 1);
3744
*self->lloc = *lloc;
3845

39-
if (debug_flag && text && text != self->expr_text)
46+
if (_extract_source_text() && text && text != self->expr_text)
4047
{
4148
g_free(self->expr_text);
4249
self->expr_text = g_strdup(text);
@@ -49,7 +56,7 @@ filterx_expr_set_location(FilterXExpr *self, CfgLexer *lexer, CFG_LTYPE *lloc)
4956
if (!self->lloc)
5057
self->lloc = g_new0(CFG_LTYPE, 1);
5158
*self->lloc = *lloc;
52-
if (debug_flag)
59+
if (_extract_source_text())
5360
{
5461
g_free(self->expr_text);
5562
GString *res = g_string_sized_new(0);
@@ -106,6 +113,17 @@ filterx_expr_optimize(FilterXExpr *self)
106113
gboolean
107114
filterx_expr_init_method(FilterXExpr *self, GlobalConfig *cfg)
108115
{
116+
if (perf_is_enabled())
117+
{
118+
gchar buf[256];
119+
120+
if (self->expr_text)
121+
g_snprintf(buf, sizeof(buf), "filterx::%s", self->expr_text);
122+
else
123+
g_snprintf(buf, sizeof(buf), "filterx::@%s", self->type);
124+
self->eval = perf_generate_trampoline(self->eval, buf);
125+
}
126+
109127
return TRUE;
110128
}
111129

0 commit comments

Comments
 (0)