Forum Discussion
Altera_Forum
Honored Contributor
16 years agoDebug user space application with MMU
I am trying to use the gdbserver as described here:
http://nioswiki.com/linux/debug_user_space At some point, this was working, but sometimes it wouldn't work and now I haven't had it working for a while. The application and gdb dies on a crash and doesn't let me debug. This isn't just this particular crash, I've had this happen with almost every crash while developing. On the server: --- Quote Start --- root:/> gdbserver localhost:9999 myprogram Process myprogram created; pid = 50 Listening on port 9999 Remote debugging from host 192.168.100.28 <program output...> Child terminated with signal = b Child terminated with signal = 0xb (SIGSEGV) GDBserver exiting root:/> --- Quote End --- On the client: --- Quote Start --- Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb) backtrace No stack. --- Quote End --- Any advice? Also, the wiki says "we will add the gdbserver source to uclinux-dist later" -- is there any progress on this? Could the gdbserver currently in uclinux-dist work?16 Replies
- Altera_Forum
Honored Contributor
Debugging after a crash might be difficult. Are you sure it's just with NIOS ?
I just read a good book about working with gdb: the art of debugging with gdb, ddd and eclipse: for professionals and students (http://www.amazon.de/art-debugging-gdb-eclipse-professionals/dp/1593271743/ref=sr_1_3?ie=utf8&s=books-intl-de&qid=1266605020&sr=8-3) by Norman Matloff und P. J. Salzma -Michael - Altera_Forum
Honored Contributor
In the cases when I could run the program on my PC, I could debug the crash using gdb, so it is something with the NIOS gdbserver provided with the mmu toolchain.
- Altera_Forum
Honored Contributor
Just wanted to add that breakpoints don't work either, with the same result, the program just terminates:
Program terminated with signal SIGTRAP, Trace/breakpoint trap. Not having the debugger available is really eating up a lot of time :-( - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- Just wanted to add that breakpoints don't work either, with the same result, the program just terminates: --- Quote End --- When the debuggee program crashes, the 'gdbserver' will terminate itself. So please get debuggee's 'coredump' file by setting 'ulimit -c ***', for example in your 'bash', And copy it to your PC, and read it by Nios's 'gdb' with the command 'core-file core'. I think that you can reach the position which causes the crash. Then set a breakpoint there and... And don't forget to compile your program with the option switch '-O0'. --- Quote Start --- Program terminated with signal SIGTRAP, Trace/breakpoint trap. --- Quote End --- SIGTRAP? Really? Kazu - Altera_Forum
Honored Contributor
I realized when somebody mentioned it in the other thread on this topic (http://www.alteraforum.com/forum/showthread.php?t=19322) that I am not actually quite following the directions there.
I am not using
but instead the libs in the romfs:set solib-absolute-prefix ~/nios2-linux/toolchain-mmu/x86-linux2/nios2-wrs-linux-gnu/libc
Since all the libraries I am using need to be on the device for the application to run, I think this should not make a difference.set solib-absolute-prefix /data/nios/nios2-linux/uClinux-dist/romfs/ - Altera_Forum
Honored Contributor
--- Quote Start --- When the debuggee program crashes, the 'gdbserver' will terminate itself. So please get debuggee's 'coredump' file by setting 'ulimit -c ***', for example in your 'bash', And copy it to your PC, and read it by Nios's 'gdb' with the command 'core-file core'. I think that you can reach the position which causes the crash. Then set a breakpoint there and... And don't forget to compile your program with the option switch '-O0'. --- Quote End --- I am trying to use a core file now. I am running `nios2-linux-gnu-gdb mynios2program`, with set solib-absolute-prefix /data/nios/nios2-linux/uClinux-dist/romfs/ in .gdbinit. Then core-file mycorefile, but all I can get is:warning: Couldn't find general-purpose registers in core file. # 0 0x00000000 in ?? () - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- I am trying to use a core file now. I am running `nios2-linux-gnu-gdb mynios2program`, with set solib-absolute-prefix /data/nios/nios2-linux/uClinux-dist/romfs/ in .gdbinit. Then core-file mycorefile, but all I can get is:
--- Quote End --- Do you have enough space for the core dump file? For example, ulimit -c unlimiled Kazuwarning: Couldn't find general-purpose registers in core file.# 0 0x00000000 in ?? () - Altera_Forum
Honored Contributor
Hi,
I am debugging a user application and I have some doubts, and maby someone can answer my questions. My application produces a segmentation fault, I suppose that a segmentation fault provoke a core dumped, is this true? If I want to have core dumps in uClinux, as kazuyasu commented in last posts I have to insert the command : ulimit -c unlimited. But where is it in the configuration kernel?, I haven't found. And my last question is, is the core file created in /proc/sys/kernel?, if not where is it found? Many thanks - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- My application produces a segmentation fault, I suppose that a segmentation fault provoke a core dumped, is this true? --- Quote End --- Yes, but the dumping is limited by 'core file size', and it's 0 by default. --- Quote Start --- I have to insert the command : ulimit -c unlimited. But where is it in the configuration kernel?, I haven't found. --- Quote End --- 'ulimit -c ***' that I mentioned before is an internal command of 'bash' and you don't need to configure your kernel in general. See also http://linux.die.net/man/3/ulimit --- Quote Start --- And my last question is, is the core file created in /proc/sys/kernel?, if not where is it found? --- Quote End --- In general, the core dump file is made in your 'current working directory'. http://linux.die.net/man/5/core Kazu - Altera_Forum
Honored Contributor
Hi Kazu,
I have changed the shell to ash and now I can see the core file. Many thanks