auto unwind()

in cpp/profiler/unwindc/android_800/arm/unwinder.h [682:745]


auto unwind(unwind_callback_t __unwind_callback, void* __unwind_data) {
  uintptr_t thread = get_art_thread();
  if ((thread == 0U)) {
    return true;
  }
  auto runtime = get_runtime_from_thread(thread);
  uintptr_t thread_obj = thread;
  auto runtime_obj = runtime;
  uintptr_t tls = AccessField(thread_obj, 128U);
  uintptr_t mstack = AccessField(tls, 12U);
  uint32_t generic_jni_trampoline =
      Read4(AccessField(AccessField(tls, 156U), 204U));
  while ((mstack != 0U)) {
    uint32_t quick_frame = Read4(AccessField(mstack, 0U));
    quick_frame = quick_frame;
    uint32_t shadow_frame = Read4(AccessField(mstack, 8U));
    shadow_frame = shadow_frame;
    uintptr_t pc = 0U;
    uintptr_t kMaxFrames = 1024U;
    uintptr_t depth = 0U;
    if ((quick_frame != 0U)) {
      while (((quick_frame != 0U) && (depth < kMaxFrames))) {
        uint32_t frameptr = Read4(quick_frame);
        if ((frameptr == 0U)) {
          break;
        }
        uint32_t frame = frameptr;
        if ((!is_runtime_method(frame))) {
          if ((!__unwind_callback(frame, __unwind_data))) {
            return false;
          }
        }
        auto size = get_frame_size(frameptr, runtime_obj, thread_obj, pc);
        auto return_pc_offset = (size - 4U);
        uint32_t return_pc_addr = (quick_frame + return_pc_offset);
        uint32_t return_pc = return_pc_addr;
        pc = Read4(return_pc);
        quick_frame = (quick_frame + size);
        depth = (depth + 1U);
      }
    } else {
      if ((shadow_frame != 0U)) {
        while (((shadow_frame != 0U) && (depth < kMaxFrames))) {
          uint32_t frame_obj = shadow_frame;
          uint32_t artmethodptr = Read4(AccessField(frame_obj, 4U));
          uint32_t artmethod = artmethodptr;
          if ((!is_runtime_method(artmethod))) {
            if ((!__unwind_callback(artmethod, __unwind_data))) {
              return false;
            }
          }
          shadow_frame = Read4(AccessField(frame_obj, 0U));
          depth = (depth + 1U);
        }
      }
    }
    uint32_t link = Read4(AccessField(mstack, 4U));
    if ((link == 0U)) {
      break;
    }
    mstack = link;
  }
  return true;
}