A gazillion changes

This commit is contained in:
Luke Street
2025-01-04 21:06:02 -07:00
parent 0c6f39c4b4
commit 3d753edd0f
28 changed files with 3331 additions and 847 deletions
+230
View File
@@ -0,0 +1,230 @@
{
"properties": [
{
"id": "relaxRelocDiffs",
"type": "boolean",
"default": false,
"name": "Relax relocation diffs",
"description": "Ignores differences in relocation targets. (Address, name, etc)"
},
{
"id": "spaceBetweenArgs",
"type": "boolean",
"default": true,
"name": "Space between args",
"description": "Adds a space between arguments in the diff output."
},
{
"id": "combineDataSections",
"type": "boolean",
"default": false,
"name": "Combine data sections",
"description": "Combines data sections with equal names."
},
{
"id": "arm.archVersion",
"type": "choice",
"default": "auto",
"name": "Architecture version",
"description": "ARM architecture version to use for disassembly.",
"items": [
{
"value": "auto",
"name": "Auto"
},
{
"value": "v4t",
"name": "ARMv4T (GBA)"
},
{
"value": "v5te",
"name": "ARMv5TE (DS)"
},
{
"value": "v6k",
"name": "ARMv6K (3DS)"
}
]
},
{
"id": "arm.unifiedSyntax",
"type": "boolean",
"default": false,
"name": "Unified syntax",
"description": "Disassemble as unified assembly language (UAL)."
},
{
"id": "arm.avRegisters",
"type": "boolean",
"default": false,
"name": "Use A/V registers",
"description": "Display R0-R3 as A1-A4 and R4-R11 as V1-V8."
},
{
"id": "arm.r9Usage",
"type": "choice",
"default": "generalPurpose",
"name": "Display R9 as",
"items": [
{
"value": "generalPurpose",
"name": "R9 or V6",
"description": "Use R9 as a general-purpose register."
},
{
"value": "sb",
"name": "SB (static base)",
"description": "Used for position-independent data (PID)."
},
{
"value": "tr",
"name": "TR (TLS register)",
"description": "Used for thread-local storage."
}
]
},
{
"id": "arm.slUsage",
"type": "boolean",
"default": false,
"name": "Display R10 as SL",
"description": "Used for explicit stack limits."
},
{
"id": "arm.fpUsage",
"type": "boolean",
"default": false,
"name": "Display R11 as FP",
"description": "Used for frame pointers."
},
{
"id": "arm.ipUsage",
"type": "boolean",
"default": false,
"name": "Display R12 as IP",
"description": "Used for interworking and long branches."
},
{
"id": "mips.abi",
"type": "choice",
"default": "auto",
"name": "ABI",
"description": "MIPS ABI to use for disassembly.",
"items": [
{
"value": "auto",
"name": "Auto"
},
{
"value": "o32",
"name": "O32"
},
{
"value": "n32",
"name": "N32"
},
{
"value": "n64",
"name": "N64"
}
]
},
{
"id": "mips.instrCategory",
"type": "choice",
"default": "auto",
"name": "Instruction category",
"description": "MIPS instruction category to use for disassembly.",
"items": [
{
"value": "auto",
"name": "Auto"
},
{
"value": "cpu",
"name": "CPU"
},
{
"value": "rsp",
"name": "RSP (N64)"
},
{
"value": "r3000gte",
"name": "R3000 GTE (PS1)"
},
{
"value": "r4000allegrex",
"name": "R4000 ALLEGREX (PSP)"
},
{
"value": "r5900",
"name": "R5900 EE (PS2)"
}
]
},
{
"id": "x86.formatter",
"type": "choice",
"default": "intel",
"name": "Format",
"description": "x86 disassembly syntax.",
"items": [
{
"value": "intel",
"name": "Intel"
},
{
"value": "gas",
"name": "AT&T"
},
{
"value": "nasm",
"name": "NASM"
},
{
"value": "masm",
"name": "MASM"
}
]
}
],
"groups": [
{
"id": "general",
"name": "General",
"properties": [
"relaxRelocDiffs",
"spaceBetweenArgs",
"combineDataSections"
]
},
{
"id": "arm",
"name": "ARM",
"properties": [
"arm.archVersion",
"arm.unifiedSyntax",
"arm.avRegisters",
"arm.r9Usage",
"arm.slUsage",
"arm.fpUsage",
"arm.ipUsage"
]
},
{
"id": "mips",
"name": "MIPS",
"properties": [
"mips.abi",
"mips.instrCategory"
]
},
{
"id": "x86",
"name": "x86",
"properties": [
"x86.formatter"
]
}
]
}
+71 -4
View File
@@ -1,5 +1,3 @@
// import * as vscode from 'vscode';
export const DEFAULT_WATCH_PATTERNS = [
'*.c',
'*.cp',
@@ -19,10 +17,12 @@ export const DEFAULT_WATCH_PATTERNS = [
'*.json',
];
export const CONFIG_FILENAME = 'objdiff.json';
/**
* Configuration file for objdiff
*/
export interface ObjdiffConfiguration {
export interface ProjectConfig {
/**
* Minimum version of objdiff required to load this configuration file.
*/
@@ -179,7 +179,7 @@ export interface ProgressCategory {
name?: string;
}
export function resolveConfig(config: ObjdiffConfiguration) {
export function resolveProjectConfig(config: ProjectConfig) {
if (config.watch_patterns === undefined) {
config.watch_patterns = DEFAULT_WATCH_PATTERNS;
}
@@ -215,3 +215,70 @@ export function resolveConfig(config: ObjdiffConfiguration) {
}
return config;
}
export type ConfigPropertyBase = {
id: string;
name: string;
description?: string;
default: ConfigPropertyValue;
};
export type ConfigPropertyValue = boolean | string;
export type ConfigProperties = Record<string, ConfigPropertyValue>;
export type ConfigPropertyBoolean = ConfigPropertyBase & {
type: 'boolean';
default: boolean;
};
export type ConfigPropertyChoice = ConfigPropertyBase & {
type: 'choice';
default: string;
items: ConfigPropertyChoiceItem[];
};
export type ConfigProperty = ConfigPropertyBoolean | ConfigPropertyChoice;
export type ConfigPropertyChoiceItem = {
value: string;
name: string;
description?: string;
};
export type ConfigGroup = {
id: string;
name: string;
properties: string[];
};
export type ConfigSchema = {
properties: ConfigProperty[];
groups: ConfigGroup[];
};
import configSchema from './config-schema.json';
export const CONFIG_SCHEMA = configSchema as ConfigSchema;
export function getPropertyValue(
properties: ConfigProperties,
id: string,
): ConfigPropertyValue {
const property = CONFIG_SCHEMA.properties.find((p) => p.id === id);
if (!property) {
throw new Error(`Property not found: ${id}`);
}
return properties[id] ?? property.default;
}
export function getModifiedConfigProperties(
properties: ConfigProperties,
): ConfigProperties {
const modified: ConfigProperties = {};
for (const property of CONFIG_SCHEMA.properties) {
if (property.default !== properties[property.id]) {
modified[property.id] = properties[property.id];
}
}
return modified;
}
+27 -18
View File
@@ -1,24 +1,21 @@
import type { ObjdiffConfiguration, Unit } from './config';
export type DiffMessage = {
type: 'diff';
data: ArrayBuffer | null;
currentUnit: Unit | null;
};
export type TaskMessage = {
type: 'task';
taskType: string;
running: boolean;
};
import type {
ConfigProperties,
ConfigPropertyValue,
ProjectConfig,
Unit,
} from './config';
export type StateMessage = {
type: 'state';
config: ObjdiffConfiguration | null;
buildRunning?: boolean;
configProperties?: ConfigProperties;
currentUnit?: Unit | null;
data?: ArrayBuffer | null;
projectConfig?: ProjectConfig | null;
};
// extension -> webview
export type InboundMessage = DiffMessage | TaskMessage | StateMessage;
export type InboundMessage = StateMessage;
export type ReadyMessage = {
type: 'ready';
@@ -43,10 +40,22 @@ export type QuickPickUnitMessage = {
type: 'quickPickUnit';
};
export type SetConfigPropertyMessage = {
type: 'setConfigProperty';
id: string;
value: ConfigPropertyValue | undefined;
};
export type OpenSettingsMessage = {
type: 'openSettings';
};
// webview -> extension
export type OutboundMessage =
| ReadyMessage
| LineRangesMessage
| OpenSettingsMessage
| QuickPickUnitMessage
| ReadyMessage
| RunTaskMessage
| SetCurrentUnitMessage
| QuickPickUnitMessage;
| SetConfigPropertyMessage
| SetCurrentUnitMessage;