diff options
author | Dean Michael Berris <dberris@google.com> | 2016-07-20 14:14:50 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2016-07-20 14:14:50 +0000 |
commit | 9b1dbf02c9adffedc28c56284967ab87941abb53 (patch) | |
tree | 1d50233d892ea15bb6365087fed3e1758f576472 /lib/xray/xray_flags.cc | |
parent | e35e7c00b5c7e7ee5e24d537b80cb0d34cebb038 (diff) |
[compiler-rt] [XRay] Basic initialization and flag definition for XRay runtime
Summary:
This patch implements the initialisation and patching routines for the XRay runtime, along with the necessary trampolines for function entry/exit handling. For now we only define the basic hooks for allowing an implementation to define a handler that gets run on function entry/exit. We expose a minimal API for controlling the behaviour of the runtime (patching, cleanup, and setting the handler to invoke when instrumenting).
Depends on D19904
Reviewers: echristo, kcc, rnk
Subscribers: rnk, mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D21612
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/xray/xray_flags.cc')
-rw-r--r-- | lib/xray/xray_flags.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/xray/xray_flags.cc b/lib/xray/xray_flags.cc new file mode 100644 index 000000000..6f829128c --- /dev/null +++ b/lib/xray/xray_flags.cc @@ -0,0 +1,61 @@ +//===-- xray_flags.cc -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of XRay, a dynamic runtime instrumentation system. +// +// XRay flag parsing logic. +//===----------------------------------------------------------------------===// + +#include "xray_flags.h" +#include "sanitizer_common/sanitizer_common.h" +#include "sanitizer_common/sanitizer_flag_parser.h" +#include "sanitizer_common/sanitizer_libc.h" + +using namespace __sanitizer; + +namespace __xray { + +Flags xray_flags_dont_use_directly; // use via flags(). + +void Flags::SetDefaults() { +#define XRAY_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue; +#include "xray_flags.inc" +#undef XRAY_FLAG +} + +static void RegisterXRayFlags(FlagParser *P, Flags *F) { +#define XRAY_FLAG(Type, Name, DefaultValue, Description) \ + RegisterFlag(P, #Name, Description, &F->Name); +#include "xray_flags.inc" +#undef XRAY_FLAG +} + +void InitializeFlags() { + SetCommonFlagsDefaults(); + auto *F = flags(); + F->SetDefaults(); + + FlagParser XRayParser; + RegisterXRayFlags(&XRayParser, F); + RegisterCommonFlags(&XRayParser); + + // Override from command line. + XRayParser.ParseString(GetEnv("XRAY_OPTIONS")); + + InitializeCommonFlags(); + + if (Verbosity()) + ReportUnrecognizedFlags(); + + if (common_flags()->help) { + XRayParser.PrintFlagDescriptions(); + } +} + +} // namespace __xray |