| 466 | ******************************************************************************/ |
| 467 | |
| 468 | static int __linux_stack_walkback(ucontext_t *context, unsigned maxframes, |
| 469 | void (*handler)(void *returnaddr, |
| 470 | void *handlerarg), |
| 471 | void *handlerarg) |
| 472 | { |
| 473 | unw_cursor_t cursor; |
| 474 | unsigned int i; |
| 475 | unw_word_t ip; |
| 476 | ucontext_t uc; |
| 477 | |
| 478 | if (context == 0) { |
| 479 | context = &uc; |
| 480 | unw_getcontext(context); |
| 481 | } |
| 482 | unw_init_local(&cursor, context); |
| 483 | for (i = 0; i < maxframes; ++i) { |
| 484 | unw_get_reg(&cursor, UNW_REG_IP, &ip); |
| 485 | (*handler)((void *)ip, handlerarg); |
| 486 | if (unw_step(&cursor) <= 0) { |
| 487 | break; |
| 488 | } |
| 489 | } |
| 490 | return 0; |
| 491 | } |
| 492 | #endif |
| 493 | |
| 494 | #if defined(__APPLE__) |