Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions assembly/api-debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ export function getPageDump(index: u32): Uint8Array {
return page;
}

export function getMemory(address: u32, length: u32): Uint8Array {
if (interpreter === null) {
return new Uint8Array(0);
}
const int = <Interpreter>interpreter;
const result = new Uint8Array(length);
const fault = int.memory.bytesRead(address, result);
if (fault.isFault) {
return new Uint8Array(0);
}
return result;
}
Comment thread
tomusdrw marked this conversation as resolved.

export function setMemory(address: u32, data: Uint8Array): void {
if (interpreter === null) {
return;
Expand Down
4 changes: 1 addition & 3 deletions assembly/api-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function executeProgram(int: Interpreter, logs: boolean = false): VmOutput {
if (logs) console.log(`REGISTERS = ${int.registers.join(", ")} (final)`);
if (logs) console.log(`REGISTERS = ${int.registers.map((x: u64) => `0x${x.toString(16)}`).join(", ")} (final)`);
if (logs) console.log(`Finished with status: ${int.status}`);
if (logs) console.log(`Exit code: ${int.exitCode}`);
break;
}

Expand Down Expand Up @@ -182,8 +183,5 @@ function executeProgram(int: Interpreter, logs: boolean = false): VmOutput {
output.memory = getOutputChunks(int.memory);
output.exitCode = int.exitCode;

// release used pages back
int.memory.free();

Comment thread
tomusdrw marked this conversation as resolved.
return output;
}
Loading