Skip to content

Commit 1f3b377

Browse files
authored
fix: remove current execution position when performing stop or continue dbgp operation. (#367)
1 parent 3564de4 commit 1f3b377

File tree

1 file changed

+56
-38
lines changed

1 file changed

+56
-38
lines changed

src/phpDebug.ts

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -894,88 +894,106 @@ class PhpDebugSession extends vscode.DebugSession {
894894
response: VSCodeDebugProtocol.ContinueResponse,
895895
args: VSCodeDebugProtocol.ContinueArguments
896896
) {
897-
let xdebugResponse: xdebug.StatusResponse | undefined
897+
let connection: xdebug.Connection | undefined
898898
try {
899-
const connection = this._connections.get(args.threadId)
899+
connection = this._connections.get(args.threadId)
900900
if (!connection) {
901-
throw new Error('Unknown thread ID ' + args.threadId)
901+
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
902+
}
903+
response.body = {
904+
allThreadsContinued: false,
902905
}
903-
xdebugResponse = await connection.sendRunCommand()
906+
this.sendResponse(response)
904907
} catch (error) {
905908
this.sendErrorResponse(response, error)
906-
if (xdebugResponse) {
907-
this._checkStatus(xdebugResponse)
908-
}
909909
return
910910
}
911-
response.body = {
912-
allThreadsContinued: false,
911+
try {
912+
const xdebugResponse = await connection.sendRunCommand()
913+
this._checkStatus(xdebugResponse)
914+
} catch (error) {
915+
this.sendEvent(
916+
new vscode.OutputEvent(
917+
'continueRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'
918+
),
919+
true
920+
)
913921
}
914-
this.sendResponse(response)
915-
this._checkStatus(xdebugResponse)
916922
}
917923

918924
protected async nextRequest(response: VSCodeDebugProtocol.NextResponse, args: VSCodeDebugProtocol.NextArguments) {
919-
let xdebugResponse: xdebug.StatusResponse | undefined
925+
let connection: xdebug.Connection | undefined
920926
try {
921-
const connection = this._connections.get(args.threadId)
927+
connection = this._connections.get(args.threadId)
922928
if (!connection) {
923-
throw new Error('Unknown thread ID ' + args.threadId)
929+
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
924930
}
925-
xdebugResponse = await connection.sendStepOverCommand()
931+
this.sendResponse(response)
926932
} catch (error) {
927933
this.sendErrorResponse(response, error)
928-
if (xdebugResponse) {
929-
this._checkStatus(xdebugResponse)
930-
}
931934
return
932935
}
933-
this.sendResponse(response)
934-
this._checkStatus(xdebugResponse)
936+
try {
937+
const xdebugResponse = await connection.sendStepOverCommand()
938+
this._checkStatus(xdebugResponse)
939+
} catch (error) {
940+
this.sendEvent(
941+
new vscode.OutputEvent('nextRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
942+
true
943+
)
944+
}
935945
}
936946

937947
protected async stepInRequest(
938948
response: VSCodeDebugProtocol.StepInResponse,
939949
args: VSCodeDebugProtocol.StepInArguments
940950
) {
941-
let xdebugResponse: xdebug.StatusResponse | undefined
951+
let connection: xdebug.Connection | undefined
942952
try {
943-
const connection = this._connections.get(args.threadId)
953+
connection = this._connections.get(args.threadId)
944954
if (!connection) {
945-
throw new Error('Unknown thread ID ' + args.threadId)
955+
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
946956
}
947-
xdebugResponse = await connection.sendStepIntoCommand()
957+
this.sendResponse(response)
948958
} catch (error) {
949959
this.sendErrorResponse(response, error)
950-
if (xdebugResponse) {
951-
this._checkStatus(xdebugResponse)
952-
}
953960
return
954961
}
955-
this.sendResponse(response)
956-
this._checkStatus(xdebugResponse)
962+
try {
963+
const xdebugResponse = await connection.sendStepIntoCommand()
964+
this._checkStatus(xdebugResponse)
965+
} catch (error) {
966+
this.sendEvent(
967+
new vscode.OutputEvent('stepInRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
968+
true
969+
)
970+
}
957971
}
958972

959973
protected async stepOutRequest(
960974
response: VSCodeDebugProtocol.StepOutResponse,
961975
args: VSCodeDebugProtocol.StepOutArguments
962976
) {
963-
let xdebugResponse: xdebug.StatusResponse | undefined
977+
let connection: xdebug.Connection | undefined
964978
try {
965-
const connection = this._connections.get(args.threadId)
979+
connection = this._connections.get(args.threadId)
966980
if (!connection) {
967-
throw new Error('Unknown thread ID ' + args.threadId)
981+
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
968982
}
969-
xdebugResponse = await connection.sendStepOutCommand()
983+
this.sendResponse(response)
970984
} catch (error) {
971985
this.sendErrorResponse(response, error)
972-
if (xdebugResponse) {
973-
this._checkStatus(xdebugResponse)
974-
}
975986
return
976987
}
977-
this.sendResponse(response)
978-
this._checkStatus(xdebugResponse)
988+
try {
989+
const xdebugResponse = await connection.sendStepOutCommand()
990+
this._checkStatus(xdebugResponse)
991+
} catch (error) {
992+
this.sendEvent(
993+
new vscode.OutputEvent('stepOutRequest thread ID ' + args.threadId + ' error: ' + error.message + '\n'),
994+
true
995+
)
996+
}
979997
}
980998

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

0 commit comments

Comments
 (0)