33 namespace debugging_internal {
41 ucontext_t* context =
reinterpret_cast<ucontext_t*
>(vuc);
42 #if defined(__aarch64__) 43 return reinterpret_cast<void*
>(context->uc_mcontext.pc);
44 #elif defined(__arm__) 45 return reinterpret_cast<void*
>(context->uc_mcontext.arm_pc);
46 #elif defined(__i386__) 48 return reinterpret_cast<void*>(context->uc_mcontext.gregs[14]);
49 #elif defined(__mips__) 50 return reinterpret_cast<void*
>(context->uc_mcontext.pc);
51 #elif defined(__powerpc64__) 52 return reinterpret_cast<void*
>(context->uc_mcontext.gp_regs[32]);
53 #elif defined(__powerpc__) 54 return reinterpret_cast<void*
>(context->uc_mcontext.regs->nip);
55 #elif defined(__s390__) && !defined(__s390x__) 56 return reinterpret_cast<void*
>(context->uc_mcontext.psw.addr & 0x7fffffff);
57 #elif defined(__s390__) && defined(__s390x__) 58 return reinterpret_cast<void*
>(context->uc_mcontext.psw.addr);
59 #elif defined(__x86_64__) 61 return reinterpret_cast<void*>(context->uc_mcontext.gregs[16]);
63 #error "Undefined Architecture." 66 #elif defined(__akaros__) 67 auto* ctx =
reinterpret_cast<struct user_context*
>(vuc);
68 return reinterpret_cast<void*
>(get_user_ctx_pc(ctx));
70 static_cast<void>(vuc);
83 void* writerfn_arg,
void* pc,
84 void* symbolize_pc,
int framesize,
85 const char*
const prefix) {
87 const char* symbol =
"(unknown)";
93 snprintf(buf,
sizeof(buf),
"%s@ %*p (unknown) %s\n", prefix,
94 kPrintfPointerFieldWidth, pc, symbol);
96 snprintf(buf,
sizeof(buf),
"%s@ %*p %9d %s\n", prefix,
97 kPrintfPointerFieldWidth, pc, framesize, symbol);
99 writerfn(buf, writerfn_arg);
104 void* writerfn_arg,
void* pc,
int framesize,
105 const char*
const prefix) {
107 if (framesize <= 0) {
108 snprintf(buf,
sizeof(buf),
"%s@ %*p (unknown)\n", prefix,
109 kPrintfPointerFieldWidth, pc);
111 snprintf(buf,
sizeof(buf),
"%s@ %*p %9d\n", prefix,
112 kPrintfPointerFieldWidth, pc, framesize);
114 writerfn(buf, writerfn_arg);
118 void* pc,
void*
const stack[],
int frame_sizes[],
int depth,
119 int min_dropped_frames,
bool symbolize_stacktrace,
120 void (*writerfn)(
const char*,
void*),
void* writerfn_arg) {
123 if (symbolize_stacktrace) {
129 for (
int i = 0;
i < depth;
i++) {
130 if (symbolize_stacktrace) {
137 reinterpret_cast<char*>(stack[i]) - 1,
138 frame_sizes[i],
" ");
144 if (min_dropped_frames > 0) {
146 snprintf(buf,
sizeof(buf),
" @ ... and at least %d more frames\n",
148 writerfn(buf, writerfn_arg);
static constexpr int kPrintfPointerFieldWidth
static void DumpPCAndFrameSizeAndSymbol(void(*writerfn)(const char *, void *), void *writerfn_arg, void *pc, void *symbolize_pc, int framesize, const char *const prefix)
static void DumpPCAndFrameSize(void(*writerfn)(const char *, void *), void *writerfn_arg, void *pc, int framesize, const char *const prefix)
bool Symbolize(const void *pc, char *out, int out_size)
#define ABSL_ARRAYSIZE(array)
void DumpPCAndFrameSizesAndStackTrace(void *pc, void *const stack[], int frame_sizes[], int depth, int min_dropped_frames, bool symbolize_stacktrace, void(*writerfn)(const char *, void *), void *writerfn_arg)
void * GetProgramCounter(void *vuc)