@henols/c64-re-tools 2.6.0-rc.9 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +3 -3
- package/skills/c64-assembler/scripts/assembler.ts +4 -3
- package/skills/c64-development/SKILL.md +3 -3
- package/skills/c64-docs/SKILL.md +5 -3
- package/skills/c64-docs/scripts/docs.ts +17 -4
- package/skills/c64-docs/scripts/lib/reference.ts +117 -31
- package/skills/c64-docs/scripts/lib/source-map.ts +14 -0
- package/skills/c64-knowledge/SKILL.md +8 -7
- package/skills/c64-knowledge/scripts/knowledge.ts +16 -9
- package/skills/c64-reverse-engineering/SKILL.md +9 -3
- package/skills/c64-source/SKILL.md +11 -8
- package/skills/c64-source/scripts/lib/export.ts +13 -2
- package/skills/c64-source/scripts/lib/loader.ts +51 -28
- package/skills/c64-source/scripts/lib/source.ts +24 -17
- package/skills/c64-source/scripts/source.ts +51 -36
- package/skills/c64-static-analysis/SKILL.md +23 -21
- package/skills/c64-static-analysis/scripts/lib/findings.ts +11 -11
- package/skills/c64-static-analysis/scripts/lib/instructions.ts +4 -4
- package/skills/c64-static-analysis/scripts/lib/macros.ts +3 -1
- package/skills/c64-static-analysis/scripts/static-analysis.ts +36 -27
- package/skills/c64-testing/SKILL.md +10 -3
- package/skills/c64-testing/references/recording-format.md +8 -2
- package/skills/c64-testing/references/scenario-format.md +4 -2
- package/skills/c64-testing/scripts/lib/recording.ts +193 -28
- package/skills/c64-testing/scripts/lib/replay.ts +31 -5
- package/skills/c64-testing/scripts/lib/runs.ts +7 -2
- package/skills/c64-testing/scripts/lib/scenario.ts +3 -3
- package/skills/c64-testing/scripts/testing.ts +23 -2
- package/skills/c64-unpacker/SKILL.md +4 -2
- package/skills/c64-unpacker/scripts/lib/stages.ts +18 -3
- package/skills/c64-unpacker/scripts/unpacker.ts +38 -6
- package/src/build-name.ts +9 -4
- package/src/c64.ts +1 -1
- package/src/host/main.ts +2 -2
- package/src/host/server.ts +3 -1
- package/src/host/tools/index.ts +1 -1
- package/src/host/vice/process.ts +34 -17
- package/src/host/vice/session.ts +55 -27
- package/src/host-client/steps.ts +4 -1
- package/src/host-client/tools.ts +1 -1
- package/src/knowledge/evidence.ts +66 -0
- package/src/knowledge/history.ts +5 -5
- package/src/knowledge/import.ts +12 -5
- package/src/knowledge/program.ts +81 -33
- package/src/knowledge/read.ts +3 -3
- package/src/knowledge/schema.ts +7 -7
- package/src/knowledge/start-screen.ts +2 -0
- package/src/knowledge/text.ts +28 -3
- package/src/knowledge/write.ts +6 -6
- package/src/mcp/tools/debug.ts +23 -21
- package/src/mcp/tools/memory.ts +12 -9
- package/src/native/c64run.ts +7 -4
- package/src/native/{ghidra → decompiler}/analyze.ts +17 -17
- package/src/native/{ghidra → decompiler}/language/c64rt_6510.slaspec +1 -1
- package/src/native/{ghidra → decompiler}/walk.ts +6 -6
- package/src/native/types.ts +25 -25
- package/src/opcodes.ts +1 -1
- package/src/reference-pages.ts +64 -0
- package/src/script.ts +1 -1
- package/tools/c64run.c +150 -4
- /package/src/native/{ghidra → decompiler}/c64rt-wasm.ts +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.cspec +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.ldefs +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.pspec +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.sla +0 -0
- /package/src/native/{ghidra → decompiler}/pcode.ts +0 -0
- /package/src/native/{ghidra → decompiler}/wasm.ts +0 -0
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ To get the command list, run the script with no arguments.
|
|
|
28
28
|
| Build a source that includes a file that you generated into a folder next to the source root | `build src boot.asm --out build/boot.prg --include ../build` |
|
|
29
29
|
| Build a source that sets no start address | `build src main.a --out build/game.prg --set-pc '$0801'` |
|
|
30
30
|
| Build a generated source with the values of `config.asm` | `build src main.asm` |
|
|
31
|
-
| Build the loader of a generated source | `build src loader.asm` |
|
|
31
|
+
| Build the loader of a generated source. For the packed form, this is only the copier. | `build src loader.asm` |
|
|
32
32
|
| Check that the rebuild is identical to the program in the project knowledge | `build src main.asm --compare` |
|
|
33
33
|
| Build a release and check it against the bytes of that release | `build src main.asm --release ORIGINAL --compare` |
|
|
34
34
|
| Check the rebuild of a program in another space, for example the drive | `build src main.asm --out build/drive.prg --compare --space drive8` |
|
|
@@ -68,7 +68,7 @@ Without `--out`, the name of the program tells what the build is:
|
|
|
68
68
|
| A value of `config.asm` is not its default | `custom_<switches>.prg`, for example `custom_trainer.prg`. A switch that is off has `no_` before its name, for example `custom_no_start_screen.prg`. |
|
|
69
69
|
| A source without `config.asm` | the name of the entry, for example `main.prg` |
|
|
70
70
|
|
|
71
|
-
An entry other than `main.asm` adds its name, for example `clean_loader.prg` for `loader.asm`. With `--plain`, the extension is `.bin`. Do not give `--out` for a build of a generated source. Then the name always tells the build.
|
|
71
|
+
An entry other than `main.asm` adds its name, for example `clean_loader.prg` for `loader.asm`. The `loader.asm` of the packed form holds only the copier, so its build is `clean_copier.prg`. The packed loader program `clean_loader.prg` of the generated source stays. With `--plain`, the extension is `.bin`. Do not give `--out` for a build of a generated source. Then the name always tells the build.
|
|
72
72
|
|
|
73
73
|
### Paths and the project folder
|
|
74
74
|
|
|
@@ -136,7 +136,7 @@ Assembles the source and writes the program to `--out`, or to `build/<name>.prg`
|
|
|
136
136
|
|
|
137
137
|
Do as the result tells:
|
|
138
138
|
|
|
139
|
-
- `result` is `PASS`: the program is at `out`. To run or debug the program, load the file at `out` into the emulator.
|
|
139
|
+
- `result` is `PASS`: the program is at `out`. To run or debug the program, load the file at `out` into the emulator. A generated source with a loader is different: the build of `main.asm` does not set the entry state, and it can hold bytes for $d000-$dfff. Load the loader program in its place.
|
|
140
140
|
- `result` is `FAIL` and `assembled` is `false`: the source has errors, and the script wrote no program. `hint` tells you to correct the source. Correct the source at the file and the line of each diagnostic. Then run `build` again.
|
|
141
141
|
- `result` is `FAIL` and `assembled` is `true`: the program is not identical to the reference. The script wrote the program. Read the first difference of each segment in `compare.segments`. Without `--release`, read the section "Switches" first.
|
|
142
142
|
- `hint` tells that `symbols` is cut: give a larger `--max-listed`, or read the symbols file for the full list.
|
|
@@ -84,12 +84,13 @@ await runScript({
|
|
|
84
84
|
}
|
|
85
85
|
const setPc = call.address("set-pc");
|
|
86
86
|
const { contents, ...tree } = readSourceTree(sourceRoot, call.strings("include"));
|
|
87
|
-
|
|
87
|
+
const inSource = (name: string) => tree.files.findIndex((file) => file.path === (tree.sourceDir === "" ? name : `${tree.sourceDir}/${name}`));
|
|
88
|
+
if (inSource(entry) < 0) throw new Refusal("not-found", `${entry} is not a file in ${sourceRoot}. Give the main source file relative to the source root.`);
|
|
88
89
|
// The name of the build tells what it is: the release, or the switch values of config.asm.
|
|
89
|
-
const config =
|
|
90
|
+
const config = inSource(CONFIG_FILE);
|
|
90
91
|
const kind: BuildKind | undefined = label !== undefined ? { release: label } : config < 0 ? undefined : { values: configValues(contents[config]!.toString("utf8")), defaults: switchDefaults(call.space) };
|
|
91
92
|
const plain = call.flag("plain");
|
|
92
|
-
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind)}.${plain ? "bin" : "prg"}`;
|
|
93
|
+
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind, contents[inSource(entry)]!.toString("utf8"))}.${plain ? "bin" : "prg"}`;
|
|
93
94
|
const params: AcmeParams = { ...tree, entrySource: entry, defines: { ...releaseDefine, ...Object.fromEntries(call.strings("define").map(parseDefine)) }, ...(setPc === undefined ? {} : { setPc }) };
|
|
94
95
|
|
|
95
96
|
const { result, attachments } = await assemble(params, contents, localToolContext());
|
|
@@ -109,9 +109,9 @@ A rebuilt program gets its source from the project knowledge. A change is a swit
|
|
|
109
109
|
- Build the base release and compare it with the original. This build must be identical to the original.
|
|
110
110
|
- Build the default build.
|
|
111
111
|
- When the default build does not have the switch, set the switch to 1 in `src/config.asm`. Then build the default build. After the test, set the value back to the default if the user did not ask for the change.
|
|
112
|
-
8. Test the
|
|
113
|
-
-
|
|
114
|
-
-
|
|
112
|
+
8. Test the builds:
|
|
113
|
+
- When the behavior must stay the same as the original, replay each recording on the default build. For a source with a loader, this is `build/clean_loader.prg`, else `build/clean.prg`. Do not replay a build with a switch that is not at its default. Run a test scenario in `tests/` only when no recording executes the changed code.
|
|
114
|
+
- On the build that has the switch, run a run file with `expect` steps that show the feature or the fix.
|
|
115
115
|
|
|
116
116
|
### The answer
|
|
117
117
|
|
package/skills/c64-docs/SKILL.md
CHANGED
|
@@ -112,12 +112,12 @@ Writes the reference pages from the project knowledge, the source map and the pr
|
|
|
112
112
|
The reference has these pages:
|
|
113
113
|
|
|
114
114
|
- `index.md`: each file of the source, with its range, its title, the count of routines and the count of names.
|
|
115
|
-
- `modules/<file>.md`: a
|
|
115
|
+
- `modules/<file>.md`: first a table of the routines of the file. Each row has the callers and the first sentence of the comment. Then the data regions with their readers and writers, and a call graph. Then an entry for each routine and each data name. An entry has the comment, the callers and the table that holds the name. For a routine, it also has the calls, the jumps, the reads and the writes. A label that only code of its own file goes to is a row in a table under its routine.
|
|
116
116
|
- `tables.md`: each table of addresses, jumps and words, entry by entry, with its target. An RTS table holds each target minus 1. The page gives the target.
|
|
117
|
-
- `memory-map.md`: each region in address order. Then each variable outside the program, with its comment and the routines that read it and write it.
|
|
117
|
+
- `memory-map.md`: each region in address order. Then each variable outside the program, with its comment and the routines that read it and write it. A platform name, for example a chip register, has a routine only where the source line uses that name. `(indexed)` after a routine tells that the line adds X or Y to the address. That access can also go to the addresses after it, which can have no row.
|
|
118
118
|
- `graphics.md`: each `sprite`, `bitmap`, `charset` and `screen` region. The project knowledge has no graphics mode. Thus a sprite, a bitmap or a charset shows in hires and in multicolour. A charset shows 16 characters in each row. A screen shows as text.
|
|
119
119
|
|
|
120
|
-
In a call graph, a solid arrow is a call, a thick arrow is a table entry
|
|
120
|
+
In a call graph, a solid arrow is a call, and a thick arrow is a table entry. The graph does not show the jumps. A table entry goes from each routine that reads the table to each target in code. A table of data addresses gives no arrow.
|
|
121
121
|
|
|
122
122
|
Errors and their actions:
|
|
123
123
|
|
|
@@ -176,12 +176,14 @@ In a group folder, a label names the project of a name. Write the label and a co
|
|
|
176
176
|
- `linked`: `links`, the count of the links that it wrote, and `pages`, the pages that it changed. With `--check`, `notUpToDate` has the same fields for the links that are not up to date.
|
|
177
177
|
- `problems`: `byKind`, `count`, `listed` and `rest`. Each item has `at` (the page and the line), `kind` and `message`. In a group folder, each item also has `project`: the label of the project of the page, or `shared`.
|
|
178
178
|
- `group`: only in a group folder. `folder` is the group folder, relative to the folder of the pages. `projects` holds the labels.
|
|
179
|
+
- `evidence`: only when the project knowledge gives a file as evidence and the file is missing or changed. `count`, `listed` and `rest`. Each item has the `file`, its `state` (`missing` or `changed`) and the `revisions` that give the file. The project knowledge keeps the SHA-256 of each file of its evidence. An evidence item does not make `result` a FAIL.
|
|
179
180
|
|
|
180
181
|
`hint` and `nextAction`:
|
|
181
182
|
|
|
182
183
|
- A page has a problem: `hint` tells you to correct each problem. `nextAction` runs the same `link` command again.
|
|
183
184
|
- With `--check`, a link is not up to date and no page has a problem: `nextAction` runs `link` without `--check` to write the links.
|
|
184
185
|
- `reference` is `none`: no `reference` folder is in or beside the given pages. Give `--reference <dir>`, or run `generate` first.
|
|
186
|
+
- `evidence` has items: for a coverage map that changed, put the map into the project knowledge again. For a file that you did not change on purpose, restore it from git. Else examine the facts of the revisions against the new file. Give the new file as evidence of the next write of these facts.
|
|
185
187
|
|
|
186
188
|
Do this for each `kind` of problem:
|
|
187
189
|
|
|
@@ -13,12 +13,14 @@ import { WireFailure } from "#src/host-client/tools.ts";
|
|
|
13
13
|
import { writeProjectFile, writeReported } from "#src/host-client/transfer.ts";
|
|
14
14
|
import { conflicts } from "#src/knowledge/conflicts.ts";
|
|
15
15
|
import { openForRead } from "#src/knowledge/database.ts";
|
|
16
|
+
import { changedEvidence, type EvidenceChange } from "#src/knowledge/evidence.ts";
|
|
16
17
|
import { programImage, type ProgramImage } from "#src/knowledge/program.ts";
|
|
17
18
|
import { listComments, listModules, listReferences, listRegions, listSymbols, sourceRevision } from "#src/knowledge/read.ts";
|
|
18
19
|
import { groupOf, namedGroup, projectRoot, resolveProjectFile, resolveProjectPath, type ProjectGroup } from "#src/project.ts";
|
|
20
|
+
import { GENERATED_MARK, referenceStamp } from "#src/reference-pages.ts";
|
|
19
21
|
import { listed, OPTIONS, reply, runScript, UsageError, type Call, type Reply } from "#src/script.ts";
|
|
20
22
|
import { checkLinks, linkPage, type Files, type LinkContext, type Names, type Problem } from "./lib/links.ts";
|
|
21
|
-
import { buildReference
|
|
23
|
+
import { buildReference } from "./lib/reference.ts";
|
|
22
24
|
import { readSourceMap } from "./lib/source-map.ts";
|
|
23
25
|
|
|
24
26
|
// ---------------------------------------------------------------------------
|
|
@@ -247,6 +249,8 @@ function link(call: Call): Reply {
|
|
|
247
249
|
const reference = checkedReference !== undefined ? checkedReference : foundReference === undefined ? undefined : foundReference.slice(memberOf(foundReference)!.prefix.length).replace(/^\//, "");
|
|
248
250
|
const referenceOf = (member: Member) => (reference === undefined ? undefined : posix.join(member.prefix, reference));
|
|
249
251
|
const problems: Problem[] = [];
|
|
252
|
+
/** The evidence files of the knowledge of each read project that are missing or changed, with paths relative to the root of the run. */
|
|
253
|
+
const evidence: EvidenceChange[] = [];
|
|
250
254
|
|
|
251
255
|
/** The names of a project, read the first time a page needs them. A project with given pages is read before the pages. */
|
|
252
256
|
const loaded = new Map<Member, Names>();
|
|
@@ -268,6 +272,7 @@ function link(call: Call): Reply {
|
|
|
268
272
|
try {
|
|
269
273
|
revision = sourceRevision(db, map.space);
|
|
270
274
|
symbols = listSymbols(db, undefined, undefined, undefined, map.space);
|
|
275
|
+
for (const change of changedEvidence(db, member.root)) evidence.push({ ...change, file: inProject(change.file) });
|
|
271
276
|
} finally {
|
|
272
277
|
db?.close();
|
|
273
278
|
}
|
|
@@ -319,9 +324,9 @@ function link(call: Call): Reply {
|
|
|
319
324
|
problems.push(unreadable(page));
|
|
320
325
|
continue;
|
|
321
326
|
}
|
|
322
|
-
const stamp =
|
|
323
|
-
if (
|
|
324
|
-
problems.push({ page, line: 1, kind: "stale-reference", message: `${shown(page)} is from knowledge revision ${stamp
|
|
327
|
+
const stamp = referenceStamp(text);
|
|
328
|
+
if (stamp !== undefined && stamp.revision !== map.revision) {
|
|
329
|
+
problems.push({ page, line: 1, kind: "stale-reference", message: `${shown(page)} is from knowledge revision ${stamp.revision}, and the source${of} from ${map.revision}. Run docs.ts generate again.` });
|
|
325
330
|
}
|
|
326
331
|
}
|
|
327
332
|
const names: Names = {
|
|
@@ -395,11 +400,19 @@ function link(call: Call): Reply {
|
|
|
395
400
|
...(check ? { notUpToDate: { links, pages: changedPages } } : { linked: { links, pages: changedPages } }),
|
|
396
401
|
problems: { byKind, ...shownProblems },
|
|
397
402
|
};
|
|
403
|
+
const shownEvidence = listed(evidence, call.count("max-listed")!, (change) => ({ ...change, file: shown(change.file) }));
|
|
404
|
+
if (evidence.length > 0) output.evidence = shownEvidence;
|
|
398
405
|
const again = (withCheck: boolean) =>
|
|
399
406
|
call.next("link", ...call.subjects, "--source", call.string("source")!, ...(givenReference === undefined ? [] : ["--reference", givenReference]), ...(withCheck ? ["--check"] : []), ...(scope.unnamed ? ["--project", root] : []));
|
|
400
407
|
const hints: string[] = [];
|
|
401
408
|
let nextAction: string | undefined;
|
|
402
409
|
if (reference === undefined) hints.push("No reference/ folder is in or beside the given pages, so the links to the reference are not checked. Give --reference <dir>, or run generate first.");
|
|
410
|
+
if (evidence.length > 0) {
|
|
411
|
+
hints.push(
|
|
412
|
+
"The project knowledge gives the files in evidence as evidence, and each file is missing or changed since the revisions in its item. For a coverage map that changed, put the map into the project knowledge again. For a file that you did not change on purpose, restore it from git. Else examine the facts of the revisions against the new file, and give the new file as evidence of the next write of these facts.",
|
|
413
|
+
);
|
|
414
|
+
if (shownEvidence.rest !== undefined) hints.push(`evidence is cut. To list all files, give ${shownEvidence.rest}.`);
|
|
415
|
+
}
|
|
403
416
|
if (problems.length > 0) {
|
|
404
417
|
hints.push("Correct each problem in problems.listed as its message tells. Then run nextAction.");
|
|
405
418
|
if (shownProblems.rest !== undefined) hints.push(`problems is cut. To list all problems, give ${shownProblems.rest}.`);
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
import { posix } from "node:path";
|
|
7
7
|
|
|
8
8
|
import { formatC64Address, POINTER_TABLE_TYPES, pointerTableEntries, type PointerTableType } from "#src/c64.ts";
|
|
9
|
+
import { IO_RAM } from "#src/host-client/coverage.ts";
|
|
9
10
|
import { bitmapFrame, charsetFrame, encodePng, PATTERN_PALETTES, scaleFrame, screenText, spriteSheet, type GraphicsMode } from "#src/graphics.ts";
|
|
10
11
|
import { mermaidGraph, ownerOf, routineEdges, routineHeads, type GraphReference, type RoutineHead } from "#src/knowledge/graph.ts";
|
|
11
12
|
import type { CommentRow, ModuleRow, ReferenceRow, RegionRow, SymbolRow } from "#src/knowledge/read.ts";
|
|
12
13
|
import type { RegionType } from "#src/knowledge/schema.ts";
|
|
14
|
+
import { platformNames } from "#src/platform.ts";
|
|
15
|
+
import { referenceHeader } from "#src/reference-pages.ts";
|
|
13
16
|
import type { SourceMap } from "./source-map.ts";
|
|
14
17
|
|
|
15
|
-
/** The first line of every generated page. A page without it is a page of a person, and docs.ts generate never writes over it. */
|
|
16
|
-
export const GENERATED_MARK = "<!-- Generated by c64-docs";
|
|
17
|
-
|
|
18
18
|
export interface ReferenceInput {
|
|
19
19
|
/** The reference directory, relative to the project folder. */
|
|
20
20
|
out: string;
|
|
@@ -40,11 +40,15 @@ const TABLE_TYPES: readonly RegionType[] = [...POINTER_TABLE_TYPES, "jumps", "wo
|
|
|
40
40
|
const GRAPHICS_TYPES: readonly RegionType[] = ["sprite", "bitmap", "charset", "screen"];
|
|
41
41
|
/** A list longer than this ends with the number of the rest. */
|
|
42
42
|
const MAX_LISTED = 40;
|
|
43
|
+
/** A list of one entry of a module page is shorter: the reader scans it. */
|
|
44
|
+
const MAX_FACTS = 12;
|
|
43
45
|
/** A call graph with more edges is not readable: then it shows the calls only, and at most this many. */
|
|
44
|
-
const MAX_EDGES =
|
|
46
|
+
const MAX_EDGES = 30;
|
|
45
47
|
/** A name outside the image covers the addresses that references use up to the next name, at most this many. */
|
|
46
48
|
const MAX_SPAN = 256;
|
|
47
|
-
/**
|
|
49
|
+
/** A source line that uses an ACME macro: +name, after a label or not. An anonymous label (+ alone) is no use. */
|
|
50
|
+
const MACRO_USE = /^\s*(?:[\w.]+\s+)?\+[A-Za-z_]/;
|
|
51
|
+
/** The kinds of a reference that reads a table: the decompiler gives an indexed read (lda table,x) as "reference". */
|
|
48
52
|
const TABLE_READS: readonly string[] = ["read", "reference", "pointer"];
|
|
49
53
|
|
|
50
54
|
const hex = (address: number) => formatC64Address(address).toUpperCase();
|
|
@@ -72,6 +76,8 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
72
76
|
const entries = new Map<string, Entry>();
|
|
73
77
|
const sortedNames = [...new Set([...input.symbols.map((symbol) => symbol.address), ...map.labels.filter((label) => label.file === "constants.asm").map((label) => label.address)])].sort((a, b) => a - b);
|
|
74
78
|
const nextName = (address: number) => sortedNames.find((other) => other > address);
|
|
79
|
+
/** A name of the platform covers only its register or area: RANDOM is $D41B, not the color RAM after it. */
|
|
80
|
+
const platformEnd = new Map(platformNames().map((entry) => [entry.name, entry.end]));
|
|
75
81
|
const regionAt = (address: number) => input.regions.find((region) => region.start <= address && region.end >= address);
|
|
76
82
|
const spanOf = (address: number, kind: string) => {
|
|
77
83
|
if (kind === "routine" || kind === "label") return address;
|
|
@@ -89,7 +95,8 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
89
95
|
// A name that c64-source makes (l_xxxx) is no entry: it has no meaning of its own.
|
|
90
96
|
if (symbol === undefined && label.file !== "constants.asm") continue;
|
|
91
97
|
const kind = symbol?.kind ?? "platform";
|
|
92
|
-
|
|
98
|
+
const platform = symbol === undefined ? platformEnd.get(label.name) : undefined;
|
|
99
|
+
entries.set(label.name, { name: label.name, address: label.address, kind, page: pageOfFile(label.file), spanEnd: platform ?? spanOf(label.address, kind) });
|
|
93
100
|
}
|
|
94
101
|
const entryAt = new Map<number, Entry>();
|
|
95
102
|
for (const entry of entries.values()) if (!entryAt.has(entry.address)) entryAt.set(entry.address, entry);
|
|
@@ -132,14 +139,52 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
132
139
|
const shown = named.base === address ? named.name : `${named.name}+${address - named.base}`;
|
|
133
140
|
return entries.has(named.name) ? entryOfName(page, named.name, shown) : codeOfName(page, named.name).replace(`\`${named.name}\``, `\`${shown}\``);
|
|
134
141
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
/** An address as the name that holds it, without the offset: a list names actor_queue once, not actor_queue+3 and actor_queue+6. */
|
|
143
|
+
const baseTarget = (page: string, address: number) => {
|
|
144
|
+
const named = nameFor(address);
|
|
145
|
+
if (named === undefined) return codeOfAddress(page, address);
|
|
146
|
+
return entries.has(named.name) ? entryOfName(page, named.name, named.name) : codeOfName(page, named.name);
|
|
147
|
+
};
|
|
148
|
+
const capped = (items: string[], limit = MAX_LISTED) => (items.length <= limit ? items.join(", ") : `${items.slice(0, limit).join(", ")} and ${items.length - limit} more`);
|
|
149
|
+
/**
|
|
150
|
+
* The references that use the data at their target. An access to the I/O area inside the image is the
|
|
151
|
+
* register, as the source writes it: it uses no data of the RAM under it, unless the knowledge names that
|
|
152
|
+
* address. So the code of the SID and the CIAs is no reader of the sprites in RAM at $d400 or $dc00.
|
|
153
|
+
*/
|
|
154
|
+
const named = new Set(input.symbols.map((symbol) => symbol.address));
|
|
155
|
+
const dataReferences = input.references.filter((reference) => !(reference.to >= IO_RAM.start && reference.to <= IO_RAM.end && input.image?.inImage(reference.to) === true && !named.has(reference.to)));
|
|
156
|
+
/**
|
|
157
|
+
* How the source line of a reference uses a platform name, as the source writes it: "named", "indexed"
|
|
158
|
+
* (name,x or name,y: the index can reach the registers after it), or undefined when the line does not
|
|
159
|
+
* name it, for example lda $d000,x with the character ROM in. "named" when the source text is not there,
|
|
160
|
+
* and for a macro use (+name): each byte of the macro maps to that line, which does not show its body.
|
|
161
|
+
*/
|
|
162
|
+
const platformUse = (reference: ReferenceRow, use: RegExp): "named" | "indexed" | undefined => {
|
|
163
|
+
const line = map.lineOf(reference.from);
|
|
164
|
+
const text = line === undefined ? undefined : map.textOf?.(line);
|
|
165
|
+
if (text === undefined || MACRO_USE.test(text)) return "named";
|
|
166
|
+
const found = use.exec(text);
|
|
167
|
+
return found === null ? undefined : found[1] === undefined ? "named" : "indexed";
|
|
168
|
+
};
|
|
169
|
+
/** The routines that read or write a range, each once and linked to its entry. `platform` is the platform name of the range. */
|
|
170
|
+
const ownersOf = (page: string, start: number, end: number, kind: string, platform?: string) => {
|
|
171
|
+
const use = platform === undefined ? undefined : new RegExp(`(?<![\\w.])${platform}(?!\\w)([^,)]*,\\s*[xXyY]\\b)?`);
|
|
172
|
+
// A routine with an indexed use and a direct use shows once, as indexed.
|
|
173
|
+
const owners = new Map<string, boolean>();
|
|
174
|
+
for (const reference of dataReferences) {
|
|
175
|
+
if (reference.kind !== kind || reference.to < start || reference.to > end) continue;
|
|
176
|
+
const how = use === undefined ? "named" : platformUse(reference, use);
|
|
177
|
+
if (how === undefined) continue;
|
|
178
|
+
const name = ownerAt(reference.from)?.name ?? hex(reference.from);
|
|
179
|
+
owners.set(name, (owners.get(name) ?? false) || how === "indexed");
|
|
180
|
+
}
|
|
181
|
+
return capped(
|
|
182
|
+
[...owners].map(([name, indexed]) => {
|
|
183
|
+
const shown = entries.has(name) ? entryOfName(page, name, name) : `\`${name}\``;
|
|
184
|
+
return indexed ? `${shown} (indexed)` : shown;
|
|
185
|
+
}),
|
|
142
186
|
);
|
|
187
|
+
};
|
|
143
188
|
|
|
144
189
|
// --- The routine graph ----------------------------------------------------
|
|
145
190
|
const tableReferences: GraphReference[] = [];
|
|
@@ -182,6 +227,12 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
182
227
|
return named === undefined ? codeOfAddress(page, from) : `${named} ${codeOfAddress(page, from)}`;
|
|
183
228
|
};
|
|
184
229
|
const edges = routineEdges(heads, boundaries, graphReferences);
|
|
230
|
+
/** The routine that holds an address, linked to its entry; the address when no routine holds it. */
|
|
231
|
+
const ownerLink = (page: string, from: number) => {
|
|
232
|
+
const owner = ownerAt(from);
|
|
233
|
+
if (owner === undefined) return codeOfAddress(page, from);
|
|
234
|
+
return entries.has(owner.name) ? entryOfName(page, owner.name, owner.name) : codeOfName(page, owner.name);
|
|
235
|
+
};
|
|
185
236
|
|
|
186
237
|
// --- File ranges ----------------------------------------------------------
|
|
187
238
|
const fileRanges = new Map<string, { start: number; end: number }>();
|
|
@@ -194,7 +245,7 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
194
245
|
}
|
|
195
246
|
const titleOf = (file: string) => input.modules.find((module) => module.file === file)?.title;
|
|
196
247
|
|
|
197
|
-
const header =
|
|
248
|
+
const header = referenceHeader(input.revision, map.mapPath);
|
|
198
249
|
const files: ReferenceFile[] = [];
|
|
199
250
|
const write = (path: string, lines: string[]) => files.push({ path, bytes: Buffer.from(`${[header, ...lines].join("\n").replace(/\n{3,}/g, "\n\n")}\n`, "utf8") });
|
|
200
251
|
|
|
@@ -204,9 +255,9 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
204
255
|
.filter((comment) => comment.address === address)
|
|
205
256
|
.sort((a, b) => (a.placement === b.placement ? 0 : a.placement === "line" ? -1 : 1))
|
|
206
257
|
.map((comment) => comment.text.replace(/\s*\r?\n\s*/g, " ").trim());
|
|
207
|
-
const incoming = (entry: Entry) =>
|
|
258
|
+
const incoming = (entry: Entry) => dataReferences.filter((reference) => reference.to >= entry.address && reference.to <= entry.spanEnd);
|
|
208
259
|
const outgoing = (head: RoutineHead) => input.references.filter((reference) => ownerAt(reference.from)?.address === head.address);
|
|
209
|
-
const entryText = (page: string, entry: Entry): string[] => {
|
|
260
|
+
const entryText = (page: string, entry: Entry, labels: readonly Entry[]): string[] => {
|
|
210
261
|
const lines = ["", `<a id="${entry.name}"></a>`, `### ${codeOfName(page, entry.name)} \`${entry.spanEnd > entry.address ? range(entry.address, entry.spanEnd) : hex(entry.address)}\``, "", `*${entry.kind}*`];
|
|
211
262
|
const comments = commentLines(entry.address);
|
|
212
263
|
if (comments.length > 0) lines.push("", ...comments);
|
|
@@ -218,9 +269,9 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
218
269
|
const by = (kinds: readonly string[]) =>
|
|
219
270
|
fromOthers
|
|
220
271
|
.filter((reference) => kinds.includes(reference.kind) && !((reference.kind === "reference" || reference.kind === "pointer") && strong.has(reference.from)))
|
|
221
|
-
.map((reference) =>
|
|
272
|
+
.map((reference) => ownerLink(page, reference.from));
|
|
222
273
|
const add = (label: string, items: string[]) => {
|
|
223
|
-
if (items.length > 0) facts.push(`- **${label}:** ${capped([...new Set(items)])}`);
|
|
274
|
+
if (items.length > 0) facts.push(`- **${label}:** ${capped([...new Set(items)], MAX_FACTS)}`);
|
|
224
275
|
};
|
|
225
276
|
add("Called from", by(["call"]));
|
|
226
277
|
add("Jumped to from", by(["jump"]));
|
|
@@ -237,7 +288,7 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
237
288
|
const all = outgoing(head);
|
|
238
289
|
const named = new Set(all.filter((reference) => reference.kind !== "reference" && reference.kind !== "pointer").map((reference) => `${reference.from}:${reference.to}`));
|
|
239
290
|
const from = all.filter((reference) => !((reference.kind === "reference" || reference.kind === "pointer") && named.has(`${reference.from}:${reference.to}`)));
|
|
240
|
-
const to = (kinds: readonly string[]) => from.filter((reference) => kinds.includes(reference.kind) && ownerAt(reference.to)?.address !== head.address).map((reference) =>
|
|
291
|
+
const to = (kinds: readonly string[]) => from.filter((reference) => kinds.includes(reference.kind) && ownerAt(reference.to)?.address !== head.address).map((reference) => baseTarget(page, reference.to));
|
|
241
292
|
add("Calls", to(["call"]));
|
|
242
293
|
add("Jumps to", to(["jump"]));
|
|
243
294
|
add("Reads", to(["read"]));
|
|
@@ -245,8 +296,17 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
245
296
|
add("Refers to", to(["reference", "pointer"]));
|
|
246
297
|
}
|
|
247
298
|
if (facts.length > 0) lines.push("", ...facts);
|
|
248
|
-
return lines;
|
|
299
|
+
return [...lines, ...labelTable(page, labels)];
|
|
249
300
|
};
|
|
301
|
+
/** The labels that only code of their own file reaches: one row each, with the anchor that links to the label. */
|
|
302
|
+
const labelTable = (page: string, labels: readonly Entry[]) =>
|
|
303
|
+
labels.length === 0
|
|
304
|
+
? []
|
|
305
|
+
: ["", "| Label | Address | Comment |", "|---|---|---|", ...labels.map((label) => `| <a id="${label.name}"></a>${codeOfName(page, label.name)} | \`${hex(label.address)}\` | ${commentLines(label.address).join(" ").replace(/\|/g, "\\|")} |`)];
|
|
306
|
+
const entersAt = new Map<number, ReferenceRow[]>();
|
|
307
|
+
for (const reference of input.references) if (reference.kind === "call" || reference.kind === "jump") entersAt.set(reference.to, [...(entersAt.get(reference.to) ?? []), reference]);
|
|
308
|
+
// A pointer to code (lda #<irq_handler) is a vector: the CPU enters there from no file.
|
|
309
|
+
const pointedAt = new Set(input.references.filter((reference) => reference.kind === "pointer").map((reference) => reference.to));
|
|
250
310
|
const tableAnchor = (table: RegionRow) => entryAt.get(table.start)?.name ?? `table_${table.start.toString(16).padStart(4, "0")}`;
|
|
251
311
|
function tableLink(page: string, table: RegionRow): string {
|
|
252
312
|
return `[\`${entryAt.get(table.start)?.name ?? range(table.start, table.end)}\`](${rel(page, posix.join(out, "tables.md"))}#${tableAnchor(table)})`;
|
|
@@ -266,16 +326,31 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
266
326
|
const own = (pieceEntries.get(file) ?? []).sort((a, b) => a.address - b.address);
|
|
267
327
|
const title = titleOf(file);
|
|
268
328
|
const lines = [`# ${file}${title === undefined ? "" : `: ${title}`}`, "", `Range \`${span === undefined ? "-" : range(span.start, span.end)}\`. Source: [${file}](${rel(page, map.pathOf(file))}). Index: [the reference](${rel(page, posix.join(out, "index.md"))}).`];
|
|
329
|
+
// A label that only code of this file enters is a row: under the routine that holds it, else in the labels of the page.
|
|
330
|
+
const headAt = new Set(heads.map((head) => head.address));
|
|
331
|
+
const fromOtherFiles = (address: number) => (entersAt.get(address) ?? []).filter((reference) => map.lineOf(reference.from)?.file !== file);
|
|
332
|
+
const mains = new Set(own.filter((entry) => entry.kind !== "label" || headAt.has(entry.address) || pointedAt.has(entry.address) || fromOtherFiles(entry.address).length > 0).map((entry) => entry.address));
|
|
333
|
+
const labelsOf = new Map<number | undefined, Entry[]>();
|
|
334
|
+
for (const entry of own) {
|
|
335
|
+
if (mains.has(entry.address)) continue;
|
|
336
|
+
const owner = ownerAt(entry.address)?.address;
|
|
337
|
+
const group = owner !== undefined && mains.has(owner) ? owner : undefined;
|
|
338
|
+
labelsOf.set(group, [...(labelsOf.get(group) ?? []), entry]);
|
|
339
|
+
}
|
|
269
340
|
if (span !== undefined) {
|
|
270
341
|
const inside = (address: number) => address >= span.start && address <= span.end;
|
|
271
|
-
const ownHeads =
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
342
|
+
const ownHeads = heads.filter((head) => inside(head.address));
|
|
343
|
+
// The overview: each routine, and each label that code of another file enters.
|
|
344
|
+
const starts = [...new Set([...ownHeads.map((head) => head.address), ...own.filter((entry) => mains.has(entry.address) && (entry.kind === "routine" || entry.kind === "label")).map((entry) => entry.address)])].sort((a, b) => a - b);
|
|
345
|
+
if (starts.length > 0) {
|
|
346
|
+
lines.push("", "## Routines", "", "| Routine | Address | Reached from | Summary |", "|---|---|---|---|");
|
|
347
|
+
for (const start of starts) {
|
|
348
|
+
const name = entryAt.get(start)?.name ?? ownHeads.find((head) => head.address === start)!.name;
|
|
349
|
+
const shown = entries.has(name) ? entryOfName(page, name, name) : codeOfName(page, name);
|
|
350
|
+
const callers = [...new Set([...edges.filter((edge) => edge.to === start && edge.kind !== "jump").map((edge) => edge.from), ...fromOtherFiles(start).map((reference) => reference.from)].map((from) => ownerLink(page, from)))];
|
|
351
|
+
const summary = /^.*?[.!?](?=\s|$)|^.*$/.exec(commentLines(start).join(" "))![0].replace(/\|/g, "\\|");
|
|
352
|
+
lines.push(`| ${shown} | \`${hex(start)}\` | ${capped(callers, MAX_FACTS)} | ${summary} |`);
|
|
353
|
+
}
|
|
279
354
|
}
|
|
280
355
|
const regions = input.regions.filter((region) => region.start <= span.end && region.end >= span.start && region.type !== "code");
|
|
281
356
|
if (regions.length > 0) {
|
|
@@ -286,9 +361,20 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
286
361
|
lines.push(`| ${codeOfAddress(page, region.start)}${region.end === region.start ? "" : `-\`${hex(region.end)}\``} | ${region.type}${region.element === undefined ? "" : ` of ${region.element}`} | ${name === undefined ? "" : codeOfName(page, name.name)} | ${owners("read")} | ${owners("write")} |`);
|
|
287
362
|
}
|
|
288
363
|
}
|
|
364
|
+
// Jumps are the control flow inside a group of routines: the graph draws the calls and the table entries only.
|
|
365
|
+
const ownAt = new Set(ownHeads.map((head) => head.address));
|
|
366
|
+
const reaching = edges.filter((edge) => edge.kind !== "jump" && (ownAt.has(edge.from) || ownAt.has(edge.to)));
|
|
367
|
+
const shown = reaching.slice(0, MAX_EDGES);
|
|
368
|
+
if (shown.length > 0) {
|
|
369
|
+
lines.push("", "## Call graph", "", "A solid arrow is a call, a thick arrow a table entry. Rounded nodes are in this file.");
|
|
370
|
+
if (shown.length < reaching.length) lines.push("", `The graph shows ${shown.length} of the ${reaching.length} edges.`);
|
|
371
|
+
lines.push("", "```mermaid", mermaidGraph(heads, shown, ownAt), "```");
|
|
372
|
+
}
|
|
289
373
|
}
|
|
290
|
-
if (own.length > 0) lines.push("", "##
|
|
291
|
-
for (const entry of own) lines.push(...entryText(page, entry));
|
|
374
|
+
if (own.length > 0) lines.push("", "## Details");
|
|
375
|
+
for (const entry of own) if (mains.has(entry.address)) lines.push(...entryText(page, entry, labelsOf.get(entry.address) ?? []));
|
|
376
|
+
const loose = labelsOf.get(undefined) ?? [];
|
|
377
|
+
if (loose.length > 0) lines.push("", "## Labels", ...labelTable(page, loose));
|
|
292
378
|
counts.entries += own.length;
|
|
293
379
|
write(page, lines);
|
|
294
380
|
}
|
|
@@ -369,7 +455,7 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
369
455
|
lines.push("", "## Variables outside the program", "", "| Address | Name | Comment | Read by | Written by |", "|---|---|---|---|---|");
|
|
370
456
|
for (const entry of outside) {
|
|
371
457
|
const at = `\`${entry.spanEnd > entry.address ? range(entry.address, entry.spanEnd) : hex(entry.address)}\``;
|
|
372
|
-
const owners = (kind: string) => ownersOf(page, entry.address, entry.spanEnd, kind);
|
|
458
|
+
const owners = (kind: string) => ownersOf(page, entry.address, entry.spanEnd, kind, entry.kind === "platform" ? entry.name : undefined);
|
|
373
459
|
lines.push(`| ${at} | <a id="${entry.name}"></a>${codeOfName(page, entry.name)} | ${commentLines(entry.address).join(" ").replace(/\|/g, "\\|")} | ${owners("read")} | ${owners("write")} |`);
|
|
374
460
|
}
|
|
375
461
|
counts.entries += outside.length;
|
|
@@ -32,6 +32,8 @@ export interface SourceMap {
|
|
|
32
32
|
lineOf: (address: number) => SourceLine | undefined;
|
|
33
33
|
/** The project path of a source file. */
|
|
34
34
|
pathOf: (file: string) => string;
|
|
35
|
+
/** The text of a source line, without its comment; undefined when the file or the line is not there. */
|
|
36
|
+
textOf?: (line: SourceLine) => string | undefined;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** Reads the source map of the source in `directory` of the project `root`. A missing map is a refusal with the remedy. */
|
|
@@ -61,6 +63,7 @@ export function readSourceMap(directory: string, root?: string): SourceMap {
|
|
|
61
63
|
.map((item) => ({ start: parseC64Address(String(item.start)), end: parseC64Address(String(item.end)), file: String(item.file), line: Number(item.line) }))
|
|
62
64
|
.sort((a, b) => a.start - b.start);
|
|
63
65
|
const byName = new Map(labels.map((label) => [label.name, label]));
|
|
66
|
+
const texts = new Map<string, string[] | undefined>();
|
|
64
67
|
return {
|
|
65
68
|
directory,
|
|
66
69
|
mapPath: path,
|
|
@@ -82,5 +85,16 @@ export function readSourceMap(directory: string, root?: string): SourceMap {
|
|
|
82
85
|
return undefined;
|
|
83
86
|
},
|
|
84
87
|
pathOf: (file) => posix.join(directory, file),
|
|
88
|
+
textOf: (line) => {
|
|
89
|
+
if (!texts.has(line.file)) {
|
|
90
|
+
try {
|
|
91
|
+
texts.set(line.file, readProjectFile(posix.join(directory, line.file), root === undefined ? {} : { root }).bytes.toString("utf8").split(/\r?\n/));
|
|
92
|
+
} catch {
|
|
93
|
+
texts.set(line.file, undefined);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const text = texts.get(line.file)?.[line.line - 1];
|
|
97
|
+
return text?.replace(/;.*$/, "");
|
|
98
|
+
},
|
|
85
99
|
};
|
|
86
100
|
}
|
|
@@ -70,7 +70,7 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
|
|
|
70
70
|
## Addresses, names and spaces
|
|
71
71
|
|
|
72
72
|
- A symbol is the name of an address from the user or the LLM. Get it from `at`, `search` or `symbols`.
|
|
73
|
-
- An analyzer name is a second name from DXA,
|
|
73
|
+
- An analyzer name is a second name from DXA, the decompiler or an idiom search, for example `FUN_17e2`. Each analyzer keeps its own name at an address. Get them from `at`, `search` or `symbols --analyzer`.
|
|
74
74
|
- The generated source uses only the symbols. To use an analyzer name in the source, give the address that name with `rename`.
|
|
75
75
|
- A symbol name is a label for ACME: a letter or an underscore, then letters, digits or underscores. The knowledge refuses the name of a 6502 instruction, for example `lda`, in upper or lower case.
|
|
76
76
|
- A space is `c64` (the default), `drive8` for code in the 1541 drive, `loading` or `bank0` to `bank255`. `loading` is the captured stage of the loading that shows the start screen. `bank0` to `bank255` are cartridge banks, or other memory images of the program, for example a file that the program loads later. Drive code, the stage and banks use the same addresses as the C64. Thus each space has its own knowledge. A name is unique in one space.
|
|
@@ -113,7 +113,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
113
113
|
| `--evidence <kind:ref>` | `join` | With `--apply`: the same as for the commands in "Change the knowledge". |
|
|
114
114
|
| `--expect-revision <revision>` | `join` | With `--apply`: the same as for the commands in "Change the knowledge". |
|
|
115
115
|
| `--range <start>-<end>` | `symbols`, `regions`, `comments`, `references`, `suppressions`, `modules`, `operands`, `patches`, `uses`, `export` | Only the rows in this range. The default is all addresses. |
|
|
116
|
-
| `--origin <origin>` | `search`, `symbols`, `regions`, `comments`, `references`, `modules`, `operands`, `patches`, `macros`, `uses`, `export` | Only the rows of these origins: `user`, `llm`, `dxa`, `
|
|
116
|
+
| `--origin <origin>` | `search`, `symbols`, `regions`, `comments`, `references`, `modules`, `operands`, `patches`, `macros`, `uses`, `export` | Only the rows of these origins: `user`, `llm`, `dxa`, `decompiler`, `heuristic`, `semantic` (user and llm), `analyzer` (dxa, decompiler and heuristic), or a comma list. The default is all origins. |
|
|
117
117
|
| `--max-listed <n>` | `search`, `symbols`, `regions`, `comments`, `references`, `suppressions`, `modules`, `operands`, `patches`, `switches`, `releases`, `macros`, `uses`, `spaces`, `history`, `revisions`, `revision`, `listing`, `join` | The most items in each list of the body. The default is 50. The counts are always complete. |
|
|
118
118
|
| `--kind <kind>` | `symbols`, `rename` | The symbol kind: `label`, `routine`, `variable`, `data` or `vector`. A read gives all kinds by default. A new symbol without `--kind` is a `label`. A `rename` without `--kind` keeps the kind of the symbol. |
|
|
119
119
|
| `--kind <kind>` | `references` | Only references of this kind: `call`, `jump`, `read`, `write`, `reference` or `pointer`. |
|
|
@@ -200,7 +200,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
|
|
|
200
200
|
### `suppressions`
|
|
201
201
|
|
|
202
202
|
- `body.suppressions` lists the places that a removal blocks. Each item has `suppresses` (`symbol`, `region` or `reference`), the place, and the `reason` of the removal.
|
|
203
|
-
- `unclassify` and `unreference` block the place for DXA and
|
|
203
|
+
- `unclassify` and `unreference` block the place for DXA and the decompiler. A later analysis does not add a region in that range or that reference again. This is also true for a fact from the LLM.
|
|
204
204
|
- `remove-symbol` does not block the address, because an analyzer name never becomes a symbol.
|
|
205
205
|
- A `rename`, `classify` or `reference` at a blocked place ends the block there. A `revert` to a revision before the removal also ends the block.
|
|
206
206
|
- `at` and `history` also show the blocks.
|
|
@@ -251,7 +251,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
|
|
|
251
251
|
- `body.lines` has `count` and `listed`. `listed` holds one line for each instruction of a code region, and one `!byte` line for other bytes.
|
|
252
252
|
- Each line has `address`, `bytes`, `text`, `referencesIn` and `referencesOut`. It can also have `label`, `analyzerNames`, `lineComments` and `comment`. `lineComments` are the line comments before the line. `comment` is the side comment.
|
|
253
253
|
- `text` is the instruction with the names of its target. An operand expression of the knowledge replaces the operand.
|
|
254
|
-
-
|
|
254
|
+
- `access` is there when the knowledge has coverage. It tells if a run executed (`x`), read (`r`) or wrote (`w`) the bytes of the line. `-` tells that no run did. An `r` on code can come from a read of the 6502 that the program does not do. Examples are the third byte of a JSR and the opcode after a branch that the CPU takes. Another example is the opcode at the PC when an interrupt starts. An indexed read (`lda table,x`) that crosses a page also reads the byte $100 below its target. A read watchpoint does not stop at these reads.
|
|
255
255
|
- With `--out`, the body has `lines` as a number, and `out`, `bytes` and `sha256` of the text file.
|
|
256
256
|
- If the knowledge has no program in the space, the script refuses. Put the program in with `image` first.
|
|
257
257
|
- Use `listing` in place of your own disassembler.
|
|
@@ -279,7 +279,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
|
|
|
279
279
|
### `revision <revision>`
|
|
280
280
|
|
|
281
281
|
- `body.revision` gives the revision. `body.added` and `body.closed` list the rows that it added and closed.
|
|
282
|
-
- The rows include the memory, entry and coverage rows of the program.
|
|
282
|
+
- The rows include the memory, entry and coverage rows of the program. A coverage row gives the `map`, the access `kind` and the number of `ranges` of that kind in the map.
|
|
283
283
|
|
|
284
284
|
---
|
|
285
285
|
|
|
@@ -540,8 +540,9 @@ A macro writes a run of instructions as one line of the source, for example `+in
|
|
|
540
540
|
### `coverage <map>...`
|
|
541
541
|
|
|
542
542
|
- `<map>` is a 64 KiB coverage map of a run. Write each map in `.c64-re-tools/local/`.
|
|
543
|
-
- `body` holds `revision`, `imported`, `known` and `
|
|
544
|
-
-
|
|
543
|
+
- `body` holds `revision`, `imported`, `replaced`, `known`, `added` and `removed`. `imported` lists the new maps. `replaced` lists the new maps that replace an earlier map of the same path. `known` lists the maps that are the latest map of their path in the space already. `added` and `removed` count the ranges of accesses that the coverage gets and loses. When both are 0, the source and the reference do not change.
|
|
544
|
+
- The knowledge keeps one map for each path in a space. A new map of a path replaces the earlier map of that path. Thus, after you record a run again into the same folder, put its new map into the project knowledge. Then the coverage has only the new run of that folder.
|
|
545
|
+
- The coverage of a space is the union of its maps. It has each address that a run executed, read or wrote. It also has each address that one run wrote and executed: self-modified code.
|
|
545
546
|
- `coverage` puts each map into the space of `--space`. You can add the same map to each space.
|
|
546
547
|
- `--evidence coverage:<map>` names a map by its path at the import. It refers to the last import of that map into the space of the write.
|
|
547
548
|
|