summaryrefslogtreecommitdiff
path: root/source/ucli/unwind.cc
diff options
context:
space:
mode:
Diffstat (limited to 'source/ucli/unwind.cc')
-rw-r--r--source/ucli/unwind.cc54
1 files changed, 20 insertions, 34 deletions
diff --git a/source/ucli/unwind.cc b/source/ucli/unwind.cc
index bc57c15..f09d7a5 100644
--- a/source/ucli/unwind.cc
+++ b/source/ucli/unwind.cc
@@ -20,16 +20,19 @@ static std::string unknow_symbol("UNKNOWN");
// }
// if (g_symbol_parser.get_symbol_info(entry->pid, sym, file)) {
-// if (g_symbol_parser.find_elf_symbol(sym, file, entry->pid, entry->pid_ns)) {
+// if (g_symbol_parser.find_elf_symbol(sym, file, entry->pid,
+// entry->pid_ns)) {
// printf("#~ 0x%lx %s ([symbol])\n", entry->ip, sym.name.c_str());
// g_symbol_parser.putin_symbol_cache(entry->pid, entry->ip, sym.name);
// } else {
-// printf("#~ 0x%lx %s ([symbol])\n", entry->ip, "(unknown)[symbol]");
-// g_symbol_parser.putin_symbol_cache(entry->pid, entry->ip, unknow_symbol);
+// printf("#~ 0x%lx %s ([symbol])\n", entry->ip,
+// "(unknown)[symbol]"); g_symbol_parser.putin_symbol_cache(entry->pid,
+// entry->ip, unknow_symbol);
// }
// } else {
-// printf("#~ 0x%lx %s ([symbol])\n", entry->ip, "(unknown)[vma,elf]");
-// g_symbol_parser.putin_symbol_cache(entry->pid, entry->ip, unknow_symbol);
+// printf("#~ 0x%lx %s ([symbol])\n", entry->ip,
+// "(unknown)[vma,elf]"); g_symbol_parser.putin_symbol_cache(entry->pid,
+// entry->ip, unknow_symbol);
// }
// return 0;
@@ -39,7 +42,8 @@ static std::string unknow_symbol("UNKNOWN");
*/
static int reg_value(unw_word_t *valp, struct regs_dump *regs, int id) {
/* we only support 3 registers. RIP, RSP and RBP */
- if (id < 0 || id > 2) return -EINVAL;
+ if (id < 0 || id > 2)
+ return -EINVAL;
*valp = regs->regs[id];
return 0;
@@ -76,12 +80,13 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
while (!ret && (unw_step(&c) > 0)) {
unw_word_t ip;
- unw_get_reg(&c, UNW_REG_IP, &ip); // get IP from current step;
+ unw_get_reg(&c, UNW_REG_IP, &ip); // get IP from current step;
cb_arg->arg = &c;
ret = entry(ip, ui->pid, ui->pid_ns, cb, cb_arg);
loops++;
- if (loops >= 50) break;
+ if (loops >= 50)
+ break;
}
unw_destroy_addr_space(addr_space);
@@ -99,35 +104,16 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, symbol_parser *sp,
};
int ret;
- if (!data->user_regs.regs) return -EINVAL;
+ if (!data->user_regs.regs)
+ return -EINVAL;
ret = reg_value(&ip, &data->user_regs, PERF_REG_IP);
- if (ret) return ret;
+ if (ret)
+ return ret;
ret = entry(ip, pid, pid_ns, cb, arg);
- if (ret) return -ENOMEM;
+ if (ret)
+ return -ENOMEM;
return get_entries(&ui, cb, arg);
-}
-
-// void diag_printf_raw_stack(int pid, int ns_pid, const char *comm,
-// raw_stack_detail *raw_stack, int attach){
-// struct perf_sample stack_sample;
-// entry_cb_arg_t unwind_arg;
-// static u64 regs_buf[3];
-
-// printf("##C++ pid %d\n", pid);
-
-// printf(" 用户态堆栈SP:%lx, BP:%lx, IP:%lx\n", raw_stack->sp,
-// raw_stack->bp, raw_stack->ip);
-// stack_sample.user_stack.offset = 0;
-// stack_sample.user_stack.size = raw_stack->stack_size;
-// stack_sample.user_stack.data = (char *)&raw_stack->stack[0];
-// stack_sample.user_regs.regs = regs_buf;
-// stack_sample.user_regs.regs[PERF_REG_IP] = raw_stack->ip;
-// stack_sample.user_regs.regs[PERF_REG_SP] = raw_stack->sp;
-// stack_sample.user_regs.regs[PERF_REG_BP] = raw_stack->bp;
-// unwind__get_entries(unwind_frame_callback, &unwind_arg, &g_symbol_parser, pid,
-// ns_pid, &stack_sample);
-// fflush(stdout);
-// } \ No newline at end of file
+} \ No newline at end of file