Skip to contentSkip to conversation

Debugging guest OS

Qemu-devel Mariano Wahlmann 4 participants 7 messages Jun 2, 2005

lore
Share & tools
lore
#0 lore raw

I want to know, if it's posible to debug an guest OS like bochs, i mean disassemble current instruction, step by step running, possibility of change registers values, etc. I try to use GDB, but i think this is for debbuging qemu itself. any clues?

thanks

#1 lore raw
Quoted 4 lines · Mariano Wahlmann

I want to know, if it's posible to debug an guest OS like bochs, i mean disassemble current instruction, step by step running, possibility of change registers values, etc. I try to use GDB, but i think this is for debbuging qemu itself.

You can use gdb on the guest if you invoke qemu with -s.

Signature · 3 lines
Ben Pfaff 
email: [email protected]
web: http://benpfaff.org
#2 lore raw
Quoted 4 lines · Ben Pfaff

Mariano Wahlmann <[email protected]> writes:

Quoted 10 lines
Quoted 6 lines

I want to know, if it's posible to debug an guest OS like bochs, i mean disassemble current instruction, step by step running, possibility of change registers values, etc. I try to use GDB, but i think this is for debbuging qemu itself.

You can use gdb on the guest if you invoke qemu with -s.

that's right, thanks
but in order to disassemble i have to do "display /i $cs * 16 + $eip", this is for real mode, what is the syntaxis for protected mode? is there any varible that contains a pointer to current virtual address of the next instruction.

Signature · 7 lines
________________________________________________________
Mariano Agustín Wahlmann
Administrador de Red
Facultad de Agronomía - Buenos Aires - Argentina
Te.: (+54 11) 4524-8000 int.8108
email: mailto:[email protected]
www: http://www.agro.uba.ar
#3 lore raw
Quoted 4 lines · Mariano Wahlmann

but in order to disassemble i have to do "display /i $cs * 16 + $eip", this is for real mode, what is the syntaxis for protected mode? is there any varible that contains a pointer to current virtual address of the next instruction.

Usually it will just be $eip

Technically you need to add the current code segment offset, but most (all?) x86 OS use a flat memory model, so this is zero.

Paul

#4 lore raw
Quoted 10 lines · Paul Brook
Quoted 6 lines · Mariano Wahlmann

but in order to disassemble i have to do "display /i $cs * 16 + $eip", this is for real mode, what is the syntaxis for protected mode? is there any varible that contains a pointer to current virtual address of the next instruction.

Quoted 8 lines

Usually it will just be $eip

Technically you need to add the current code segment offset, but most (all?) x86 OS use a flat memory model, so this is zero.

Paul

i think this is not true, you can have so many desciptors on gdt table, not all start at has 0 as base address. The way that i find to do that, is to look in "info register" on qemu monitor, and look what is the current base for cs and add it to eip. This is a very uneasy way.

Quoted 7 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Signature · 7 lines
________________________________________________________
Mariano Agustín Wahlmann
Administrador de Red
Facultad de Agronomía - Buenos Aires - Argentina
Te.: (+54 11) 4524-8000 int.8108
email: mailto:[email protected]
www: http://www.agro.uba.ar
#5 lore raw
Quoted 12 lines · Mariano Wahlmann
Quoted 11 lines · Paul Brook
Quoted 4 lines · Mariano Wahlmann

but in order to disassemble i have to do "display /i $cs * 16 + $eip", this is for real mode, what is the syntaxis for protected mode? is there any varible that contains a pointer to current virtual address of the next instruction.

Usually it will just be $eip

Technically you need to add the current code segment offset, but most (all?) x86 OS use a flat memory model, so this is zero.

Quoted 7 lines
Quoted 1 line

Paul

i think this is not true, you can have so many desciptors on gdt table, not all start at has 0 as base address.
The way that i find to do that, is to look in "info register" on qemu monitor, and look what is the current base for cs and add it to eip. This is a very uneasy way.

Right, that's why I said "usually" and "most".

Paul

#6 lore raw
In reply to Mariano Wahlmann
Quoted 15 lines · Mariano Wahlmann
Quoted 11 lines · Ben Pfaff
Quoted 5 lines · Mariano Wahlmann

I want to know, if it's posible to debug an guest OS like bochs, i mean disassemble current instruction, step by step running, possibility of change registers values, etc. I try to use GDB, but i think this is for debbuging qemu itself.

Quoted 6 lines
Quoted 3 lines

You can use gdb on the guest if you invoke qemu with -s.

that's right, thanks
but in order to disassemble i have to do "display /i $cs * 16 + $eip", this is for real mode, what is the syntaxis for protected mode? is there any varible that contains a pointer to current virtual address of the next instruction.

In QEMU you have $pc which gives the correct value.

Fabrice.