Month: February 2013

qemu single step will fail if current EIP hit a breakpoint

I use the following code to insert a breakpoint in physical address 0x1600000

CPUArchState *cpu = first_cpu;
hwaddr addr;
sscanf(command + 2, "%ld", &addr);
int err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL );</pre>

qemu successfully hit the breakpoint and stop, then i try to single-step by the following code:

CPUArchState *cpu = first_cpu;
cpu_single_step(cpu, sstep_flags);
vm_start();

Nothing happened, the EIP still stay in 0x1600000, but if i delete the breakpoint, the single step just work again. Am I missed something?

read count : 622

when you debugging qemu, it will keep firing SIGUSR1 so gdb will always catched in some breakpooints that are not defined by you

when you debugging qemu, it will keep firing SIGUSR1 so gdb will always catched in some breakpooints that are not defined by you, to turn off the SIGUSR1, you have to:

(gdb) info signal SIGUSR1

Signal        Stop      Print   Pass to program Description
SIGUSR1       Yes       Yes     Yes             User defined signal 1

And if deemed to not be of interest, where you just want your program to continue without prompting or spamming, something like the following does the trick:

(gdb) handle SIGUSR1 noprint nostop

Signal        Stop      Print   Pass to program Description
SIGUSR1       No        No      Yes             User defined signal 1

read count : 1185

compile 64 bits newlib on 64 bits linux host

If you compile newlib in x86-64 host and want to have 64-bits newlib, you have to add “–disable-multilib“, otherwise you will get the following error:

x86_64-peter-elf-cc -B/root/workspace2/newlib-1.<wbr />19.0build/x86_64-peter-elf/32/<wbr />newlib/ -isystem /root/workspace2/newlib-1.19.<wbr />0build/x86_64-peter-elf/32/<wbr />newlib/targ-include -isystem /root/workspace2/newlib-1.19.<wbr />0/newlib/libc/include -B/root/workspace2/newlib-1.<wbr />19.0build/x86_64-peter-elf/32/<wbr />libgloss/x86_64 -L/root/workspace2/newlib-1.<wbr />19.0build/x86_64-peter-elf/32/<wbr />libgloss/libnosys -L/root/workspace2/newlib-1.<wbr />19.0/libgloss/x86_64  -m32 -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.19.0\" -DPACKAGE_STRING=\"newlib\ 1.19.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../../../newlib-<wbr />1.19.0/newlib/libc/machine/<wbr />x86_64 -DMISSING_SYSCALL_NAMES -fno-builtin     -DMISSING_SYSCALL_NAMES -fno-builtin   -O2 -g  -m32 -c -o lib_a-setjmp.o `test -f 'setjmp.S' || echo '../../../../../../../newlib-<wbr />1.19.0/newlib/libc/machine/<wbr />x86_64/'`setjmp.S
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S: Assembler messages:
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:25: Error: bad register name `%rbx'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:26: Error: bad register name `%rbp'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:27: Error: bad register name `%r12'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:28: Error: bad register name `%r13'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:29: Error: bad register name `%r14'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:30: Error: bad register name `%r15'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:31: Error: bad register name `%rsp)'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:32: Error: bad register name `%rax'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:33: Error: bad register name `%rsp)'
../../../../../../../newlib-1.<wbr />19.0/newlib/libc/machine/x86_<wbr />64/setjmp.S:34: Error: bad register name `%rax'

read count : 761