I am trying to run a test program to see how gdb (backtrace) shows the call stack. I have the following program
#include<iostream>
#include<assert.h>
void fun2()
{
assert(0);
}
void fun1()
{
fun2();
}
int main()
{
fun1();
return 0;
}
And i do the following:
g++ -g dump.cpp -o out
./out
out: dump.cpp:16: void fun2(): Assertion `0' failed.
Abort (core dumped)
gdb out core.28149
(gdb) bt
No stack. //Why does it show no stack here
I was expecting it to show the call stack as :
fun2
fun1
main
Edit:
I edited the code and compiled as g++ -g -O0 dump.cpp -o out
But still i have No Stack
void fun2(int num)
{
int h=23;
if(h*num>100)
{
assert(0);
}
else
{
cout<<"Hello";
}
}
void fun1(int num)
{
{
fun2(num);
}
}
int main()
{
int num;
cin>>num;
fun1(num);
return 0;
}
Assembly code shows me this time the separate code for fun1,fun2(assert),main. But still I see No Stack in gdb
Reading symbols from /somepath here../tmp/out...done. "/somepath here/core.30117" is not a core dump: File format not recognized
Your core dump is somehow corrupted. Actually it was not loaded by gdb so typing bt
has no effect.
Try to examine it, these command should give you some info about core dump:
file core.28149
strings core.28149
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With