urust: fixed Step Over

This commit is contained in:
Steven Hugg committed 2026-11-03 12:22:03 +01:00
1 parent 29687d039b
commit 4779cdea41
4 files changed
+42 -11

No files matched your search

+2
View File
@@ -8,6 +8,8 @@ See [extension/CHANGELOG.md](extension/CHANGELOG.md).
### Builds and tools
- The IDE's Step Over button on urust programs ran one instruction at a time. urust's debug info has one entry per expression, so every instruction counted as a line start; step over now stops only where the source line changes.
- Git hooks in `.githooks/` run the type check before a commit (`npm run tslint`) and the test suite before a push (`npm test`). They print one line while working and only show output on failure, which aborts the commit/push. `make prepare`/`npm run hooks` installs them by pointing `core.hooksPath` at `.githooks`; bypass with `--no-verify`, `SKIP_PRECOMMIT=1`, or `SKIP_PREPUSH=1`. Tag-only and branch-deletion pushes don't run the tests.
- **CVBasic** builds BASIC programs for the Colecovision, MSX, SG-1000/SMS and NES. The WASI compiler turns `.bas` into gasm80 assembler, which the newly vendored gasm80 (also WASI) assembles into a cartridge ROM. Compiler and assembler diagnostics point at BASIC lines, and the gasm80 listing gives the debugger source line/address information. Colecovision, MSX, NES and SG-1000/SMS now send `.bas` to it, with presets, skeletons and a `cvbasic-fs.zip` package of its prologue/epilogue files.
+26
View File
@@ -242,3 +242,29 @@ export function mergeSegments(nativeSegs: Segment[], linkerSegs: Segment[]): Seg
segs.sort((a, b) => a.start - b.start);
return segs;
}
/**
* The set of PCs that begin a source line, for source-level step over.
* Compilers like urust emit one entry per expression, so one source line can
* have many entries at consecutive addresses. Only the first entry of each run
* (in address order) on the same file+line counts, or step over would stop
* after nearly every instruction.
*/
export function sourceLineStartPCs(listings: CodeListingMap): Set<number> {
var entries: SourceLine[] = [];
for (var lstfn in listings || {}) {
var sourcefile = listings[lstfn].sourcefile;
if (!sourcefile) continue;
for (var line of sourcefile.lines) {
if (line.offset >= 0) entries.push(line);
}
}
entries.sort((a, b) => a.offset - b.offset);
var pcs = new Set<number>();
var prev: SourceLine = null;
for (var e of entries) {
if (!prev || prev.line != e.line || prev.path != e.path) pcs.add(e.offset);
prev = e;
}
return pcs;
}
+2 -11
View File
@@ -18,6 +18,7 @@ import { getAppVersionLabel } from "../common/version";
import { PLATFORM_PARAMS } from "../worker/platforms";
import { hasErrors } from "../worker/listingutils";
import { CodeListingMap, FileData, WorkerError, WorkerResult, isErrorResult } from "../common/workertypes";
import { sourceLineStartPCs } from "../common/projectcore";
import { reportErrorToServer, reportInternalError } from "./errorreport";
import { importPlatform } from "../platform/_index";
import { alertError, alertInfo, fatalError, setWaitDialog } from "./dialogs";
@@ -1544,17 +1545,7 @@ var sourcePcsCache: { listings: CodeListingMap, pcs: Set<number> } = null;
function getSourceLineStartPCs(): Set<number> {
var listings = current_project.getListings();
if (!sourcePcsCache || sourcePcsCache.listings !== listings) {
var pcs = new Set<number>();
if (listings) {
for (var lstfn in listings) {
var sourcefile = listings[lstfn].sourcefile;
if (!sourcefile) continue;
for (var line of sourcefile.lines) {
if (line.offset >= 0) pcs.add(line.offset);
}
}
}
sourcePcsCache = { listings: listings, pcs: pcs };
sourcePcsCache = { listings: listings, pcs: sourceLineStartPCs(listings) };
}
return sourcePcsCache.pcs;
}
+12
View File
@@ -0,0 +1,12 @@
import assert from "assert";
import { describe, it } from "mocha";
import { processListings, sourceLineStartPCs } from "../../src/common/projectcore";
describe('sourceLineStartPCs', function () {
it('keeps one start PC per run of entries on the same line (urust emits one per expression)', function () {
const mk = (line: number, offset: number) => ({ line, offset, path: 'a.rs', iscode: true });
const listings: any = { 'a.rs': { lines: [mk(1, 0x800), mk(1, 0x803), mk(1, 0x806), mk(2, 0x809), mk(2, 0x80b), mk(1, 0x80d)] } };
processListings(listings);
assert.deepStrictEqual([...sourceLineStartPCs(listings)].sort(), [0x800, 0x809, 0x80d]);
});
});