Dl_info info;
int res = dladdr(callstack[i], &info);
if(res!=0)
{
size_t length=0;
int status=0;
char* name = __cxxabiv1::__cxa_demangle(info.dli_sname,NULL,&length,&status);
printf (" : %s + %d %s\n", (0 == status) ? name : info.dli_sname, (unsigned int)((unsigned int)callstack[i] - (unsigned int)info.dli_saddr), info.dli_fname);
}
}
I get the name of the function and its arguments but I would like to have the source file's name and the line number of each address of the stack. I know that gdb can do this with "info line *addr", but I want to do it programmatically.
Is there a way to get the source name/line number from backtrace or is it possible to call gdb commands programmatically?
Thanks for any help,
Sam