Skip to content

Commit

Permalink
Avoid an infinite loop when stepping forward without next sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Nov 27, 2024
1 parent e0f16ee commit 0946e8f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/debug/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export class Session {
}
}
} else {
let ordersOfMagnitude = 0;
while (true) {
const followingTimePoint = this.timeCursor.offsetByFemtos(this._forwardTimeStep);
const response = await this.connection.queryInterval({
Expand All @@ -382,12 +383,15 @@ export class Session {
item_values_encoding: null,
diagnostics: false
});
if (response.samples.length === 1) {
this._forwardTimeStep = this._forwardTimeStep * 2n;
continue;
if (response.samples.length > 1) {
this.timeCursor = TimePoint.fromCXXRTL(response.samples.at(1)!.time);
break;
} else if (ordersOfMagnitude < 30 /* femto -> peta */) {
ordersOfMagnitude += 1;
this._forwardTimeStep = this._forwardTimeStep * 10n;
} else {
throw new RangeError('Could not find a sample to step forward to');
}
this.timeCursor = TimePoint.fromCXXRTL(response.samples.at(1)!.time);
break;
}
}
return this.timeCursor;
Expand Down

0 comments on commit 0946e8f

Please sign in to comment.