Compile C as a running file for arm instructions
/usr/bin/arm-linux-gnueabi-g++ Hello.cpp
Cat Hello.cpp #include <stdio.h>void crash () { char *a=0; *a=0;} int main () { printf ("Hello world\n"); Crash (); printf ("After crash\n"); }
Execute the error directly. Because host is a Linux x86
$./a.out
-bash:./a.out:cannot Execute binary file
Need to be executed with qemu-arm, the result is expected
Qemu-arm-l/usr/arm-linux-gnueabi/a.out
Hello World
Qemu:uncaught Target signal (segmentation fault)-core dumped
Segmentation fault (core dumped)
Remote debugging (The key is to add the-G parameter, specify port as 1235)
qemu-arm-g 1235 -l/usr/arm-linux-gnueabi/a.out
GDB running with linux-x86 does not print symbol
(GDB) Target remote:1235remote debugging using:1235 (GDB) Ccontinuing.program received signal SIGSEGV, segmentation fault .0x00000000 in?? () (GDB) bt#0 0x00000000 in?? () Cannot access memory at address 0x0 (GDB) File/home/payne/hello/a.outa program is being debugged already. Is you sure the file of want to? (Y or N) yreading symbols from/home/payne/hello/a.out ... (No debugging symbols found) ... done. (GDB) bt#0
You suspect that you want to use arm GDB
See http://mazhijing.blog.51cto.com/215535/40759. Compiled arm GDB, after running to crash ()
Qemu-arm-l /usr/arm-linux-gnueabi/ /gdb (gdb) target remote:1235remote debugging Using:1235warning:can not P Arse XML target description; XML support is disabled at compile time0x40801c40 in?? (GDB) File/home/payne/hello/a.outa program is being debugged already. Is you sure the file of want to?(Y or N) yreading symbols from/home/payne/hello/a.out ... (No debugging symbols found) ... done. (GDB) Ccontinuing.program received signal SIGSEGV, segmentation fault.0x0000841e in Crash () () (GDB)
Conclusion:
Does arm's gdbserver, just can use arm's gdb?
GDB Remote Qemu-arm Debugging