Operating System - HP-UX
1827476 Members
2050 Online
109965 Solutions
New Discussion

Re: adb to debug core file

 
Vincenzo Capasso
Frequent Advisor

adb to debug core file

Hi All,

I need to debug a core file with adb command, but I have problem to understand the right way to run it.

Can someone help me to understand the correct syntax to work fine this command??

Thanks and best regards,
Vinc.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: adb to debug core file

Compared to gdb, adb is very limited so if you can, use gdb. Life is also easier if you can compile with the -g flag to include symbol/debugger data in the object file. In either debugger, the starting point is the stacktrace.

Invoke adb as "adb myexe core"
$c
$c

$c -- stack trace; the 1st listed function is where the error occured.

$q -> exits adb
$h -> help

Gdb can zero in on the exact line of source code if supplied with -g and the source is available. Again, adb is rather limited.



If it ain't broke, I can fix that.
Vincenzo Capasso
Frequent Advisor

Re: adb to debug core file

Hi,

I try with gdb, but everytime I run it, the follow message show me on prompt:
"warning: Unknown symbols for 'core'; use the 'symbol-file' command."

Where I wrong ??

The syntax that I use is the follow:
/opt/OV/contrib/OpC/gdb -core=core

Can U help me??

Thanks in advance,
Vinc.
A. Clay Stephenson
Acclaimed Contributor

Re: adb to debug core file

cd to the directory containing the core file.
gdb /xxx/yyy/zzz/myexethatcrashed core

gdb will immediately do a stack trace with no command needed.

By the way, I suspect the gdb version supplied as part of NNM/VP/O is rather old so you might be well advised to get a newer version.

It's probably a good idea to play a little before doing the real thing. I would create a program that will crash and debug it:

The following should get you started:

#include

int badboy()
{
char s0[32],s1[4];
int i = 0;

for (i = 0; i < 1000000; ++i)
{
s0[i] = 'x';
s1[i - 100000] = s0[i + 100000];
}
return(0);
} /* badboy */

int main()
{
int cc = 0;

cc = badboy();
(void) printf("cc = %d\n",cc);
return(cc);
} /* main */

Compile it like this:

cc -g bad.c -o bad
next execute bad (it should immediate dump core)
gdb bad core

q (quit gdb)

(-g is not supported unless you have a development compiler (aCC or ANCI/C) but the Bundled compiler will simply ignore it. -g adds debugging data to the object.

If it ain't broke, I can fix that.