老师这个函数有点问题,设置一个断点以后,再继续运行还是会回到这个断点,在打印源码的时候改了pc指针,打印完了以后没有改回来 void debugger::handle_sigtrap(siginfo_t info) { switch (info.si_code) { //one of these will be set if a breakpoint was hit case SI_KERNEL: case TRAP_BRKPT: { set_pc(get_pc()-1); //这里将pc指针设置成了当前指令,在打印完了以后,应该修改回来为当前指令的下一条指令 std::cout << "Hit breakpoint at address 0x" << std::hex << get_pc() << std::endl; auto line_entry = get_line_entry_from_pc(get_pc()); print_source(line_entry->file->path, line_entry->line); //set_pc(get_pc()+1);这里应该加上这么一句 return; } //this will be set if the signal was sent by single stepping case TRAP_TRACE: return; default: std::cout << "Unknown SIGTRAP code " << info.si_code << std::endl; return; } }