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