mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 07:03:39 +00:00
* Reimplement colorized data relocation hover diffs * Fix objdiff-wasm build Data diffing doesn't seem to be fully implemented in objdiff-wasm yet, so just putting placeholders in so it compiles. * Reloc hover: Add separators, override special color too
280 lines
5.2 KiB
Plaintext
280 lines
5.2 KiB
Plaintext
package objdiff:core;
|
|
|
|
use wasi:logging/logging@0.1.0-draft;
|
|
|
|
interface diff {
|
|
resource diff-config {
|
|
constructor();
|
|
set-property: func(id: string, value: string) -> result<_, string>;
|
|
get-property: func(id: string) -> result<string, string>;
|
|
}
|
|
|
|
record mapping-config {
|
|
mappings: list<tuple<string, string>>,
|
|
selecting-left: option<string>,
|
|
selecting-right: option<string>,
|
|
}
|
|
|
|
resource object {
|
|
parse: static func(
|
|
data: list<u8>,
|
|
config: borrow<diff-config>,
|
|
) -> result<object, string>;
|
|
|
|
hash: func() -> u64;
|
|
}
|
|
|
|
resource object-diff {
|
|
find-symbol: func(
|
|
name: string,
|
|
section-name: option<string>
|
|
) -> option<u32>;
|
|
}
|
|
|
|
record diff-result {
|
|
left: option<object-diff>,
|
|
right: option<object-diff>,
|
|
}
|
|
|
|
run-diff: func(
|
|
left: option<borrow<object>>,
|
|
right: option<borrow<object>>,
|
|
config: borrow<diff-config>,
|
|
) -> result<diff-result, string>;
|
|
}
|
|
|
|
interface display {
|
|
use diff.{
|
|
object,
|
|
object-diff,
|
|
diff-config
|
|
};
|
|
|
|
type symbol-ref = u32;
|
|
|
|
record display-config {
|
|
show-hidden-symbols: bool,
|
|
show-mapped-symbols: bool,
|
|
reverse-fn-order: bool,
|
|
}
|
|
|
|
record symbol-filter {
|
|
regex: option<string>,
|
|
mapping: option<symbol-ref>,
|
|
}
|
|
|
|
record section-display-symbol {
|
|
symbol: symbol-ref,
|
|
is-mapping-symbol: bool,
|
|
}
|
|
|
|
record section-display {
|
|
id: string,
|
|
name: string,
|
|
size: u64,
|
|
match-percent: option<f32>,
|
|
symbols: list<section-display-symbol>,
|
|
}
|
|
|
|
enum symbol-kind {
|
|
unknown,
|
|
function,
|
|
object,
|
|
section,
|
|
}
|
|
|
|
flags symbol-flags {
|
|
global,
|
|
local,
|
|
weak,
|
|
common,
|
|
hidden,
|
|
has-extra,
|
|
size-inferred,
|
|
ignored,
|
|
}
|
|
|
|
record symbol-display {
|
|
name: string,
|
|
demangled-name: option<string>,
|
|
address: u64,
|
|
size: u64,
|
|
kind: symbol-kind,
|
|
section: option<u32>,
|
|
%flags: symbol-flags,
|
|
align: option<u32>,
|
|
virtual-address: option<u64>,
|
|
|
|
target-symbol: option<symbol-ref>,
|
|
match-percent: option<f32>,
|
|
diff-score: option<tuple<u64, u64>>,
|
|
row-count: u32,
|
|
}
|
|
|
|
enum symbol-navigation-kind {
|
|
normal,
|
|
extab,
|
|
}
|
|
|
|
record context-item-copy {
|
|
value: string,
|
|
label: option<string>,
|
|
}
|
|
|
|
record context-item-navigate {
|
|
label: string,
|
|
symbol: symbol-ref,
|
|
kind: symbol-navigation-kind,
|
|
}
|
|
|
|
variant context-item {
|
|
copy(context-item-copy),
|
|
navigate(context-item-navigate),
|
|
separator,
|
|
}
|
|
|
|
enum hover-item-color {
|
|
normal,
|
|
emphasized,
|
|
special,
|
|
delete,
|
|
insert,
|
|
}
|
|
|
|
record hover-item-text {
|
|
label: string,
|
|
value: string,
|
|
color: hover-item-color,
|
|
}
|
|
|
|
variant hover-item {
|
|
text(hover-item-text),
|
|
separator,
|
|
}
|
|
|
|
record diff-text-opcode {
|
|
mnemonic: string,
|
|
opcode: u16,
|
|
}
|
|
|
|
record diff-text-symbol {
|
|
name: string,
|
|
demangled-name: option<string>,
|
|
}
|
|
|
|
variant diff-text {
|
|
// Basic text (not semantically meaningful)
|
|
basic(string),
|
|
// Line number
|
|
line(u32),
|
|
// Instruction address
|
|
address(u64),
|
|
// Instruction mnemonic
|
|
opcode(diff-text-opcode),
|
|
// Instruction argument (signed)
|
|
signed(s64),
|
|
// Instruction argument (unsigned)
|
|
unsigned(u64),
|
|
// Instruction argument (opaque)
|
|
opaque(string),
|
|
// Instruction argument (branch destination)
|
|
branch-dest(u64),
|
|
// Relocation target name
|
|
symbol(diff-text-symbol),
|
|
// Relocation addend
|
|
addend(s64),
|
|
// Number of spaces
|
|
spacing(u8),
|
|
// End of line
|
|
eol,
|
|
}
|
|
|
|
variant diff-text-color {
|
|
normal,
|
|
dim,
|
|
bright,
|
|
replace,
|
|
delete,
|
|
insert,
|
|
rotating(u8),
|
|
}
|
|
|
|
record diff-text-segment {
|
|
// Text to display
|
|
text: diff-text,
|
|
// Text color
|
|
color: diff-text-color,
|
|
// Number of spaces to pad to
|
|
pad-to: u8,
|
|
}
|
|
|
|
record instruction-diff-row {
|
|
// Text segments
|
|
segments: list<diff-text-segment>,
|
|
// Diff kind
|
|
diff-kind: instruction-diff-kind,
|
|
}
|
|
|
|
enum instruction-diff-kind {
|
|
none,
|
|
op-mismatch,
|
|
arg-mismatch,
|
|
replace,
|
|
insert,
|
|
delete,
|
|
}
|
|
|
|
display-sections: func(
|
|
diff: borrow<object-diff>,
|
|
filter: symbol-filter,
|
|
config: display-config,
|
|
) -> list<section-display>;
|
|
|
|
display-symbol: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
) -> symbol-display;
|
|
|
|
display-instruction-row: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
row-index: u32,
|
|
config: borrow<diff-config>,
|
|
) -> instruction-diff-row;
|
|
|
|
symbol-context: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
) -> list<context-item>;
|
|
|
|
symbol-hover: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
) -> list<hover-item>;
|
|
|
|
instruction-context: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
row-index: u32,
|
|
config: borrow<diff-config>,
|
|
) -> result<list<context-item>, string>;
|
|
|
|
instruction-hover: func(
|
|
diff: borrow<object-diff>,
|
|
symbol: section-display-symbol,
|
|
row-index: u32,
|
|
config: borrow<diff-config>,
|
|
) -> result<list<hover-item>, string>;
|
|
}
|
|
|
|
world api {
|
|
import logging;
|
|
use logging.{level};
|
|
|
|
export diff;
|
|
export display;
|
|
|
|
export init: func(level: level);
|
|
export version: func() -> string;
|
|
}
|