Source code

Revision control

Other Tools

1
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsISupports.idl"
7
8
%{C++
9
#include "mozilla/Maybe.h"
10
#include "nsTArrayForwardDeclare.h"
11
#include "nsStringFwd.h"
12
%}
13
14
[ref] native nsCString(const nsCString);
15
[ref] native StringArrayRef(const nsTArray<nsCString>);
16
17
/**
18
* Start-up parameters for subprocesses are passed through nsIObserverService,
19
* which, unfortunately, means we need to implement nsISupports in order to
20
* go through it.
21
*/
22
[scriptable, builtinclass, uuid(0a175ba7-8fcf-4ce9-9c4b-ccc6272f4425)]
23
interface nsIProfilerStartParams : nsISupports
24
{
25
readonly attribute uint32_t entries;
26
readonly attribute double duration;
27
readonly attribute double interval;
28
readonly attribute uint32_t features;
29
30
[noscript, notxpcom, nostdcall] StringArrayRef getFilters();
31
};
32
33
[scriptable, builtinclass, uuid(ead3f75c-0e0e-4fbb-901c-1e5392ef5b2a)]
34
interface nsIProfiler : nsISupports
35
{
36
boolean CanProfile();
37
void StartProfiler(in uint32_t aEntries, in double aInterval,
38
in Array<AUTF8String> aFeatures,
39
[optional] in Array<AUTF8String> aFilters,
40
[optional] in double aDuration);
41
void StopProfiler();
42
boolean IsPaused();
43
void PauseSampling();
44
void ResumeSampling();
45
void AddMarker(in string aMarker);
46
/*
47
* Returns the JSON string of the profile. If aSinceTime is passed, only
48
* report samples taken at >= aSinceTime.
49
*/
50
string GetProfile([optional] in double aSinceTime);
51
52
/*
53
* Returns a JS object of the profile. If aSinceTime is passed, only report
54
* samples taken at >= aSinceTime.
55
*/
56
[implicit_jscontext]
57
jsval getProfileData([optional] in double aSinceTime);
58
59
[implicit_jscontext]
60
Promise getProfileDataAsync([optional] in double aSinceTime);
61
62
[implicit_jscontext]
63
Promise getProfileDataAsArrayBuffer([optional] in double aSinceTime);
64
65
[implicit_jscontext]
66
Promise getProfileDataAsGzippedArrayBuffer([optional] in double aSinceTime);
67
68
/**
69
* Returns a promise that resolves once the file has been written.
70
*/
71
[implicit_jscontext]
72
Promise dumpProfileToFileAsync(in ACString aFilename,
73
[optional] in double aSinceTime);
74
75
boolean IsActive();
76
77
/**
78
* Clear all registered and unregistered page information in prifiler.
79
*/
80
void ClearAllPages();
81
82
/**
83
* Returns an array of the features that are supported in this build.
84
* Features may vary depending on platform and build flags.
85
*/
86
Array<AUTF8String> GetFeatures();
87
88
/**
89
* Returns an array of all features that are supported by the profiler.
90
* The array may contain features that are not supported in this build.
91
*/
92
Array<AUTF8String> GetAllFeatures();
93
94
void GetBufferInfo(out uint32_t aCurrentPosition, out uint32_t aTotalSize,
95
out uint32_t aGeneration);
96
97
/**
98
* Returns the elapsed time, in milliseconds, since the profiler's epoch.
99
* The epoch is guaranteed to be constant for the duration of the
100
* process, but is otherwise arbitrary.
101
*/
102
double getElapsedTime();
103
104
/**
105
* Contains an array of shared library objects.
106
* Every object has the properties:
107
* - start: The start address of the memory region occupied by this library.
108
* - end: The end address of the memory region occupied by this library.
109
* - offset: Usually zero, except on Linux / Android if the first mapped
110
* section of the library has been mapped to an address that's
111
* different from the library's base address.
112
* Then offset = start - baseAddress.
113
* - name: The name (file basename) of the binary.
114
* - path: The full absolute path to the binary.
115
* - debugName: On Windows, the name of the pdb file for the binary. On other
116
* platforms, the same as |name|.
117
* - debugPath: On Windows, the full absolute path of the pdb file for the
118
* binary. On other platforms, the same as |path|.
119
* - arch: On Mac, the name of the architecture that identifies the right
120
* binary image of a fat binary. Example values are "i386", "x86_64",
121
* and "x86_64h". (x86_64h is used for binaries that contain
122
* instructions that are specific to the Intel Haswell microarchitecture.)
123
* On non-Mac platforms, arch is "".
124
* - breakpadId: A unique identifier string for this library, as used by breakpad.
125
*/
126
[implicit_jscontext]
127
readonly attribute jsval sharedLibraries;
128
129
/**
130
* Returns a promise that resolves to a SymbolTableAsTuple for the binary at
131
* the given path.
132
*
133
* SymbolTable as tuple: [addrs, index, buffer]
134
* Contains a symbol table, which can be used to map addresses to strings.
135
*
136
* The first element of this tuple, commonly named "addrs", is a sorted array of
137
* symbol addresses, as library-relative offsets in bytes, in ascending order.
138
* The third element of this tuple, commonly named "buffer", is a buffer of
139
* bytes that contains all strings from this symbol table, in the order of the
140
* addresses they correspond to, in utf-8 encoded form, all concatenated
141
* together.
142
* The second element of this tuple, commonly named "index", contains positions
143
* into "buffer". For every address, that position is where the string for that
144
* address starts in the buffer.
145
* index.length == addrs.length + 1.
146
* index[addrs.length] is the end position of the last string in the buffer.
147
*
148
* The string for the address addrs[i] is
149
* (new TextDecoder()).decode(buffer.subarray(index[i], index[i + 1]))
150
*/
151
[implicit_jscontext]
152
nsISupports getSymbolTable(in ACString aDebugPath, in ACString aBreakpadID);
153
154
/**
155
* Dump the collected profile to a file.
156
*/
157
void dumpProfileToFile(in string aFilename);
158
159
[noscript, notxpcom, nostdcall]
160
void receiveShutdownProfile(in nsCString aProfile);
161
};