Skip to content

Commit

Permalink
Ensure terminated event is sent to client (eclipse-cdt-cloud#234)
Browse files Browse the repository at this point in the history
Consider that when no threads are running the inferior is not running.
This is needed so we don't suppress sending events to client
on async stopped events from gdb

Fixes eclipse-cdt-cloud#233

Also-by: Jonah Graham <[email protected]>
  • Loading branch information
noneghost authored Feb 4, 2023
1 parent 5da49a6 commit 4f6f0fa
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GDBDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ export class GDBDebugSession extends LoggingDebugSession {

protected handleGDBAsync(resultClass: string, resultData: any) {
const updateIsRunning = () => {
this.isRunning = true;
this.isRunning = this.threads.length ? true : false;
for (const thread of this.threads) {
if (!thread.running) {
this.isRunning = false;
Expand Down
67 changes: 67 additions & 0 deletions src/integration-tests/terminated.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*********************************************************************
* Copyright (c) 2023 Kichwa Coders Canada Inc. and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*********************************************************************/

// import { expect } from 'chai';
import * as path from 'path';
import { LaunchRequestArguments } from '../GDBDebugSession';
import { CdtDebugClient } from './debugClient';
import {
fillDefaults,
getScopes,
standardBeforeEach,
testProgramsDir,
} from './utils';

describe('terminated', function () {
let dc: CdtDebugClient;
const emptyProgram = path.join(testProgramsDir, 'empty');
const emptySrc = path.join(testProgramsDir, 'empty.c');

beforeEach(async function () {
dc = await standardBeforeEach();
});

afterEach(async function () {
await dc.stop();
});

it('terminated event arrives after continuing after a breakpoint', async function () {
await dc.hitBreakpoint(
fillDefaults(this.test, {
program: emptyProgram,
} as LaunchRequestArguments),
{
path: emptySrc,
line: 3,
}
);

await Promise.all([
dc.waitForEvent('terminated'),
dc.continueRequest({ threadId: (await getScopes(dc)).thread.id }),
]);
});

it('terminated event arrives on a short run', async function () {
await Promise.all([
dc.waitForEvent('terminated'),

dc
.waitForEvent('initialized')
.then((_event) => dc.configurationDoneRequest()),

dc.launch(
fillDefaults(this.test, {
program: emptyProgram,
} as LaunchRequestArguments)
),
]);
});
});

0 comments on commit 4f6f0fa

Please sign in to comment.