1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
5 /* XRay -- a simple profiler for Native Client */
8 #ifndef LIBRARIES_XRAY_XRAY_H_
9 #define LIBRARIES_XRAY_XRAY_H_
13 #ifndef XRAY_DISABLE_BROWSER_INTEGRATION
14 #include "ppapi/c/ppb.h"
25 #define XRAY_NO_INSTRUMENT __attribute__((no_instrument_function))
26 #define XRAY_INLINE __attribute__((always_inline, no_instrument_function))
30 /* Do not call __XRayAnnotate* directly; instead use the */
31 /* XRayAnnotate() macros below. */
32 XRAY_NO_INSTRUMENT
void __XRayAnnotate(const char* str
, ...)
33 __attribute__ ((format(printf
, 1, 2)));
34 XRAY_NO_INSTRUMENT
void __XRayAnnotateFiltered(const uint32_t filter
,
35 const char* str
, ...) __attribute__ ((format(printf
, 2, 3)));
37 /* This is the beginning of the public XRay API */
39 /* Ok if mapfilename is NULL, no symbols will be loaded. On glibc builds,
40 * XRay will also attempt to populate the symbol table with dladdr()
42 XRAY_NO_INSTRUMENT
struct XRayTraceCapture
* XRayInit(int stack_size
,
45 const char* mapfilename
);
46 XRAY_NO_INSTRUMENT
void XRayShutdown(struct XRayTraceCapture
* capture
);
47 XRAY_NO_INSTRUMENT
void XRayStartFrame(struct XRayTraceCapture
* capture
);
48 XRAY_NO_INSTRUMENT
void XRayEndFrame(struct XRayTraceCapture
* capture
);
49 XRAY_NO_INSTRUMENT
void XRaySetAnnotationFilter(
50 struct XRayTraceCapture
* capture
, uint32_t filter
);
51 XRAY_NO_INSTRUMENT
void XRaySaveReport(struct XRayTraceCapture
* capture
,
55 XRAY_NO_INSTRUMENT
void XRayReport(struct XRayTraceCapture
* capture
,
60 #ifndef XRAY_DISABLE_BROWSER_INTEGRATION
61 XRAY_NO_INSTRUMENT
void XRayBrowserTraceReport(
62 struct XRayTraceCapture
* capture
);
63 XRAY_NO_INSTRUMENT
void XRayRegisterBrowserInterface(
64 PPB_GetInterface get_browser_interface
);
65 #endif /* XRAY_DISABLE_BROWSER_INTEGRATION */
68 #if defined(XRAY_ANNOTATE)
69 #define XRayAnnotate(...) __XRayAnnotate(__VA_ARGS__)
70 #define XRayAnnotateFiltered(...) __XRayAnnotateFiltered(__VA_ARGS__)
72 #define XRayAnnotate(...)
73 #define XRayAnnotateFiltered(...)
75 /* This is the end of the public XRay API */
77 #else /* defined(XRAY) */
79 /* Builds that don't define XRAY will use these 'null' functions instead. */
81 #define XRayAnnotate(...)
82 #define XRayAnnotateFiltered(...)
84 inline struct XRayTraceCapture
* XRayInit(int stack_size
,
87 const char* mapfilename
) {
90 inline void XRayShutdown(struct XRayTraceCapture
* capture
) {}
91 inline void XRayStartFrame(struct XRayTraceCapture
* capture
) {}
92 inline void XRayEndFrame(struct XRayTraceCapture
* capture
) {}
93 inline void XRaySetAnnotationFilter(struct XRayTraceCapture
* capture
,
95 inline void XRaySaveReport(struct XRayTraceCapture
* capture
,
99 inline void XRayReport(struct XRayTraceCapture
* capture
,
101 float percent_cutoff
,
104 #ifndef XRAY_DISABLE_BROWSER_INTEGRATION
105 inline void XRayBrowserTraceReport(struct XRayTraceCapture
* capture
) {}
106 inline void XRayRegisterBrowserInterface(
107 PPB_GetInterface get_browser_interface
) {}
108 #endif /* XRAY_DISABLE_BROWSER_INTEGRATION */
111 #endif /* defined(XRAY) */
117 #endif /* LIBRARIES_XRAY_XRAY_H_ */