From b43b7750a6e08706aeb61d83ff1e1eb0c81c910b Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Fri, 4 Jun 2010 15:10:43 -0700 Subject: 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. --- jemalloc/src/prof.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index 88e8f44..6d6910e 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -239,16 +239,15 @@ 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 -- cgit v0.12