1.11 Native Debugger

less than 1 minute read

Native Debugger实现

  1. sigaction()注册捕捉signal(SIGABRT[调用abort函数发的信号], SIGBUS[非法地址, 内存地址对齐出错], SIGFPE[算数错误], SIGILL[非法指令], SIGPIPE[管道破裂], SIGSEGV[访问未分配内存])
  2. 通过socket发送请求, 让debugger服务端调用系统调用ptrace(PTRACE_ATTACH, request_tid, 0, 0), Attach到目标进程, 获取寄存器等相关信息
  3. 调用backtrace_map()获取目标进程的堆栈
  4. activity_manager_connect()告诉AMS 有crash
  5. perform_dump()执行dump操作 -> engrave_tombstone()
  6. ptrace(PTRACE_DETACH, request.tid, 0, 0) detach目标进程
  7. ps: debuggerd -b [pid], 可输出Native进程的调用栈