-
Notifications
You must be signed in to change notification settings - Fork 339
[XDebug Bridge] Exclude file and directory paths from devtools stack and debugging #2423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
I will need to add tests before making it ready for review. |
I added tests based on the tests from pull request #2409. |
There's a few conflicts to resolve and the implementation section of the description is missing (a sentence or two should suffice here) but other than that it LGTM. Let's fix those and merge – thank you @mho22! |
}, | ||
}); | ||
if (this.isExcludedPath(fileUri)) { | ||
this.sendDbgpCommand('step_over'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The excluded file could call a function defined in a non-excluded file. Would step_over
ignore the entire call and never step into that other file? This isn't relevant for breaking on the first line but it is relevant for calls made by Playground-level mu-plugins, e.g. the SQLite integration plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oho. I guess it will ignore the file. It should also check the command. If the command is step_into
then, don't ignore the file. I'll need to test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn't understand your sentence correctly a few days ago! The excluded file won't be "loaded" by Devtools but its code will be run as expected. So if an excluded file is running a function from a non excluded file it will pause the script on the first line of the non-excluded file.
The opposite will happen though. If you run a script that calls another one that has an excluded path, you won't see anything from that excluded path script. That is why I understood with my last comment.
That is why I should let the current code change but I should add a second condition in the if statement indicating that if the current command is step_into
and the file has an excluded path we should not step_over
and show the script.
I am adding a new test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mho22 to make sure we're aligned, let's discuss different scenarios. Let's also create a test case for each of them.
Scenario 1 – basic exclusion
// In main.php:
require_once "excluded.php";
// Breakpoint is set on this line:
excluded_function();
boot_wordpress();
// In excluded.php:
function excluded_function() {
// ... logic ...
}
In this scenario, stepping into excluded_function
would be the same as stepping over it – we'd advance to boot_wordpress()
.
Scenario 2 – excluded file in a stack trace
// In main.php:
require_once "excluded.php";
function boot_wordpress() {
// Breakpoint on the next line
require "wp-load.php";
}
// Breakpoint is set on this line:
excluded_function();
// In excluded.php:
function excluded_function() {
global $log;
$log->info("Booting WordPress");
boot_wordpress();
}
In this scenario, stepping into excluded_function();
would:
- Skip the body of
excluded_function()
- Move the execution inside
boot_wordpress()
where we could continue stepping into or stepping over
Similarly, in this scenario:
// main.php
// breakpoint set here:
require_once "excluded.php";
// excluded.php:
require_once "my-app.php";
// my-app.php:
call1();
call2();
Stepping into the firs require_once would, ideally, move us into the first line of my-app.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need some time to test your scenarios.
a2 | ||
) => {}) /* a dynamic function call to signature vii, but there are no exported function pointers with that signature, so this path should never be taken. Build with ASSERTIONS enabled to validate. */( | ||
handle, | ||
((a1, a2) => {})( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should php_8_3.js and other PHP JS files be shipped with this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something went wrong with the merge conflicts. Let's start again.
}), | ||
]), | ||
it('ignores files from excluded path except when stepping into manually', async () => { | ||
const excludedPath = `${fixtures}/excluded-paths/`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use more intuitive names for those files. E.g. excluded-paths.php
could be called something runs-excluded-script
and then the excluded-paths
directory could be called excluded-source-root
or something like that.
|
||
let steps = 5; | ||
|
||
await new Promise<void>((resolve) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it difficult to follow what this test is doing. Let's add some human-friendly annotations.
66676d3
to
b233abe
Compare
Motivation for the change, related issues
Based on this comment and pull request.
In Playground CLI, the first line where Xdebug stops in Devtools is the
auto_prepend_file.php
file located in theinternal
directory. This pull request aims to ignore what's in the directory by adding aexcludedPaths
option in the bridge that will be ignored when stacking or stepping.Implementation details
Added an
excludedPath
option to thestartBridge
function. When specified,XdebugCDPBridge
will check this option, and the DevTools willstep_over
any file matching the excluded path, skipping its parsing.Testing Instructions
With script
cli.ts
:Run command :
Before
After