Skip to content

Commit dabe56e

Browse files
committed
Bug 1823514 - Define shared-libraries.h for non-MOZ_GECKO_PROFILER with stubbed methods r=mstange,profiler-reviewers
This patch defines shared-libraries.h header file all the time even when the MOZ_GECKO_PROFILER is not defined. `SharedLibraryInfo` class now has stubbed-out implementation-specific methods that are defined in platform specific cpp files. This allows us to always define the header file which will let us remove a lot of ifdefs in the following patch. Differential Revision: https://phabricator.services.mozilla.com/D199361
1 parent 1760a54 commit dabe56e

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

mozglue/baseprofiler/moz.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
if CONFIG["MOZ_GECKO_PROFILER"]:
1313
DEFINES["IMPL_MFBT"] = True
1414
EXPORTS += [
15-
"public/BaseProfilerSharedLibraries.h",
1615
"public/BaseProfilingStack.h",
1716
]
1817
UNIFIED_SOURCES += [
@@ -76,6 +75,7 @@ GeneratedFile(
7675
EXPORTS += [
7776
"!public/ProfilingCategoryList.h",
7877
"public/BaseProfiler.h",
78+
"public/BaseProfilerSharedLibraries.h",
7979
"public/BaseProfilingCategory.h",
8080
]
8181

mozglue/baseprofiler/public/BaseProfilerSharedLibraries.h

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#include "BaseProfiler.h"
1111

12-
#ifndef MOZ_GECKO_PROFILER
13-
# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined.
14-
#endif
15-
1612
#include <algorithm>
1713
#include <stdint.h>
1814
#include <stdlib.h>
@@ -124,12 +120,23 @@ static bool CompareAddresses(const SharedLibrary& first,
124120

125121
class SharedLibraryInfo {
126122
public:
123+
#ifdef MOZ_GECKO_PROFILER
127124
static SharedLibraryInfo GetInfoForSelf();
128-
#ifdef XP_WIN
125+
# ifdef XP_WIN
129126
static SharedLibraryInfo GetInfoFromPath(const wchar_t* aPath);
130-
#endif
127+
# endif
131128

132129
static void Initialize();
130+
#else
131+
static SharedLibraryInfo GetInfoForSelf() { return SharedLibraryInfo(); }
132+
# ifdef XP_WIN
133+
static SharedLibraryInfo GetInfoFromPath(const wchar_t* aPath) {
134+
return SharedLibraryInfo();
135+
}
136+
# endif
137+
138+
static void Initialize() {}
139+
#endif
133140

134141
SharedLibraryInfo() {}
135142

tools/profiler/moz.build

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
1414
"public/GeckoProfilerReporter.h",
1515
"public/ProfilerChild.h",
1616
"public/ProfilerCodeAddressService.h",
17-
"public/shared-libraries.h",
1817
]
1918
UNIFIED_SOURCES += [
2019
"core/PageInformation.cpp",
@@ -108,7 +107,7 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
108107
"core/PowerCounters-win.cpp",
109108
]
110109
SOURCES += {
111-
"core/ETWTools.cpp",
110+
"core/ETWTools.cpp",
112111
}
113112
SOURCES += [
114113
"core/ProfilerCPUFreq-win.cpp",
@@ -175,6 +174,7 @@ EXPORTS += [
175174
"public/ProfilerControl.h",
176175
"public/ProfilerParent.h",
177176
"public/ProfilerRustBindings.h",
177+
"public/shared-libraries.h",
178178
]
179179

180180
EXPORTS.mozilla += [

tools/profiler/public/shared-libraries.h

+13-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#ifndef SHARED_LIBRARIES_H_
88
#define SHARED_LIBRARIES_H_
99

10-
#ifndef MOZ_GECKO_PROFILER
11-
# error This header does not have a useful implementation on your platform!
12-
#endif
13-
1410
#include "nsNativeCharsetUtils.h"
1511
#include "nsString.h"
1612
#include <nsID.h>
@@ -117,12 +113,23 @@ static bool CompareAddresses(const SharedLibrary& first,
117113

118114
class SharedLibraryInfo {
119115
public:
116+
#ifdef MOZ_GECKO_PROFILER
120117
static SharedLibraryInfo GetInfoForSelf();
121-
#ifdef XP_WIN
118+
# ifdef XP_WIN
122119
static SharedLibraryInfo GetInfoFromPath(const wchar_t* aPath);
123-
#endif
120+
# endif
124121

125122
static void Initialize();
123+
#else
124+
static SharedLibraryInfo GetInfoForSelf() { return SharedLibraryInfo(); }
125+
# ifdef XP_WIN
126+
static SharedLibraryInfo GetInfoFromPath(const wchar_t* aPath) {
127+
return SharedLibraryInfo();
128+
}
129+
# endif
130+
131+
static void Initialize() {}
132+
#endif
126133

127134
void AddSharedLibrary(SharedLibrary entry) { mEntries.push_back(entry); }
128135

0 commit comments

Comments
 (0)