1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* FFI functions for Profiler Rust API to call into profiler */
9 #ifndef ProfilerBindings_h
10 #define ProfilerBindings_h
12 #include "mozilla/BaseProfilerMarkersPrerequisites.h"
18 class AutoProfilerLabel
;
22 enum class StackCaptureOptions
;
24 namespace baseprofiler
{
25 enum class ProfilingCategoryPair
: uint32_t;
26 class SpliceableJSONWriter
;
27 } // namespace baseprofiler
29 } // namespace mozilla
32 enum class ProfilingCategoryPair
: uint32_t;
35 // Everything in here is safe to include unconditionally, implementations must
36 // take !MOZ_GECKO_PROFILER into account.
39 void gecko_profiler_register_thread(const char* aName
);
40 void gecko_profiler_unregister_thread();
42 void gecko_profiler_construct_label(mozilla::AutoProfilerLabel
* aAutoLabel
,
43 JS::ProfilingCategoryPair aCategoryPair
);
44 void gecko_profiler_destruct_label(mozilla::AutoProfilerLabel
* aAutoLabel
);
46 // Construct, clone and destruct the timestamp for profiler time.
47 void gecko_profiler_construct_timestamp_now(mozilla::TimeStamp
* aTimeStamp
);
48 void gecko_profiler_clone_timestamp(const mozilla::TimeStamp
* aSrcTimeStamp
,
49 mozilla::TimeStamp
* aDestTimeStamp
);
50 void gecko_profiler_destruct_timestamp(mozilla::TimeStamp
* aTimeStamp
);
52 // Addition and subtraction for timestamp.
53 void gecko_profiler_add_timestamp(const mozilla::TimeStamp
* aTimeStamp
,
54 mozilla::TimeStamp
* aDestTimeStamp
,
55 double aMicroseconds
);
56 void gecko_profiler_subtract_timestamp(const mozilla::TimeStamp
* aTimeStamp
,
57 mozilla::TimeStamp
* aDestTimeStamp
,
58 double aMicroseconds
);
60 // Various MarkerTiming constructors and a destructor.
61 void gecko_profiler_construct_marker_timing_instant_at(
62 mozilla::MarkerTiming
* aMarkerTiming
, const mozilla::TimeStamp
* aTime
);
63 void gecko_profiler_construct_marker_timing_instant_now(
64 mozilla::MarkerTiming
* aMarkerTiming
);
65 void gecko_profiler_construct_marker_timing_interval(
66 mozilla::MarkerTiming
* aMarkerTiming
, const mozilla::TimeStamp
* aStartTime
,
67 const mozilla::TimeStamp
* aEndTime
);
68 void gecko_profiler_construct_marker_timing_interval_until_now_from(
69 mozilla::MarkerTiming
* aMarkerTiming
, const mozilla::TimeStamp
* aStartTime
);
70 void gecko_profiler_construct_marker_timing_interval_start(
71 mozilla::MarkerTiming
* aMarkerTiming
, const mozilla::TimeStamp
* aTime
);
72 void gecko_profiler_construct_marker_timing_interval_end(
73 mozilla::MarkerTiming
* aMarkerTiming
, const mozilla::TimeStamp
* aTime
);
74 void gecko_profiler_destruct_marker_timing(
75 mozilla::MarkerTiming
* aMarkerTiming
);
77 // MarkerSchema constructors and destructor.
78 mozilla::MarkerSchema
* gecko_profiler_construct_marker_schema(
79 const mozilla::MarkerSchema::Location
* aLocations
, size_t aLength
);
80 mozilla::MarkerSchema
*
81 gecko_profiler_construct_marker_schema_with_special_front_end_location();
82 void gecko_profiler_destruct_marker_schema(
83 mozilla::MarkerSchema
* aMarkerSchema
);
85 // MarkerSchema methods for adding labels.
86 void gecko_profiler_marker_schema_set_chart_label(
87 mozilla::MarkerSchema
* aSchema
, const char* aLabel
, size_t aLabelLength
);
88 void gecko_profiler_marker_schema_set_tooltip_label(
89 mozilla::MarkerSchema
* aSchema
, const char* aLabel
, size_t aLabelLength
);
90 void gecko_profiler_marker_schema_set_table_label(
91 mozilla::MarkerSchema
* aSchema
, const char* aLabel
, size_t aLabelLength
);
92 void gecko_profiler_marker_schema_set_all_labels(mozilla::MarkerSchema
* aSchema
,
96 // MarkerSchema methods for adding key/key-label values.
97 void gecko_profiler_marker_schema_add_key_format(
98 mozilla::MarkerSchema
* aSchema
, const char* aKey
, size_t aKeyLength
,
99 mozilla::MarkerSchema::Format aFormat
);
100 void gecko_profiler_marker_schema_add_key_label_format(
101 mozilla::MarkerSchema
* aSchema
, const char* aKey
, size_t aKeyLength
,
102 const char* aLabel
, size_t aLabelLength
,
103 mozilla::MarkerSchema::Format aFormat
);
104 void gecko_profiler_marker_schema_add_key_format_searchable(
105 mozilla::MarkerSchema
* aSchema
, const char* aKey
, size_t aKeyLength
,
106 mozilla::MarkerSchema::Format aFormat
,
107 mozilla::MarkerSchema::Searchable aSearchable
);
108 void gecko_profiler_marker_schema_add_key_label_format_searchable(
109 mozilla::MarkerSchema
* aSchema
, const char* aKey
, size_t aKeyLength
,
110 const char* aLabel
, size_t aLabelLength
,
111 mozilla::MarkerSchema::Format aFormat
,
112 mozilla::MarkerSchema::Searchable aSearchable
);
113 void gecko_profiler_marker_schema_add_static_label_value(
114 mozilla::MarkerSchema
* aSchema
, const char* aLabel
, size_t aLabelLength
,
115 const char* aValue
, size_t aValueLength
);
117 // Stream MarkerSchema to SpliceableJSONWriter.
118 void gecko_profiler_marker_schema_stream(
119 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
120 size_t aNameLength
, mozilla::MarkerSchema
* aMarkerSchema
,
121 void* aStreamedNamesSet
);
123 // Various SpliceableJSONWriter methods to add properties.
124 void gecko_profiler_json_writer_int_property(
125 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
126 size_t aNameLength
, int64_t aValue
);
127 void gecko_profiler_json_writer_float_property(
128 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
129 size_t aNameLength
, double aValue
);
130 void gecko_profiler_json_writer_bool_property(
131 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
132 size_t aNameLength
, bool aValue
);
133 void gecko_profiler_json_writer_string_property(
134 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
135 size_t aNameLength
, const char* aValue
, size_t aValueLength
);
136 void gecko_profiler_json_writer_unique_string_property(
137 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
138 size_t aNameLength
, const char* aValue
, size_t aValueLength
);
139 void gecko_profiler_json_writer_null_property(
140 mozilla::baseprofiler::SpliceableJSONWriter
* aWriter
, const char* aName
,
144 void gecko_profiler_add_marker_untyped(
145 const char* aName
, size_t aNameLength
,
146 mozilla::baseprofiler::ProfilingCategoryPair aCategoryPair
,
147 mozilla::MarkerTiming
* aMarkerTiming
,
148 mozilla::StackCaptureOptions aStackCaptureOptions
);
149 void gecko_profiler_add_marker_text(
150 const char* aName
, size_t aNameLength
,
151 mozilla::baseprofiler::ProfilingCategoryPair aCategoryPair
,
152 mozilla::MarkerTiming
* aMarkerTiming
,
153 mozilla::StackCaptureOptions aStackCaptureOptions
, const char* aText
,
155 void gecko_profiler_add_marker(
156 const char* aName
, size_t aNameLength
,
157 mozilla::baseprofiler::ProfilingCategoryPair aCategoryPair
,
158 mozilla::MarkerTiming
* aMarkerTiming
,
159 mozilla::StackCaptureOptions aStackCaptureOptions
, uint8_t aMarkerTag
,
160 const uint8_t* aPayload
, size_t aPayloadSize
);
164 #endif // ProfilerBindings_h