Skip to content

Commit

Permalink
Fewer assumptions about how many steps we need
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Nov 2, 2023
1 parent 8e3dcd5 commit a78a7dc
Showing 1 changed file with 27 additions and 57 deletions.
84 changes: 27 additions & 57 deletions src/integration-tests/stepping-granularity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ interface StackStateCheck {
line: number;
}

describe('Stepping', async function () {
describe('Stepping', async function() {
let dc: CdtDebugClient;
const steppingProgram = path.join(testProgramsDir, 'stepping');
const steppingSource = path.join(testProgramsDir, 'stepping.c');

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

await dc.hitBreakpoint(
Expand Down Expand Up @@ -98,7 +98,8 @@ describe('Stepping', async function () {
it('steps in by instruction', async () => {
const threads = await dc.threadsRequest();
const threadId = threads.body.threads[0].id;
expectStackState(await getFrameState(threadId), {
let state = await getFrameState(threadId);
expectStackState(state, {
elsewhereDefined: false,
line: 8,
});
Expand All @@ -107,24 +108,20 @@ describe('Stepping', async function () {
dc.waitForEvent('stopped'),
]);
// First step should not take us straight to the function.
expectStackState(await getFrameState(threadId), {
expectStackState(state = await getFrameState(threadId), {
elsewhereDefined: false,
line: 8,
});
// Step several times to get into the function.
await Promise.all([
dc.stepInRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
await Promise.all([
dc.stepInRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
await Promise.all([
dc.stepInRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
// Step until we leave that line.
while (state.main?.line === 8 && !state.elsewhere) {
await Promise.all([
dc.stepInRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
state = await getFrameState(threadId);
}
// First line we see should be inside `getFromElsewhere`
expectStackState(state, {
elsewhereDefined: true,
line: 14,
});
Expand Down Expand Up @@ -158,48 +155,21 @@ describe('Stepping', async function () {
it('steps next by instruction and skips a function', async () => {
const threads = await dc.threadsRequest();
const threadId = threads.body.threads[0].id;
expectStackState(await getFrameState(threadId), {
elsewhereDefined: false,
line: 8,
});
// Step several times to prove that we go straight from 8 to 9.
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
elsewhereDefined: false,
line: 8,
});
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
elsewhereDefined: false,
line: 8,
});
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
let state = await getFrameState(threadId);
expectStackState(state, {
elsewhereDefined: false,
line: 8,
});
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
elsewhereDefined: false,
line: 8,
});
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
expectStackState(await getFrameState(threadId), {
// Step until we get off line 8.
while (state.main?.line === 8 && !state.elsewhere) {
await Promise.all([
dc.nextRequest({ threadId, granularity: 'instruction' }),
dc.waitForEvent('stopped'),
]);
state = await getFrameState(threadId);
}
// The first line we should see after 8 is nine, not something in `getFromElsewhere`.
expectStackState(state, {
elsewhereDefined: false,
line: 9,
});
Expand Down

0 comments on commit a78a7dc

Please sign in to comment.