Skip to content

Commit

Permalink
docs: change case of Xdebug (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan authored Feb 8, 2021
1 parent 3c66f87 commit c18654d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.xdebug }}
# Top: XDebug v3
# Bottom: XDebug v2
# Top: Xdebug v3
# Bottom: Xdebug v2
ini-values: >-
xdebug.mode = debug,
xdebug.start_with_request = yes,
Expand Down
10 changes: 5 additions & 5 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PHP version:
XDebug version:
PHP version:
Xdebug version:
Adapter version:

Your launch.json:
XDebug php.ini config:
Your launch.json:
Xdebug php.ini config:

XDebug logfile (from setting `xdebug.remote_log` in php.ini):
Xdebug logfile (from setting `xdebug.remote_log` in php.ini):
Adapter logfile (from setting `"log": true` in launch.json):

Code snippet to reproduce:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ This extension is a debug adapter between VS Code and [Xdebug](https://xdebug.or
In your project, go to the debugger and hit the little gear icon and choose _PHP_. A new launch configuration will be created for you with two configurations:

- **Listen for Xdebug**
This setting will simply start listening on the specified port (by default 9000) for XDebug. If you configured XDebug like recommended above, everytime you make a request with a browser to your webserver or launch a CLI script Xdebug will connect and you can stop on breakpoints, exceptions etc.
This setting will simply start listening on the specified port (by default 9000) for Xdebug. If you configured Xdebug like recommended above, everytime you make a request with a browser to your webserver or launch a CLI script Xdebug will connect and you can stop on breakpoints, exceptions etc.
- **Launch currently open script**
This setting is an example of CLI debugging. It will launch the currently opened script as a CLI, show all stdout/stderr output in the debug console and end the debug session once the script exits.

#### Supported launch.json settings:

- `request`: Always `"launch"`
- `hostname`: The address to bind to when listening for XDebug (default: all IPv6 connections if available, else all IPv4 connections)
- `hostname`: The address to bind to when listening for Xdebug (default: all IPv6 connections if available, else all IPv4 connections)
- `port`: The port on which to listen for Xdebug (default: `9000`)
- `stopOnEntry`: Whether to break at the beginning of the script (default: `false`)
- `pathMappings`: A list of server paths mapping to the local source paths on your machine, see "Remote Host Debugging" below
- `log`: Whether to log all communication between VS Code and the adapter to the debug console. See _Troubleshooting_ further down.
- `ignore`: An optional array of glob patterns that errors should be ignored from (for example `**/vendor/**/*.php`)
- `xdebugSettings`: Allows you to override XDebug's remote debugging settings to fine tuning XDebug to your needs. For example, you can play with `max_children` and `max_depth` to change the max number of array and object children that are retrieved and the max depth in structures like arrays and objects. This can speed up the debugger on slow machines.
- `xdebugSettings`: Allows you to override Xdebug's remote debugging settings to fine tuning Xdebug to your needs. For example, you can play with `max_children` and `max_depth` to change the max number of array and object children that are retrieved and the max depth in structures like arrays and objects. This can speed up the debugger on slow machines.
For a full list of feature names that can be set please refer to the [Xdebug documentation](https://xdebug.org/docs-dbgp.php#feature-names).
- `max_children`: max number of array or object children to initially retrieve
- `max_data`: max amount of variable data to initially retrieve.
Expand Down Expand Up @@ -132,4 +132,4 @@ VS Code will open an "Extension Development Host" with the debug adapter running

The extension is written in TypeScript. You can compile it through `npm run build`. `npm run watch` enables incremental compilation.

Tests are written with Mocha and can be run with `npm test`. The tests are run in CI on Linux, macOS and Windows against multiple PHP and XDebug versions.
Tests are written with Mocha and can be run with `npm test`. The tests are run in CI on Linux, macOS and Windows against multiple PHP and Xdebug versions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0-development",
"publisher": "felixfbecker",
"license": "MIT",
"description": "Debug support for PHP with XDebug",
"description": "Debug support for PHP with Xdebug",
"keywords": [
"php",
"debug",
Expand Down Expand Up @@ -196,12 +196,12 @@
},
"hostname": {
"type": "string",
"description": "Address to bind to when listening for XDebug",
"description": "Address to bind to when listening for Xdebug",
"default": "::"
},
"port": {
"type": "number",
"description": "Port on which to listen for XDebug",
"description": "Port on which to listen for Xdebug",
"default": 9000
},
"serverSourceRoot": {
Expand Down Expand Up @@ -250,15 +250,15 @@
"description": "This feature can get set by the IDE if it wants to have more detailed internal information on properties (eg. private members of classes, etc.) Zero means that hidden members are not shown to the IDE"
}
},
"description": "Overrides for XDebug remote debugging settings. See https://xdebug.org/docs-dbgp.php#feature-names",
"description": "Overrides for Xdebug remote debugging settings. See https://xdebug.org/docs-dbgp.php#feature-names",
"default": {}
}
}
}
},
"initialConfigurations": [
{
"name": "Listen for XDebug",
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9000
Expand Down
2 changes: 1 addition & 1 deletion src/dbgp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EventEmitter } from 'events'
import * as iconv from 'iconv-lite'
import { DOMParser } from 'xmldom'

/** The encoding all XDebug messages are encoded with */
/** The encoding all Xdebug messages are encoded with */
export const ENCODING = 'iso-8859-1'

/** The two states the connection switches between */
Expand Down
6 changes: 3 additions & 3 deletions src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const RELATE_URL_OPTIONS: RelateUrl.Options = {
*/
const relativeUrl = (from: string, to: string): string => RelateUrl.relate(from, to, RELATE_URL_OPTIONS)

/** converts a server-side XDebug file URI to a local path for VS Code with respect to source root settings */
/** converts a server-side Xdebug file URI to a local path for VS Code with respect to source root settings */
export function convertDebuggerPathToClient(
fileUri: string | url.Url,
pathMapping?: { [index: string]: string }
Expand Down Expand Up @@ -71,11 +71,11 @@ export function convertDebuggerPathToClient(
return localPath
}

/** converts a local path from VS Code to a server-side XDebug file URI with respect to source root settings */
/** converts a local path from VS Code to a server-side Xdebug file URI with respect to source root settings */
export function convertClientPathToDebugger(localPath: string, pathMapping?: { [index: string]: string }): string {
let localSourceRoot: string | undefined
let serverSourceRoot: string | undefined
// XDebug always lowercases Windows drive letters in file URIs
// Xdebug always lowercases Windows drive letters in file URIs
let localFileUri = fileUrl(
localPath.replace(/^[A-Z]:\\/, match => match.toLowerCase()),
{ resolve: false }
Expand Down
46 changes: 23 additions & 23 deletions src/phpDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ function formatPropertyValue(property: xdebug.BaseProperty): string {
* This interface should always match the schema found in the mock-debug extension manifest.
*/
interface LaunchRequestArguments extends VSCodeDebugProtocol.LaunchRequestArguments {
/** The address to bind to for listening for XDebug connections (default: all IPv6 connections if available, else all IPv4 connections) */
/** The address to bind to for listening for Xdebug connections (default: all IPv6 connections if available, else all IPv4 connections) */
hostname?: string
/** The port where the adapter should listen for XDebug connections (default: 9000) */
/** The port where the adapter should listen for Xdebug connections (default: 9000) */
port?: number
/** Automatically stop target after launch. If not specified, target does not stop. */
stopOnEntry?: boolean
Expand All @@ -66,7 +66,7 @@ interface LaunchRequestArguments extends VSCodeDebugProtocol.LaunchRequestArgume
log?: boolean
/** Array of glob patterns that errors should be ignored from */
ignore?: string[]
/** XDebug configuration */
/** Xdebug configuration */
xdebugSettings?: { [featureName: string]: string | number }

// CLI options
Expand All @@ -91,15 +91,15 @@ class PhpDebugSession extends vscode.DebugSession {
/** The arguments that were given to launchRequest */
private _args: LaunchRequestArguments

/** The TCP server that listens for XDebug connections */
/** The TCP server that listens for Xdebug connections */
private _server: net.Server

/** The child process of the launched PHP script, if launched by the debug adapter */
private _phpProcess?: childProcess.ChildProcess

/**
* A map from VS Code thread IDs to XDebug Connections.
* XDebug makes a new connection for each request to the webserver, we present these as threads to VS Code.
* A map from VS Code thread IDs to Xdebug Connections.
* Xdebug makes a new connection for each request to the webserver, we present these as threads to VS Code.
* The threadId key is equal to the id attribute of the connection.
*/
private _connections = new Map<number, xdebug.Connection>()
Expand All @@ -110,34 +110,34 @@ class PhpDebugSession extends vscode.DebugSession {
/** A counter for unique source IDs */
private _sourceIdCounter = 1

/** A map of VS Code source IDs to XDebug file URLs for virtual files (dpgp://whatever) and the corresponding connection */
/** A map of VS Code source IDs to Xdebug file URLs for virtual files (dpgp://whatever) and the corresponding connection */
private _sources = new Map<number, { connection: xdebug.Connection; url: string }>()

/** A counter for unique stackframe IDs */
private _stackFrameIdCounter = 1

/** A map from unique stackframe IDs (even across connections) to XDebug stackframes */
/** A map from unique stackframe IDs (even across connections) to Xdebug stackframes */
private _stackFrames = new Map<number, xdebug.StackFrame>()

/** A map from XDebug connections to their current status */
/** A map from Xdebug connections to their current status */
private _statuses = new Map<xdebug.Connection, xdebug.StatusResponse>()

/** A counter for unique context, property and eval result properties (as these are all requested by a VariableRequest from VS Code) */
private _variableIdCounter = 1

/** A map from unique VS Code variable IDs to XDebug statuses for virtual error stack frames */
/** A map from unique VS Code variable IDs to Xdebug statuses for virtual error stack frames */
private _errorStackFrames = new Map<number, xdebug.StatusResponse>()

/** A map from unique VS Code variable IDs to XDebug statuses for virtual error scopes */
/** A map from unique VS Code variable IDs to Xdebug statuses for virtual error scopes */
private _errorScopes = new Map<number, xdebug.StatusResponse>()

/** A map from unique VS Code variable IDs to an XDebug contexts */
/** A map from unique VS Code variable IDs to an Xdebug contexts */
private _contexts = new Map<number, xdebug.Context>()

/** A map from unique VS Code variable IDs to a XDebug properties */
/** A map from unique VS Code variable IDs to a Xdebug properties */
private _properties = new Map<number, xdebug.Property>()

/** A map from unique VS Code variable IDs to XDebug eval result properties, because property children returned from eval commands are always inlined */
/** A map from unique VS Code variable IDs to Xdebug eval result properties, because property children returned from eval commands are always inlined */
private _evalResultProperties = new Map<number, xdebug.EvalResultProperty>()

/** A flag to indicate that the adapter has already processed the stopOnEntry step request */
Expand Down Expand Up @@ -250,13 +250,13 @@ class PhpDebugSession extends vscode.DebugSession {
this._phpProcess = script
}
}
/** sets up a TCP server to listen for XDebug connections */
/** sets up a TCP server to listen for Xdebug connections */
const createServer = () =>
new Promise<void>((resolve, reject) => {
const server = (this._server = net.createServer())
server.on('connection', async (socket: net.Socket) => {
try {
// new XDebug connection
// new Xdebug connection
const connection = new xdebug.Connection(socket)
if (args.log) {
this.sendEvent(new vscode.OutputEvent('new connection ' + connection.id + '\n'), true)
Expand Down Expand Up @@ -456,7 +456,7 @@ class PhpDebugSession extends vscode.DebugSession {
vscodeBreakpoints = args.breakpoints!.map(breakpoint => ({ verified: false, line: breakpoint.line }))
} else {
vscodeBreakpoints = []
// create XDebug breakpoints from the arguments
// create Xdebug breakpoints from the arguments
xdebugBreakpoints = args.breakpoints!.map(breakpoint => {
if (breakpoint.condition) {
return new xdebug.ConditionalBreakpoint(breakpoint.condition, fileUri, breakpoint.line)
Expand Down Expand Up @@ -651,7 +651,7 @@ class PhpDebugSession extends vscode.DebugSession {
protected threadsRequest(response: VSCodeDebugProtocol.ThreadsResponse): void {
// PHP doesn't have threads, but it may have multiple requests in parallel.
// Think about a website that makes multiple, parallel AJAX requests to your PHP backend.
// XDebug opens a new socket connection for each of them, we tell VS Code that these are our threads.
// Xdebug opens a new socket connection for each of them, we tell VS Code that these are our threads.
const connections = Array.from(this._connections.values())
response.body = {
threads: connections.map(
Expand Down Expand Up @@ -699,7 +699,7 @@ class PhpDebugSession extends vscode.DebugSession {
// for eval code, we add a "<?php" line at the beginning to get syntax highlighting (see sourceRequest)
line++
} else {
// XDebug paths are URIs, VS Code file paths
// Xdebug paths are URIs, VS Code file paths
const filePath = convertDebuggerPathToClient(urlObject, this._args.pathMappings)
// "Name" of the source and the actual file path
source = { name: path.basename(filePath), path: filePath }
Expand All @@ -725,7 +725,7 @@ class PhpDebugSession extends vscode.DebugSession {
// for eval code, we add a "<?php" line at the beginning to get syntax highlighting (see sourceRequest)
line++
} else {
// XDebug paths are URIs, VS Code file paths
// Xdebug paths are URIs, VS Code file paths
const filePath = convertDebuggerPathToClient(urlObject, this._args.pathMappings)
// "Name" of the source and the actual file path
source = { name: path.basename(filePath), path: filePath }
Expand All @@ -734,7 +734,7 @@ class PhpDebugSession extends vscode.DebugSession {
const stackFrameId = this._stackFrameIdCounter++
// save the connection this stackframe belongs to and the level of the stackframe under the stacktrace id
this._stackFrames.set(stackFrameId, stackFrame)
// prepare response for VS Code (column is always 1 since XDebug doesn't tell us the column)
// prepare response for VS Code (column is always 1 since Xdebug doesn't tell us the column)
return { id: stackFrameId, name: stackFrame.name, source, line, column: 1 }
}
),
Expand Down Expand Up @@ -791,7 +791,7 @@ class PhpDebugSession extends vscode.DebugSession {
const contexts = await stackFrame.getContexts()
scopes = contexts.map(context => {
const variableId = this._variableIdCounter++
// remember that this new variable ID is assigned to a SCOPE (in XDebug "context"), not a variable (in XDebug "property"),
// remember that this new variable ID is assigned to a SCOPE (in Xdebug "context"), not a variable (in Xdebug "property"),
// so when VS Code does a variablesRequest with that ID we do a context_get and not a property_get
this._contexts.set(variableId, context)
// send VS Code the variable ID as identifier
Expand Down Expand Up @@ -1002,7 +1002,7 @@ class PhpDebugSession extends vscode.DebugSession {
}

protected pauseRequest(response: VSCodeDebugProtocol.PauseResponse, args: VSCodeDebugProtocol.PauseArguments) {
this.sendErrorResponse(response, new Error('Pausing the execution is not supported by XDebug'))
this.sendErrorResponse(response, new Error('Pausing the execution is not supported by Xdebug'))
}

protected async disconnectRequest(
Expand Down
2 changes: 1 addition & 1 deletion src/test/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('PHP Debug Adapter', () => {
const scopes = (await client.scopesRequest({ frameId: stackFrame.id })).body.scopes
localScope = scopes.find(scope => scope.name === 'Locals')
superglobalsScope = scopes.find(scope => scope.name === 'Superglobals')
constantsScope = scopes.find(scope => scope.name === 'User defined constants') // XDebug >2.3 only
constantsScope = scopes.find(scope => scope.name === 'User defined constants') // Xdebug >2.3 only
})

it('should report scopes correctly', () => {
Expand Down
Loading

0 comments on commit c18654d

Please sign in to comment.