I need to find a point in my userland code that breaks my core
I have a large system that is causing my system to crash a lot. When I boot, I don't even have corundum. If I write to each line, they execute until my system goes down. I will find this evil code.
Can I write every line of source code in GDB to a file?
UPDATE:
ok i found a bug. It was disgusting. In the app I started, unset the system. After learning about checking the coredump with mdb and some gdb steppings, I found out that the system call causing the reset was not implemented. Updating the system to the latest kernel will fix my problem. Thanks to all.
MY LESSON:
make sure you know which process is calling the coredump. This is not always the one you started.
a source to share
Sounds like a tricky little problem.
I often try to eliminate as many potential suspects as possible by commenting out large chunks of code, tweaking the system not to run certain chunks (if it allows it), etc. It boils down to doing an ad-hoc binary search on the problem and is a surprisingly efficient way of approaching code breaking relatively quickly.
A potential problem with logging is that the log cannot get to disk before the system locks - if you don't get a kernel dump, you might not get the log.
When talking about kernel dumps, make sure you don't have a kernel size limit (man ulimit.)
You can try to get a list of all the functions in your code using objdump, do a little bit of processing, and generate a bunch of GDB trace statements for those functions - basically generating a GDB script automatically. If this turns out to be overkill, then doing a binary search in your code using tracepoints will also help you scale up the problem.
And don't panic. You are smarter than a mistake - you will find it.
a source to share
You cannot intelligently track every line of your source with GDB (too slow). Also, the system crash is most likely the result of a system call, and libc is probably doing the system call on your behalf. Even if you find that the application line caused the OS to crash, you still don't know anything.
You should start by figuring out which OS is crashing. For Linux, you can try the following approaches:
strace -fo trace.out /path/to/app
After a reboot, trace.out will contain the system calls that the application was making just before the crash. If you're lucky, you'll see the latest syscall-of-death, but I won't count on it.
Alternatively, try to reproduce the crash on Linux user mode or a kernel with KGDB compiled into.
They will tell you where the problem is in the kernel. Finding a suitable system call in your application will probably be trivial.
a source to share
Please clarify your problem: which part of the system is crashing?
Is this app? If so, which application? Is this an app that you wrote yourself? Is this an app you got elsewhere? Can you get a clean interrupt if using a debugger? Can you get a backtrace showing which functions are calling the section of code that is failing?
Is this a new driver? Is it based on an older driver? If so, what has changed? Is this the basis for a manufacturer's specification? Is this data sheet the latest and most correct?
Is it somewhere in the core? Which core?
What is OS? I am assuming this is Linux because you are using the GNU debugger. But of course this is not necessarily the case.
You say you don't have a coredump. Have you turned on the crowns on your machine? Most systems these days don't have built-in commands enabled by default.
As far as the GDB log output is concerned, you may have some success, but it depends on where the problem is, whether you have the correct output logged before the system crash. The recording is being written to disk. You may not catch him in time.
a source to share
I'm not familiar with this gdb way, but with windbg you can use a debugger attached to the kernel and remotely control the debugger over a serial cable (or FireWire) from a second debugger. I'm sure gdb has similar capabilities, I could quickly find some hints here: http://www.digipedia.pl/man/gdb.4.html
a source to share