Skip to content

Commit

Permalink
fix: remove current execution position when performing stop or contin…
Browse files Browse the repository at this point in the history
…ue dbgp operation. (#367)
  • Loading branch information
zobo authored Feb 2, 2021
1 parent 3564de4 commit 1f3b377
Showing 1 changed file with 56 additions and 38 deletions.
94 changes: 56 additions & 38 deletions src/phpDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,88 +894,106 @@ class PhpDebugSession extends vscode.DebugSession {
response: VSCodeDebugProtocol.ContinueResponse,
args: VSCodeDebugProtocol.ContinueArguments
) {
let xdebugResponse: xdebug.StatusResponse | undefined
let connection: xdebug.Connection | undefined
try {
const connection = this._connections.get(args.threadId)
connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
response.body = {
allThreadsContinued: false,
}
xdebugResponse = await connection.sendRunCommand()
this.sendResponse(response)
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
response.body = {
allThreadsContinued: false,
try {
const xdebugResponse = await connection.sendRunCommand()
this._checkStatus(xdebugResponse)
} catch (error) {
this.sendEvent(
new vscode.OutputEvent(
'continueRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'
),
true
)
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
}

protected async nextRequest(response: VSCodeDebugProtocol.NextResponse, args: VSCodeDebugProtocol.NextArguments) {
let xdebugResponse: xdebug.StatusResponse | undefined
let connection: xdebug.Connection | undefined
try {
const connection = this._connections.get(args.threadId)
connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
xdebugResponse = await connection.sendStepOverCommand()
this.sendResponse(response)
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
try {
const xdebugResponse = await connection.sendStepOverCommand()
this._checkStatus(xdebugResponse)
} catch (error) {
this.sendEvent(
new vscode.OutputEvent('nextRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
true
)
}
}

protected async stepInRequest(
response: VSCodeDebugProtocol.StepInResponse,
args: VSCodeDebugProtocol.StepInArguments
) {
let xdebugResponse: xdebug.StatusResponse | undefined
let connection: xdebug.Connection | undefined
try {
const connection = this._connections.get(args.threadId)
connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
xdebugResponse = await connection.sendStepIntoCommand()
this.sendResponse(response)
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
try {
const xdebugResponse = await connection.sendStepIntoCommand()
this._checkStatus(xdebugResponse)
} catch (error) {
this.sendEvent(
new vscode.OutputEvent('stepInRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
true
)
}
}

protected async stepOutRequest(
response: VSCodeDebugProtocol.StepOutResponse,
args: VSCodeDebugProtocol.StepOutArguments
) {
let xdebugResponse: xdebug.StatusResponse | undefined
let connection: xdebug.Connection | undefined
try {
const connection = this._connections.get(args.threadId)
connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
xdebugResponse = await connection.sendStepOutCommand()
this.sendResponse(response)
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
try {
const xdebugResponse = await connection.sendStepOutCommand()
this._checkStatus(xdebugResponse)
} catch (error) {
this.sendEvent(
new vscode.OutputEvent('stepOutRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
true
)
}
}

protected pauseRequest(response: VSCodeDebugProtocol.PauseResponse, args: VSCodeDebugProtocol.PauseArguments) {
Expand Down

0 comments on commit 1f3b377

Please sign in to comment.