Allow starting javascript tracing via an API from privileged codebases
Categories
(DevTools :: Debugger, task)
Tracking
(firefox114 fixed)
Tracking | Status | |
---|---|---|
firefox114 | --- | fixed |
People
(Reporter: ochameau, Assigned: ochameau)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 2 obsolete files)
Bug 1803616 is introducing Javascript tracing, but this can only be enable from the debugger on-demand by clicking on a debugger button.
So that we can't control precisely when to start tracing.
This can be quite problematic as javascript tracing can quickly become very verbose.
It would be handy if we could call some API to control start and stop of JS tracing.
It would be similar to debugger;
statement.
In https://phabricator.services.mozilla.com/D168300 I experimented re-using console.profile/profileEnd methods which aren't used in Firefox. console is an handy object as it is easily available from privileged as well as webpages.
Assignee | ||
Comment 1•1 year ago
|
||
These two methods are defunct since we removed the old performance panel.
You can toggle tracing via "log breakpoints" by calling these methods:
- start tracing => console.profile()
- stop tracing => console.profileEnd()
You may pass "webconsole" or "stdout" at first agument to console.profile()
to choose where to log the traces.
Updated•1 year ago
|
Assignee | ||
Comment 2•1 year ago
|
||
For now, you could only toggle tracing from the debugger interface.
Having an API would help debugging tests and start'n stop tracing
from precise locations.
This would also ease passing parameters to have configurable traces.
Updated•1 year ago
|
Assignee | ||
Updated•1 year ago
|
Comment 3•1 year ago
|
||
Comment on attachment 9326918 [details]
Bug 1817834 - [devtools] Allow to start and stop JavaScript tracing via console.jsTrace() and console.jsTraceEnd().
Revision D174649 was moved to bug 1826389. Setting attachment 9326918 [details] to obsolete.
Assignee | ||
Comment 4•1 year ago
|
||
For now, you could only toggle tracing from the debugger interface.
Having an API would help debugging tests by start'n stop tracing from precise locations in code.
This would also ease passing parameters to have configurable traces.
With the following snipper you can toggle tracing without devtools opened by logging traces to stdout:
{
const { startTracing, stopTracing } = ChromeUtils.importESModule(
"resource://devtools/server/tracer/tracer.sys.mjs"
);
startTracing({ prefix: "prefix" });
function bar() {}; function foo() {bar()}; foo();
stopTracing();
}
It will log this to the terminal:
[prefix] Start tracing JavaScript
[prefix] —[interpreter]—> debugger eval code @ 6:43 - λ foo
[prefix] ——[interpreter]—> debugger eval code @ 6:24 - λ bar
[prefix] Stop tracing JavaScript
This typically allows to use traces on automation.
Note that if tracing is toggled by DevTools, it will integrate into this new ES Module
and will be able to log the traces to the web console.
Updated•1 year ago
|
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/77ab46da6605 [devtools] Allow to start and stop JavaScript tracing from privileged codebases. r=devtools-reviewers,nchevobbe
Comment 6•1 year ago
|
||
bugherder |
Description
•