v86 icon indicating copy to clipboard operation
v86 copied to clipboard

Implement single stepping

Open darkf opened this issue 7 years ago • 2 comments

I'd like to construct an x86 emulator+debugger using V86, but it does not support single-stepping, which is quite necessary for it.

darkf avatar Jul 26 '16 03:07 darkf

Here's something to play with:

> cpu = new CPU
CPU {memory_size: 0, segment_is_null: Array[0], segment_offsets: Array[0], segment_limits: Array[0], tlb_data: Int32Array[1048576]…}
> cpu.create_memory(1024 * 1024 * 16)
undefined
> cpu.memory.mem8[0] = 0x40; // inc ax
64
> cpu.instruction_pointer
0
> cpu.reg32s[reg_eax]
0
> cpu.cycle()
undefined
> cpu.reg32s[reg_eax]
1
> cpu.instruction_pointer
1

Use this script to load the required files. None of this is stable now, we'll need to think how to expose internals.

We might need to write some functions similar to this (in order to make sure the names don't get mangled and we can change reg32s at a later point):

/** @export */
CPU.prototype.get_reg32s = function(n)
{
    return this.reg32s[n];
};

copy avatar Jul 26 '16 20:07 copy

I'm trying to follow your snippet on Node. I can't get it to work.

When doing this:

var CPU = new require('./v86/build/libv86.js').CPU();
CPU.mem8[0] = 0x40;
CPU.cycle();

It throws an exception like:

TypeError: this.memory_map_read8[(a >>> MMAP_BLOCK_BITS)] is not a function
    at CPU.mmap_read8 (libv86.js:254:947)
    at CPU.read8 (libv86.js:256:331)
    at CPU.read_imm8 (502:243)

Any idea on what could I be missing?

almosnow avatar Jun 29 '17 19:06 almosnow