aboutsummaryrefslogtreecommitdiffstats
path: root/docs/wip-asm-spans.patch (follow)
Commit message (Collapse)AuthorAgeFilesLines
* listing: syntax-highlight assembly from IDA's own token tagsblasty20 hours1-247/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The listing showed the mnemonic bright and every operand in one body colour. IDA already classifies each token, for every processor it supports: generate_disasm_line() emits \x01<tag>text\x02<tag> and the tag says what the text IS. We were calling tag_remove() and throwing that away. So: no lexer. A pygments asm lexer would be a worse guess and would need one dialect per architecture — this is arch-correct for free, including the ARM/MIPS blobs the loader work just made openable. lea rcx, function; "usage" insn reg punct name cmt _idatui_spans() parses the tags into [[kind, text], ...], heads rows carry "spans", Head.spans holds them, and _span_segments() renders them with a fallback to the old mnemonic/rest split for older workers. Palette rule: NEUTRALS for the machine (mnemonic brightest — it's the column you scan; registers at body weight because they're most of the text), HUES only where they mean something (numbers, strings, symbols), structure recedes so commas and brackets stop competing with operands. Two things that fail SILENTLY and are now encoded: * The constants are SCOLOR_DATNAME / SCOLOR_CODNAME. There is no SCOLOR_DNAME — a wrong guess leaves the tag unmapped, symbols render as plain body text, and nothing tells you why. Probed the live IDA to get the real names. * Spans must be whitespace-collapsed exactly as `text` is, walking characters rather than per span, because a run of IDA's column padding straddles span boundaries. A row only gets spans when they reconstruct `text` exactly, so a mismatch degrades to the old rendering instead of corrupting the line. The reason this was parked yesterday was NOT a bug in it. listing_view's "undefining a data head yields an unknown run" waits for `index_of_ea(dea) >= 0` — but dea is the head it just undefined, so it is in the OLD model too and the predicate passes instantly, asserting against pre-edit rows. It only ever passed because the model swap won the race; spans made pages 3x bigger, the swap lost, and the check accused working code. It now waits for the model to be REPLACED. Cost measured on libcrypto: 95KB per 500-row page, 50ms; model ensure(2000) 228ms. Acceptable for what it buys. tests: new asm_highlight scenario (+7) — >90% of code rows carry spans, insn/reg/ punct present, every span kind has a style, spans reconstruct the row text exactly, mnemonic is the first span. 202/0 scenarios, 26/0 blob, 30/0 project UI. TODO: DisasmView appears to be dead code (never instantiated; Ctx.dis returns ListingView), which is why this only needed doing once.
* asm highlighting: park the work with its findings (not merged)blasty20 hours1-0/+247
IDA already classifies every disassembly token for every processor it supports — generate_disasm_line emits \x01<tag>text\x02<tag> and the tag says what the text IS — so this needs no lexer at all, and certainly not a pygments asm lexer, which would be a worse guess and need one dialect per architecture. Working implementation is in docs/wip-asm-spans.patch and verified on echo: "lea rcx, function; \"usage\"" tokenises as insn/text/reg/punct/text/name/cmt, with sane coverage over 400 rows. Not merged: it breaks listing_view's "undefining a data head yields an unknown run" (reports kind=data). Bisected to this change on a fresh database — 10/0 with it stashed, 9/1 with it applied. The span code doesn't touch `kind`, so the cause is not yet understood, and I would rather park a working-but-unexplained change than merge one that makes a real check lie. TODO records the two non-obvious findings so the next attempt doesn't repeat them: the constants are SCOLOR_DATNAME/SCOLOR_CODNAME (no SCOLOR_DNAME, and a wrong guess fails silently as plain body text), and spans must be whitespace-collapsed by walking characters, not per span, because a run of spaces straddles span boundaries.