|
|
 |
Using STWorkbench with STLinux
Debugging a corefile
|
|
The corefile shows an application's state when it terminated abnormally.
STWorkbench can be used as a remote debugger to find out the state of the application when it
terminated. When debugging a corefile, the following questions are raised.
- At what point did the application fail and why?
- How did the application get to that point?
- Is the culprit thread the only one executing that function?
- What were the variable and register values at the point of termination?
Create a project to dump a corefile
Click File > New > Project.... The New Project window appears.
Select C > C Project from the Wizards tree/list and click Next.
The C Project dialog appears.
Enter 'Crash' into the Project name text box
Select Executable from the Project types list
Select ST40 Linux GCC from the Toolchain list.
Click Finish. If a confirmation appears, click Yes.
Select File > Open File and navigate to the Crash folder.
Click OK
Click File > New > File. The New File window appears.
Enter 'crash.c' into the File name text box and click
Finish.
Ulimit limits the corefile dump size; the -c
switch limits it to 120000.
Edit root.bashrc and change the last line from
ulimit-c to ulimit unlimited.
Copy the following into the editor.
#include <stdio.h>
int main(void)
{
int *ptr = 0;
printf("About to crash and dump core\n");
printf("This is a really bad idea... %d\n", *ptr);
return 0;
}
|
|
|
- Select File > Save.
- Select Project > Build Project. The application is built.
If the console output is not displayed automatically, select HelloWorld
from the STWorkbench Navigator window.
Run the application to dump the corefile.
Debugging the application
From the STWorkbench Navigator window, select Crash
Click Run > Debug. The Create, manage, ans run configurations window appears.
From the Configurations list, select STLinux Corefile and click
New. A configuration called Crash is automatically created from the selected project,
showing the Main tab.
In the C/C++ Application field, click Browse to find
crash.c.
Select the Debugger tab.

Check that ST40 Linux GDB Debugger is selected in the Debugger list.
Enter the name or IP address of the target board into the Target name or IP address
text box.
Confirm the path to the corefile (/root/core).
Click Debug and the debugger stops at the point at which the application terminated.
If an alert is displayed to confirm a perspective switch, click Yes.
Note the value of ptr in the Variables view.
|