Skip to content

Commit

Permalink
Rename word to MAU and add link to settings docs (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
planger committed Mar 22, 2024
1 parent d1c825c commit e92b909
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 92 deletions.
9 changes: 9 additions & 0 deletions media/options-widget.css
Expand Up @@ -137,3 +137,12 @@
background-color: transparent;
cursor: pointer;
}

.no-text-decoration {
text-decoration: none;
}

.option-help-icon {
color: var(--vscode-button-background);
margin-left: 0.2em;
}
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -255,7 +255,7 @@
"default": "on",
"description": "Refresh memory views when debugger stops"
},
"memory-inspector.groupings.bytesPerWord": {
"memory-inspector.groupings.bytesPerMAU": {
"type": "number",
"enum": [
1,
Expand All @@ -265,9 +265,9 @@
16
],
"default": 1,
"description": "Default bytes per word"
"description": "Default bytes per MAU (Minimum Addressable Unit)"
},
"memory-inspector.groupings.wordsPerGroup": {
"memory-inspector.groupings.MAUsPerGroup": {
"type": "number",
"enum": [
1,
Expand All @@ -277,7 +277,7 @@
16
],
"default": 1,
"description": "Default words per group"
"description": "Default MAUs (Minimum Addressable Units) per group"
},
"memory-inspector.groupings.groupsPerRow": {
"type": [
Expand Down
4 changes: 2 additions & 2 deletions src/common/memory-range.ts
Expand Up @@ -122,8 +122,8 @@ export function areVariablesEqual(one: BigIntVariableRange, other: BigIntVariabl
&& one.value === other.value;
}

export function toOffset(startAddress: bigint, targetAddress: bigint, wordSize: number): number {
return Number(targetAddress - startAddress) * (wordSize / 8);
export function toOffset(startAddress: bigint, targetAddress: bigint, mauSize: number): number {
return Number(targetAddress - startAddress) * (mauSize / 8);
}

export enum Endianness {
Expand Down
18 changes: 9 additions & 9 deletions src/plugin/manifest.ts
Expand Up @@ -29,16 +29,16 @@ export const DEFAULT_DEBUG_TYPES = ['gdb', 'embedded-debug', 'arm-debugger'];
export const CONFIG_REFRESH_ON_STOP = 'refreshOnStop';
export const DEFAULT_REFRESH_ON_STOP = 'on';

// Words
// - Bytes per Word
export const CONFIG_BYTES_PER_WORD = 'groupings.bytesPerWord';
export const CONFIG_BYTES_PER_WORD_CHOICES = [1, 2, 4, 8, 16] as const;
export const DEFAULT_BYTES_PER_WORD = 1;
// MAUs (Minimum Addressable Units)
// - Bytes per MAU
export const CONFIG_BYTES_PER_MAU = 'groupings.bytesPerMAU';
export const CONFIG_BYTES_PER_MAU_CHOICES = [1, 2, 4, 8, 16] as const;
export const DEFAULT_BYTES_PER_MAU = 1;

// - Words per Group
export const CONFIG_WORDS_PER_GROUP = 'groupings.wordsPerGroup';
export const CONFIG_WORDS_PER_GROUP_CHOICES = [1, 2, 4, 8, 16] as const;
export const DEFAULT_WORDS_PER_GROUP = 1;
// - MAU per Group
export const CONFIG_MAUS_PER_GROUP = 'groupings.MAUsPerGroup';
export const CONFIG_MAUS_PER_GROUP_CHOICES = [1, 2, 4, 8, 16] as const;
export const DEFAULT_MAUS_PER_GROUP = 1;

// - Groups per Row
export const CONFIG_GROUPS_PER_ROW = 'groupings.groupsPerRow';
Expand Down
6 changes: 3 additions & 3 deletions src/plugin/memory-webview-main.ts
Expand Up @@ -255,8 +255,8 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {

protected getMemoryViewSettings(messageParticipant: WebviewIdMessageParticipant, title: string): MemoryViewSettings {
const memoryInspectorConfiguration = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME);
const bytesPerWord = memoryInspectorConfiguration.get<number>(manifest.CONFIG_BYTES_PER_WORD, manifest.DEFAULT_BYTES_PER_WORD);
const wordsPerGroup = memoryInspectorConfiguration.get<number>(manifest.CONFIG_WORDS_PER_GROUP, manifest.DEFAULT_WORDS_PER_GROUP);
const bytesPerMau = memoryInspectorConfiguration.get<number>(manifest.CONFIG_BYTES_PER_MAU, manifest.DEFAULT_BYTES_PER_MAU);
const mausPerGroup = memoryInspectorConfiguration.get<number>(manifest.CONFIG_MAUS_PER_GROUP, manifest.DEFAULT_MAUS_PER_GROUP);
const groupsPerRow = memoryInspectorConfiguration.get<manifest.GroupsPerRowOption>(manifest.CONFIG_GROUPS_PER_ROW, manifest.DEFAULT_GROUPS_PER_ROW);
const endianness = memoryInspectorConfiguration.get<Endianness>(manifest.CONFIG_ENDIANNESS, manifest.DEFAULT_ENDIANNESS);
const scrollingBehavior = memoryInspectorConfiguration.get<ScrollingBehavior>(manifest.CONFIG_SCROLLING_BEHAVIOR, manifest.DEFAULT_SCROLLING_BEHAVIOR);
Expand All @@ -267,7 +267,7 @@ export class MemoryWebview implements vscode.CustomReadonlyEditorProvider {
const addressRadix = memoryInspectorConfiguration.get<number>(manifest.CONFIG_ADDRESS_RADIX, manifest.DEFAULT_ADDRESS_RADIX);
const showRadixPrefix = memoryInspectorConfiguration.get<boolean>(manifest.CONFIG_SHOW_RADIX_PREFIX, manifest.DEFAULT_SHOW_RADIX_PREFIX);
return {
messageParticipant, title, bytesPerWord, wordsPerGroup, groupsPerRow,
messageParticipant, title, bytesPerMau, mausPerGroup, groupsPerRow,
endianness, scrollingBehavior, visibleColumns, addressPadding, addressRadix, showRadixPrefix
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/webview/columns/ascii-column.ts
Expand Up @@ -33,9 +33,9 @@ export class AsciiColumn implements ColumnContribution {
readonly label = 'ASCII';
readonly priority = 3;
render(range: BigIntMemoryRange, memory: Memory, options: TableRenderOptions): ReactNode {
const wordSize = options.bytesPerWord * 8;
const startOffset = toOffset(memory.address, range.startAddress, wordSize);
const endOffset = toOffset(memory.address, range.endAddress, wordSize);
const mauSize = options.bytesPerMau * 8;
const startOffset = toOffset(memory.address, range.startAddress, mauSize);
const endOffset = toOffset(memory.address, range.endAddress, mauSize);
let result = '';
for (let i = startOffset; i < endOffset; i++) {
result += getASCIIForSingleByte(memory.bytes[i]);
Expand Down
38 changes: 19 additions & 19 deletions src/webview/columns/data-column.tsx
Expand Up @@ -62,27 +62,27 @@ export class EditableDataColumnRow extends React.Component<EditableDataColumnRow
protected renderGroups(): React.ReactNode {
const { range, options, memory } = this.props;
const groups = [];
let words: React.ReactNode[] = [];
let maus: React.ReactNode[] = [];
let address = range.startAddress;
let groupStartAddress = address;
while (address < range.endAddress) {
words.push(this.renderWord(memory, options, address));
maus.push(this.renderMau(memory, options, address));
const next = address + 1n;
if (words.length % options.wordsPerGroup === 0) {
this.applyEndianness(words, options);
if (maus.length % options.mausPerGroup === 0) {
this.applyEndianness(maus, options);
const isLast = next >= range.endAddress;
const style: React.CSSProperties | undefined = isLast ? undefined : DataColumn.Styles.byteGroupStyle;
groups.push(this.renderGroup(words, groupStartAddress, next, style));
groups.push(this.renderGroup(maus, groupStartAddress, next, style));
groupStartAddress = next;
words = [];
maus = [];
}
address = next;
}
if (words.length) { groups.push(this.renderGroup(words, groupStartAddress, range.endAddress)); }
if (maus.length) { groups.push(this.renderGroup(maus, groupStartAddress, range.endAddress)); }
return groups;
}

protected renderGroup(words: React.ReactNode, startAddress: bigint, endAddress: bigint, style?: React.CSSProperties): React.ReactNode {
protected renderGroup(maus: React.ReactNode, startAddress: bigint, endAddress: bigint, style?: React.CSSProperties): React.ReactNode {
return <span
className='byte-group hoverable'
data-column='data'
Expand All @@ -91,24 +91,24 @@ export class EditableDataColumnRow extends React.Component<EditableDataColumnRow
key={startAddress.toString(16)}
onDoubleClick={this.setGroupEdit}
>
{words}
{maus}
</span>;
}

protected renderWord(memory: Memory, options: TableRenderOptions, currentAddress: bigint): React.ReactNode {
protected renderMau(memory: Memory, options: TableRenderOptions, currentAddress: bigint): React.ReactNode {
if (currentAddress === this.state.editedRange?.startAddress) {
return this.renderEditingGroup(this.state.editedRange);
} else if (this.state.editedRange && isWithin(currentAddress, this.state.editedRange)) {
return;
}
const initialOffset = toOffset(memory.address, currentAddress, options.bytesPerWord * 8);
const finalOffset = initialOffset + options.bytesPerWord;
const initialOffset = toOffset(memory.address, currentAddress, options.bytesPerMau * 8);
const finalOffset = initialOffset + options.bytesPerMau;
const bytes: React.ReactNode[] = [];
for (let i = initialOffset; i < finalOffset; i++) {
bytes.push(this.renderEightBits(memory, currentAddress, i));
}
this.applyEndianness(bytes, options);
return <span className='single-word' data-address={currentAddress.toString()} key={currentAddress.toString(16)}>{bytes}</span>;
return <span className='single-mau' data-address={currentAddress.toString()} key={currentAddress.toString(16)}>{bytes}</span>;
}

protected renderEightBits(memory: Memory, currentAddress: bigint, offset: number): React.ReactNode {
Expand Down Expand Up @@ -163,9 +163,9 @@ export class EditableDataColumnRow extends React.Component<EditableDataColumnRow
}

protected createEditingGroupDefaultValue(editedRange: BigIntMemoryRange): string {
const bitsPerWord = this.props.options.bytesPerWord * 8;
const startOffset = toOffset(this.props.memory.address, editedRange.startAddress, bitsPerWord);
const numBytes = toOffset(editedRange.startAddress, editedRange.endAddress, bitsPerWord);
const bitsPerMau = this.props.options.bytesPerMau * 8;
const startOffset = toOffset(this.props.memory.address, editedRange.startAddress, bitsPerMau);
const numBytes = toOffset(editedRange.startAddress, editedRange.endAddress, bitsPerMau);

const area = Array.from(this.props.memory.bytes.slice(startOffset, startOffset + numBytes));
this.applyEndianness(area, this.props.options);
Expand Down Expand Up @@ -219,7 +219,7 @@ export class EditableDataColumnRow extends React.Component<EditableDataColumnRow
}

protected processData(data: string, editedRange: BigIntMemoryRange): string {
const characters = toOffset(editedRange.startAddress, editedRange.endAddress, this.props.options.bytesPerWord * 8) * 2;
const characters = toOffset(editedRange.startAddress, editedRange.endAddress, this.props.options.bytesPerMau * 8) * 2;
// Revert Endianness
if (this.props.options.endianness === Endianness.Little) {
const chunks = data.padStart(characters, '0').match(/.{2}/g) || [];
Expand Down Expand Up @@ -257,8 +257,8 @@ export namespace DataColumn {
const charactersWidth = Math.round((characterWidthInContainer(element, '0') + Number.EPSILON) * 100) / 100;
const groupWidth = charactersWidth
* 2 // characters per byte
* options.bytesPerWord
* options.wordsPerGroup
* options.bytesPerMau
* options.mausPerGroup
+ Styles.MARGIN_RIGHT_PX;
// Accommodate the non-existent margin of the final element.
const maxGroups = Math.max((columnWidth + Styles.MARGIN_RIGHT_PX) / groupWidth, 1);
Expand Down
32 changes: 14 additions & 18 deletions src/webview/components/memory-table.tsx
Expand Up @@ -142,8 +142,8 @@ interface MemoryTableProps extends TableRenderOptions, MemoryDisplayConfiguratio

interface MemoryRowListOptions {
numRows: number;
wordsPerRow: number;
bigWordsPerRow: bigint;
mausPerRow: number;
bigMausPerRow: bigint;
}

interface MemoryRowData {
Expand All @@ -165,14 +165,14 @@ interface MemoryTableState {
hoverContent: React.ReactNode;
}

export type MemorySizeOptions = Pick<MemoryTableProps, 'bytesPerWord' | 'wordsPerGroup'> & { groupsPerRow: number };
export type MemorySizeOptions = Pick<MemoryTableProps, 'bytesPerMau' | 'mausPerGroup'> & { groupsPerRow: number };
export namespace MemorySizeOptions {
export function create(props: MemoryTableProps, state: MemoryTableState): MemorySizeOptions {
const { bytesPerWord, wordsPerGroup } = props;
const { bytesPerMau, mausPerGroup } = props;
return {
bytesPerWord,
bytesPerMau,
groupsPerRow: tryToNumber(props.groupsPerRow) ?? state.groupsPerRowToRender,
wordsPerGroup
mausPerGroup
};
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ export class MemoryTable extends React.PureComponent<MemoryTableProps, MemoryTab
|| prevProps.activeReadArguments.offset !== this.props.activeReadArguments.offset
|| prevProps.activeReadArguments.count !== this.props.activeReadArguments.count;

const hasOptionsChanged = prevProps.wordsPerGroup !== this.props.wordsPerGroup || prevProps.groupsPerRow !== this.props.groupsPerRow;
const hasOptionsChanged = prevProps.mausPerGroup !== this.props.mausPerGroup || prevProps.groupsPerRow !== this.props.groupsPerRow;

// Reset selection
const selection = this.state.selection;
Expand Down Expand Up @@ -388,7 +388,7 @@ export class MemoryTable extends React.PureComponent<MemoryTableProps, MemoryTab
if (!this.isLoading && this.props.memory !== undefined) {
const memorySizeOptions = MemorySizeOptions.create(this.props, this.state);
const options = this.createMemoryRowListOptions(this.props.memory, memorySizeOptions);
const newCount = this.props.activeReadArguments.count + options.wordsPerRow * MemoryTable.renderableRowsAtOnceCountForWrapper(this.datatableWrapper);
const newCount = this.props.activeReadArguments.count + options.mausPerRow * MemoryTable.renderableRowsAtOnceCountForWrapper(this.datatableWrapper);
this.props.fetchMemory({ count: newCount });
}
}
Expand Down Expand Up @@ -510,30 +510,26 @@ export class MemoryTable extends React.PureComponent<MemoryTableProps, MemoryTab
protected createTableRows = memoize((memory: Memory, options: MemoryRowListOptions): MemoryRowData[] => {
const rows: MemoryRowData[] = [];
for (let i = 0; i < options.numRows; i++) {
const startAddress = memory.address + options.bigWordsPerRow * BigInt(i);
const startAddress = memory.address + options.bigMausPerRow * BigInt(i);
rows.push(this.createMemoryRow(i, startAddress, options));
}

return rows;
}, isDeepEqual);

protected createMemoryRowListOptions(memory: Memory, options: MemorySizeOptions): MemoryRowListOptions {
const wordsPerRow = options.wordsPerGroup * options.groupsPerRow;
const numRows = Math.ceil((memory.bytes.length) / (wordsPerRow * options.bytesPerWord));
const bigWordsPerRow = BigInt(wordsPerRow);
const mausPerRow = options.mausPerGroup * options.groupsPerRow;
const numRows = Math.ceil((memory.bytes.length) / (mausPerRow * options.bytesPerMau));
const bigMausPerRow = BigInt(mausPerRow);

return {
numRows,
wordsPerRow,
bigWordsPerRow
};
return { numRows, mausPerRow, bigMausPerRow };
};

protected createMemoryRow(rowIndex: number, startAddress: bigint, memoryTableOptions: MemoryRowListOptions): MemoryRowData {
return {
rowIndex,
startAddress,
endAddress: startAddress + memoryTableOptions.bigWordsPerRow
endAddress: startAddress + memoryTableOptions.bigMausPerRow
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/webview/components/memory-widget.tsx
Expand Up @@ -87,8 +87,8 @@ export class MemoryWidget extends React.Component<MemoryWidgetProps, MemoryWidge
configuredReadArguments={this.props.configuredReadArguments}
activeReadArguments={this.props.activeReadArguments}
endianness={this.props.endianness}
bytesPerWord={this.props.bytesPerWord}
wordsPerGroup={this.props.wordsPerGroup}
bytesPerMau={this.props.bytesPerMau}
mausPerGroup={this.props.mausPerGroup}
groupsPerRow={this.props.groupsPerRow}
updateMemoryState={this.props.updateMemoryState}
updateRenderOptions={this.props.updateMemoryDisplayConfiguration}
Expand All @@ -112,8 +112,8 @@ export class MemoryWidget extends React.Component<MemoryWidgetProps, MemoryWidge
columnOptions={this.props.columns.filter(candidate => candidate.active)}
memory={this.props.memory}
endianness={this.props.endianness}
bytesPerWord={this.props.bytesPerWord}
wordsPerGroup={this.props.wordsPerGroup}
bytesPerMau={this.props.bytesPerMau}
mausPerGroup={this.props.mausPerGroup}
groupsPerRow={this.props.groupsPerRow}
effectiveAddressLength={this.props.effectiveAddressLength}
fetchMemory={this.props.fetchMemory}
Expand Down

0 comments on commit e92b909

Please sign in to comment.