Fix the libunwind version of prof_backtrace().

Fix the libunwind version of prof_backtrace() to set the backtrace depth
for all possible code paths.  This fixes the zero-length backtrace
problem when using libunwind.
This commit is contained in:
Jason Evans 2010-06-04 15:10:43 -07:00
parent 7013d10a9e
commit b43b7750a6

View File

@ -239,18 +239,17 @@ prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
} }
/* /*
* Iterate over stack frames until there are no more. Heap-allocate * Iterate over stack frames until there are no more, or until no space
* and iteratively grow a larger bt if necessary. * remains in bt.
*/ */
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *)&bt->vec[i]); unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *)&bt->vec[i]);
bt->len++;
err = unw_step(&cursor); err = unw_step(&cursor);
if (err <= 0) { if (err <= 0)
bt->len = i;
break; break;
} }
} }
}
#else #else
static void static void
prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max) prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)