Skip to content

feat: Add DBGP emulator - #37

Merged
pronskiy merged 2 commits into
php-debugger:mainfrom
carlos-granados:feature/add-dbgp-emulator
Apr 11, 2026
Merged

pronskiy merged 2 commits into
php-debugger:mainfrom
carlos-granados:feature/add-dbgp-emulator

Conversation

@carlos-granados

Copy link
Copy Markdown
Collaborator

Xdebug has the functionality needed to emulate a DBGP client defined in the DebugClient class but this was only used in tests.

In this PR we use this existing functionality to create a DBGP client emulator which can be run as a daemon, listening for incoming connections. It accepts an argument pointing to a file which contains a list of DBGP commands. When it accepts a connection, it will send these commands to the running php debugger and record the conversation.

This tool can be useful for two thing:

  • Debugging the php debugger by emulating a connection with a client
  • Testing the performance of the debugger when connection to a client

@carlos-granados
carlos-granados requested a review from pronskiy April 4, 2026 08:00
@carlos-granados
carlos-granados force-pushed the feature/add-dbgp-emulator branch from a60159e to 22ced68 Compare April 7, 2026 23:17
Comment thread tests/debugger/dbgp/dbgp-emulator.php Outdated
public function __construct()
{
parent::__construct();
$this->setPort(9003);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I understand DebugClient already reads $_ENV['XDEBUG_TEST_PORT'] so maybe use that or add -port=9003 ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not actually use that ENV. I have added a --port command line option

Comment thread tests/debugger/dbgp/dbgp-emulator.php Outdated
echo "Waiting for debugger connection...\n";

$daemon->runEmulator();
?>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
?>

<?php
require_once __DIR__ . '/dbgpclient.php';

class DbgpEmulator extends DebugClient

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some usage example in PHPDoc would be good

@carlos-granados
carlos-granados force-pushed the feature/add-dbgp-emulator branch from 22ced68 to 596444d Compare April 9, 2026 17:15
@pronskiy
pronskiy merged commit 34176e9 into php-debugger:main Apr 11, 2026
11 checks passed
@carlos-granados
carlos-granados deleted the feature/add-dbgp-emulator branch April 11, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants