31RCSID(
"$Id: 0b3059a7b886fb58ea5c574d46c689652874faf5 $")
33#include <freeradius-devel/server/base.h>
34#include <freeradius-devel/unlang/xlat_priv.h>
37#ifdef HAVE_VALGRIND_CALLGRIND_H
38# include <valgrind/callgrind.h>
47static bool callgrind_attached(
request_t *request)
51 RERROR(
"Refusing callgrind request, the server is not running under valgrind");
80 CALLGRIND_START_INSTRUMENTATION;
112 CALLGRIND_STOP_INSTRUMENTATION;
154 CALLGRIND_DUMP_STATS_AT(label->vb_strvalue);
156 CALLGRIND_DUMP_STATS;
189 CALLGRIND_ZERO_STATS;
199#ifdef HAVE_GPERFTOOLS_PROFILER_H
200# include <gperftools/profiler.h>
226 struct ProfilerState state;
233 ProfilerGetCurrentState(&state);
235 RERROR(
"Profiler already running, writing to %s", state.profile_name);
239 if (ProfilerStart(vb->vb_strvalue) == 0) {
240 RERROR(
"Failed starting profiler with output file %s", vb->vb_strvalue);
253static bool gperftools_running(
request_t *request)
255 struct ProfilerState state;
257 ProfilerGetCurrentState(&state);
258 if (state.enabled)
return true;
260 RERROR(
"Profiler not running");
333#if defined(HAVE_VALGRIND_CALLGRIND_H) || defined(HAVE_GPERFTOOLS_PROFILER_H)
336#define XLAT_REGISTER_PROFILING(_xlat, _func, _args) \
338 if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_BOOL)) == NULL)) return -1; \
339 xlat_func_args_set(xlat, _args); \
340 xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL); \
343#define XLAT_REGISTER_PROFILING_VOID(_xlat, _func) \
345 if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_BOOL)) == NULL)) return -1; \
346 xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL); \
349# ifdef HAVE_VALGRIND_CALLGRIND_H
350 XLAT_REGISTER_PROFILING_VOID(
"callgrind.start", xlat_func_callgrind_start);
351 XLAT_REGISTER_PROFILING_VOID(
"callgrind.stop", xlat_func_callgrind_stop);
352 XLAT_REGISTER_PROFILING(
"callgrind.dump", xlat_func_callgrind_dump, xlat_func_callgrind_dump_args);
353 XLAT_REGISTER_PROFILING_VOID(
"callgrind.zero", xlat_func_callgrind_zero);
356# ifdef HAVE_GPERFTOOLS_PROFILER_H
358 XLAT_REGISTER_PROFILING_VOID(
"gperftools.stop", xlat_func_gperftools_stop);
359 XLAT_REGISTER_PROFILING_VOID(
"gperftools.flush", xlat_func_gperftools_flush);
362#undef XLAT_REGISTER_PROFILING
363#undef XLAT_REGISTER_PROFILING_VOID
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
#define RUNNING_ON_VALGRIND
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_BOOL
A truth value.
#define XLAT_ARGS(_list,...)
Populate local variables with value boxes from the input list.
unsigned int required
Argument must be present, and non-empty.
#define XLAT_ARG_PARSER_TERMINATOR
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition for a single argument consumed by an xlat function.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
static fr_sbuff_err_t char ** out
bool xlat_file_allowed(request_t *request, fr_value_box_t const *vb, int oflags)
xlat_arg_parser_t const xlat_func_file_name_args[]
int xlat_profiling_init(void)
Register the control functions for every profiler that the build compiled in.