Unused BaseProfilerLogTest declaration in baseprofiler/core/platform.h
Categories
(Core :: Gecko Profiler, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox76 | --- | fixed |
People
(Reporter: mstange, Assigned: mstange)
References
Details
Attachments
(2 files)
There's a declaration of a function named BaseProfilerLogTest in mozglue/baseprofiler/core/platform.h: https://searchfox.org/mozilla-central/source/mozglue/baseprofiler/core/platform.h#44
Clicking the function does not show a "Go to definition" item.
The definition is here: https://searchfox.org/mozilla-central/source/mozglue/baseprofiler/core/platform.cpp#151
Comment 1•6 years ago
|
||
The header is BaseProfilerLogTest but the definition is mozilla::baseprofiler::BaseProfilerLogTest, so they don't link up. That might be an actual bug in the code?
| Assignee | ||
Comment 2•6 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #1)
The header is
BaseProfilerLogTestbut the definition ismozilla::baseprofiler::BaseProfilerLogTest, so they don't link up. That might be an actual bug in the code?
Cool! It might be! Things do compile and link fine though. I'm not sure of the semantics here. So yes, we should probably fix it, but if our regular linker links them up, shouldn't searchfox also be able to link them up?
Comment 3•6 years ago
|
||
The calls to the functions are done via macros, so all semantic processing such as name lookup happens at the site of the macro invocations. The function is also only required to be declared at those invocations, rather than at the location of the macro definition.
So what's happening is the declaration in platform.h declares an unrelated global ::BaseProfilerLogTest function which is never used, and all the macro invocations (I'm assuming) occur inside mozilla::baseprofiler and correctly find mozilla::baseprofiler::BaseProfilerLogTest.
| Assignee | ||
Comment 4•6 years ago
|
||
Hah, nice! Moving to the Gecko Profiler component. Thanks for the explanation!
Comment 5•6 years ago
|
||
The fact that the macro makes an unqualified call is bug-prone, because any macro invocations that may be added outside of mozilla::baseprofiler in the future could hypothetically resolve to a different function.
My suggestion would be to modify the macros to qualify the call explicitly:
#define LOG_TEST mozilla::baseprofiler::BaseProfileLogTest(3)
// etc.
and then forward-declare the function inside that namespace:
namespace mozilla {
namespace baseprofiler {
bool BaseProfilerLogTest(int aLevelToTest);
}
}
(While it's only the invocation sites of the macros that require this forward declaration to be in scope, it's still a good idea for the same header that defines the macros to provide the forward declaration.)
| Assignee | ||
Comment 6•6 years ago
|
||
I'll take care of this.
| Assignee | ||
Comment 7•6 years ago
|
||
This fixes the declaration of (BaseProfiler)LogTest. It also makes it so that the logs show up on Android.
In xpcom we have printf_stderr which does something similar and also handles Windows.
Depends on D64990
| Assignee | ||
Comment 8•6 years ago
|
||
Depends on D64994
| Assignee | ||
Updated•6 years ago
|
Comment 10•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/5c978c229b66
https://hg.mozilla.org/mozilla-central/rev/daf1993b5140
Description
•