backtrace: use backtrace_symbols() only if we have backtrace() and dladdr() fails
This commit is contained in:
@@ -382,9 +382,7 @@ METHOD(backtrace_t, log_, void,
|
|||||||
{
|
{
|
||||||
#if defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H)
|
#if defined(HAVE_BACKTRACE) || defined(HAVE_LIBUNWIND_H)
|
||||||
size_t i;
|
size_t i;
|
||||||
char **strings;
|
char **strings = NULL;
|
||||||
|
|
||||||
strings = backtrace_symbols(this->frames, this->frame_count);
|
|
||||||
|
|
||||||
println(file, " dumping %d stack frame addresses:", this->frame_count);
|
println(file, " dumping %d stack frame addresses:", this->frame_count);
|
||||||
for (i = 0; i < this->frame_count; i++)
|
for (i = 0; i < this->frame_count; i++)
|
||||||
@@ -424,10 +422,23 @@ METHOD(backtrace_t, log_, void,
|
|||||||
else
|
else
|
||||||
#endif /* HAVE_DLADDR */
|
#endif /* HAVE_DLADDR */
|
||||||
{
|
{
|
||||||
println(file, " %s", strings[i]);
|
#ifdef HAVE_BACKTRACE
|
||||||
|
if (!strings)
|
||||||
|
{
|
||||||
|
strings = backtrace_symbols(this->frames, this->frame_count);
|
||||||
|
}
|
||||||
|
if (strings)
|
||||||
|
{
|
||||||
|
println(file, " %s", strings[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* HAVE_BACKTRACE */
|
||||||
|
{
|
||||||
|
println(file, " %p", this->frames[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (strings);
|
free(strings);
|
||||||
#else /* !HAVE_BACKTRACE && !HAVE_LIBUNWIND_H */
|
#else /* !HAVE_BACKTRACE && !HAVE_LIBUNWIND_H */
|
||||||
println(file, "no support for backtrace()/libunwind");
|
println(file, "no support for backtrace()/libunwind");
|
||||||
#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H */
|
#endif /* HAVE_BACKTRACE/HAVE_LIBUNWIND_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user