31RCSID(
"$Id: 5aa3f4df72f97d6dcc77de07a316dae86f1de12a $")
33#include <freeradius-devel/server/base.h>
34#include <freeradius-devel/unlang/xlat_priv.h>
36#ifdef HAVE_VALGRIND_CALLGRIND_H
37# include <valgrind/callgrind.h>
46static bool callgrind_attached(
request_t *request)
50 RERROR(
"Refusing callgrind request, the server is not running under valgrind");
79 CALLGRIND_START_INSTRUMENTATION;
111 CALLGRIND_STOP_INSTRUMENTATION;
153 CALLGRIND_DUMP_STATS_AT(label->vb_strvalue);
155 CALLGRIND_DUMP_STATS;
188 CALLGRIND_ZERO_STATS;
198#ifdef HAVE_GPERFTOOLS_PROFILER_H
199# include <gperftools/profiler.h>
225 struct ProfilerState
state;
232 ProfilerGetCurrentState(&
state);
234 RERROR(
"Profiler already running, writing to %s",
state.profile_name);
238 if (ProfilerStart(vb->vb_strvalue) == 0) {
239 RERROR(
"Failed starting profiler with output file %s", vb->vb_strvalue);
252static bool gperftools_running(
request_t *request)
254 struct ProfilerState
state;
256 ProfilerGetCurrentState(&
state);
257 if (
state.enabled)
return true;
259 RERROR(
"Profiler not running");
332#if defined(HAVE_VALGRIND_CALLGRIND_H) || defined(HAVE_GPERFTOOLS_PROFILER_H)
335#define XLAT_REGISTER_PROFILING(_xlat, _func, _args) \
337 if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_BOOL)) == NULL)) return -1; \
338 xlat_func_args_set(xlat, _args); \
339 xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL); \
342#define XLAT_REGISTER_PROFILING_VOID(_xlat, _func) \
344 if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_BOOL)) == NULL)) return -1; \
345 xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL); \
348# ifdef HAVE_VALGRIND_CALLGRIND_H
349 XLAT_REGISTER_PROFILING_VOID(
"callgrind.start", xlat_func_callgrind_start);
350 XLAT_REGISTER_PROFILING_VOID(
"callgrind.stop", xlat_func_callgrind_stop);
351 XLAT_REGISTER_PROFILING(
"callgrind.dump", xlat_func_callgrind_dump, xlat_func_callgrind_dump_args);
352 XLAT_REGISTER_PROFILING_VOID(
"callgrind.zero", xlat_func_callgrind_zero);
355# ifdef HAVE_GPERFTOOLS_PROFILER_H
357 XLAT_REGISTER_PROFILING_VOID(
"gperftools.stop", xlat_func_gperftools_stop);
358 XLAT_REGISTER_PROFILING_VOID(
"gperftools.flush", xlat_func_gperftools_flush);
361#undef XLAT_REGISTER_PROFILING
362#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 size_t char ** out
bool xlat_file_allowed(request_t *request, fr_value_box_t const *vb)
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.