- dwarf::die debugger::get_function_from_pc(uint64_t pc) {
- for (auto &cu : m_dwarf.compilation_units()) {
- if (die_pc_range(cu.root()).contains(pc)) {
- for (const auto& die : cu.root()) {
- if (die.tag == dwarf::DW_TAG::subprogram) {
- if (die_pc_range(die).contains(pc)) {
- return die;
- }
- }
- }
- }
- }
- throw std::out_of_range{"Cannot find function"};
- }
同样,我们可以简单地找到精确的编译单位,然后萌芽行表获取相干的条目。
- void debugger::handle_sigtrap(siginfo_t info) {
- switch (info.si_code) {
- //如不雅射中了一个断点个中的一个会被设置
- case SI_KERNEL:
- case TRAP_BRKPT:
- {
- set_pc(get_pc()-1); //将法度榜样计数器的值设置为它应当指向的处所
- std::cout << "Hit breakpoint at address 0x" << std::hex << get_pc() << std::endl;
推荐阅读
概述秦人不暇自哀,而后人哀之;后人哀之而不鉴之,亦使后人而复哀后人也! –论面向文档编程的重要性如不雅想看见识一小我写代码的功力,注释其实是区分老司机和小鲜肉的一个明显的分界线(有没有不雅察碘晾髑公司的>>>详细阅读
地址:http://www.17bianji.com/lsqh/36965.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示