Skip to content

Conversation

mho22
Copy link
Collaborator

@mho22 mho22 commented Jul 25, 2025

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 the internal directory. This pull request aims to ignore what's in the directory by adding a excludedPaths option in the bridge that will be ignored when stacking or stepping.

Implementation details

Added an excludedPath option to the startBridge function. When specified, XdebugCDPBridge will check this option, and the DevTools will step_over any file matching the excluded path, skipping its parsing.

Testing Instructions

With script cli.ts :

import { runCLI } from "./packages/playground/cli/src/run-cli";

const script = `<?php

$test = 42;

echo "Output!\n";

function test() {
	echo "Hello Xdebug World!\n";
}

test();
`;

const cliServer = await runCLI({command: 'server', xdebug: true, experimentalDevtools: true});

cliServer.playground.writeFile('xdebug.php', script);

const result = await cliServer.playground.run({scriptPath: `xdebug.php`});

console.log(result.text);

Run command :

node --no-warnings --experimental-wasm-stack-switching --experimental-wasm-jspi --loader=./packages/meta/src/node-es-module-loader/loader.mts cli.ts

Before

before

After

after

@mho22 mho22 changed the title [Xdebug Bridge] Exclude file and directory paths from devtools stack and debugging [XDebug Bridge] Exclude file and directory paths from devtools stack and debugging Jul 25, 2025
@mho22 mho22 mentioned this pull request Jul 25, 2025
10 tasks
@mho22
Copy link
Collaborator Author

mho22 commented Aug 4, 2025

I will need to add tests before making it ready for review.

@mho22
Copy link
Collaborator Author

mho22 commented Aug 18, 2025

I added tests based on the tests from pull request #2409.

@mho22 mho22 marked this pull request as ready for review August 18, 2025 15:28
@brandonpayton brandonpayton requested a review from a team August 20, 2025 17:48
@adamziel
Copy link
Collaborator

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!

@mho22 mho22 requested a review from adamziel August 26, 2025 12:43
},
});
if (this.isExcludedPath(fileUri)) {
this.sendDbgpCommand('step_over');
Copy link
Collaborator

@adamziel adamziel Aug 28, 2025

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.

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants