Okay, I've added a framework for a debugger.
It's not usable yet but I think it only
requires a few minor changes in order to work
just fine !!!
Glitches:
- GDB works by inserting int3 instructions into
the code. However, right now when an int3
occurs it is redirected back into the VM.
At the point where allocating interrupts
is implemented, adding a few lines to the
code should make debugging work just fine.
- There's one bug in it right now that I have not
succeeded in solving. However, I attribute
this to my complete lack of experience with
network programming, so it wouldn't surprise
me if somebody here can solve it in no time.
The problem can be reproduced as follows:
start up the VM with the cooperative kernel,
with the debugger loaded. Now create a
connection with GDB, and press c<enter>.
The cooperative kernel will now run.
Now, in GDB, press ctrl-c. The problem
is that for some reason, when the
debugger tries to read() from the socket
the read() function returns EINTR, which
makes the debugger get into an infinite
loop (redirect output to a file to see
this). The same thing happens when you
start up the preemptive kernel with the
debugger. What's wrong ? Why is it
doing EINTR ? And what do I do about it ?
Attached is a patch that adds the debugger
(and some other stuff too). The patch is
a patch on top of the tarball I previously
made for plugins. Have a look at
freemware/user/plugins/ice/README for
instructions.
PS, about AT&T syntax, Ulrich do you save
the actual opcode anywhere ? The problem
is that byte- and word/long- instructions
have separate opcodes, and as far as I can
see you lose this infomation when you call
decode(). I had a look at the objdump code,
they had in their instruction name table
separate names for, for instance,
addb and addw/l (which was called addS,
where the S was replaced by the correct
suffix later on).
-- Ramon
freemware-ice.diff.gz