ARGOBOTS
dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
|
Go to the documentation of this file.
8 #ifdef ABT_CONFIG_ENABLE_STACK_UNWIND
10 #include <libunwind.h>
11 struct unwind_stack_t {
14 static void ythread_unwind_stack(
void *arg);
126 if (p_prev_pool != p_next_pool) {
237 "stacksize : %" PRIu64
"\n",
241 #ifdef ABT_CONFIG_ENABLE_STACK_UNWIND
249 struct unwind_stack_t arg;
255 fprintf(p_os,
"not executed yet.\n");
258 fprintf(p_os,
"failed to unwind a stack.\n");
266 if (stacksize == 0 || p_stacktop == NULL) {
268 fprintf(p_os,
"no stack\n");
273 void *p_stack = (
void *)(((
char *)p_stacktop) - stacksize);
275 const size_t value_width = 8;
276 const int num_bytes =
sizeof(buffer);
277 static const char zero[
sizeof(buffer)];
280 for (i = 0; i < stacksize; i += num_bytes) {
281 if (stacksize >= i + num_bytes) {
282 memcpy(buffer, &((uint8_t *)p_stack)[i], num_bytes);
284 memset(buffer, 0, num_bytes);
285 memcpy(buffer, &((uint8_t *)p_stack)[i], stacksize - i);
289 if (!memcmp(zero, buffer,
sizeof(buffer))) {
299 fprintf(p_os,
"*\n");
305 #if SIZEOF_VOID_P == 8
306 fprintf(p_os,
"%016" PRIxPTR
":",
307 (uintptr_t)(&((uint8_t *)p_stack)[i]));
308 #elif SIZEOF_VOID_P == 4
309 fprintf(p_os,
"%08" PRIxPTR
":",
310 (uintptr_t)(&((uint8_t *)p_stack)[i]));
312 #error "unknown pointer size"
315 for (j = 0; j < num_bytes / value_width; j++) {
316 if (value_width == 8) {
317 uint64_t val = ((uint64_t *)buffer)[j];
318 fprintf(p_os,
" %016" PRIx64, val);
319 }
else if (value_width == 4) {
320 uint32_t val = ((uint32_t *)buffer)[j];
321 fprintf(p_os,
" %08" PRIx32, val);
322 }
else if (value_width == 2) {
323 uint16_t val = ((uint16_t *)buffer)[j];
324 fprintf(p_os,
" %04" PRIx16, val);
326 uint8_t val = ((uint8_t *)buffer)[j];
327 fprintf(p_os,
" %02" PRIx8, val);
329 if (j == (num_bytes / value_width) - 1)
341 #ifdef ABT_CONFIG_ENABLE_STACK_UNWIND
349 ret = unw_getcontext(&uc);
353 ret = unw_init_local(&cursor, &uc);
357 while (unw_step(&cursor) > 0 && level < 50) {
360 ret = unw_get_reg(&cursor, UNW_REG_IP, &ip);
364 ret = unw_get_reg(&cursor, UNW_REG_SP, &sp);
370 ret = unw_get_proc_name(&cursor, proc_name, 256, &offset);
375 fprintf(fp,
"#%d %p in %s () <+%d> (%s = %p)\n", level,
376 (
void *)((uintptr_t)ip), proc_name, (
int)offset,
377 unw_regname(UNW_REG_SP), (
void *)((uintptr_t)sp));
382 static void ythread_unwind_stack(
void *arg)
384 struct unwind_stack_t *p_arg = (
struct unwind_stack_t *)arg;
385 if (ythread_unwind_stack_impl(p_arg->fp) !=
ABT_SUCCESS) {
386 fprintf(p_arg->fp,
"libunwind error\n");
void ABTI_ythread_callback_suspend_join(void *arg)
void ABTI_ythread_callback_suspend_unlock(void *arg)
int ABT_bool
Boolean type.
static void ABTD_atomic_release_store_ythread_context_ptr(ABTD_ythread_context_atomic_ptr *ptr, ABTD_ythread_context *p_ctx)
#define ABT_POOL_CONTEXT_OP_THREAD_CREATE_TO
A flag that hints a push operation in a thread creation routine with a yield operation.
uint64_t ABT_pool_context
A pool context value.
static void * ABTD_ythread_context_get_stacktop(ABTD_ythread_context *p_ctx)
static ABTI_global * ABTI_global_get_global(void)
void ABTI_ythread_callback_suspend(void *arg)
void ABTI_ythread_callback_yield_user_yield(void *arg)
ABTU_no_sanitize_address void ABTI_ythread_print_stack(ABTI_global *p_global, ABTI_ythread *p_ythread, FILE *p_os)
void ABTI_ythread_callback_resume_exit_to(void *arg)
ABTD_ythread_context_atomic_ptr p_link
void ABTI_ythread_callback_resume_yield_to(void *arg)
ABT_thread_state
State of a work unit.
ABTI_sched * p_main_sched
@ ABT_THREAD_STATE_BLOCKED
void ABTI_ythread_callback_suspend_replace_sched(void *arg)
#define ABTI_SCHED_REQ_REPLACE
static ABT_bool ABTI_ythread_context_peek(ABTI_ythread *p_ythread, void(*f_peek)(void *), void *arg)
#define ABT_POOL_CONTEXT_OP_THREAD_REVIVE_TO
A flag that hints a push operation in a thread revival routine with a yield operation.
#define ABTI_THREAD_HANDLE_REQUEST_CANCELLED
void ABTI_ythread_callback_yield_loop(void *arg)
#define ABT_POOL_CONTEXT_OP_THREAD_YIELD_TO
A flag that hints a push operation in a thread yield-to routine.
static void ABTI_sched_set_request(ABTI_sched *p_sched, uint32_t req)
void ABTI_ythread_callback_yield_revive_to(void *arg)
#define ABT_SUCCESS
Error code: the routine returns successfully.
static int ABTD_atomic_acquire_load_int(const ABTD_atomic_int *ptr)
static void ythread_callback_yield_impl(void *arg, ABT_pool_context context)
#define ABT_TRUE
True constant for ABT_bool.
static void ABTI_pool_add_thread(ABTI_thread *p_thread, ABT_pool_context context)
void ABTI_ythread_callback_thread_yield_to(void *arg)
#define ABT_FALSE
False constant for ABT_bool.
void ABTI_ythread_callback_yield_user_yield_to(void *arg)
static void ABTD_spinlock_release(ABTD_spinlock *p_lock)
ABTI_xstream * p_last_xstream
void ABTI_ythread_callback_exit(void *arg)
#define ABTU_no_sanitize_address
#define ABT_ERR_OTHER
Error code: other error.
static void ABTI_pool_inc_num_blocked(ABTI_pool *p_pool)
static void ABTI_thread_unset_associated_pool(ABTI_global *p_global, ABTI_thread *p_thread)
void ABTI_ythread_callback_resume_suspend_to(void *arg)
void ABTI_ythread_callback_orphan(void *arg)
static int ABTI_thread_handle_request(ABTI_thread *p_thread, ABT_bool allow_termination)
void ABTI_ythread_callback_yield_create_to(void *arg)
#define ABT_POOL_CONTEXT_OP_THREAD_YIELD_LOOP
A flag that hints a push operation in a yield operation in a synchronization loop.
#define ABT_POOL_CONTEXT_OP_THREAD_YIELD
A flag that hints a push operation in a thread yield routine.
static size_t ABTD_ythread_context_get_stacksize(ABTD_ythread_context *p_ctx)
#define ABT_POOL_CONTEXT_OP_THREAD_RESUME_YIELD_TO
A flag that hints a push operation in a thread resume-yield-to routine.
static void ABTD_atomic_release_store_int(ABTD_atomic_int *ptr, int val)
static void ABTI_thread_terminate(ABTI_global *p_global, ABTI_xstream *p_local_xstream, ABTI_thread *p_thread)
static void ABTI_pool_dec_num_blocked(ABTI_pool *p_pool)
void ABTD_ythread_print_context(ABTI_ythread *p_ythread, FILE *p_os, int indent)