要在GDB – C中反汇编重载的成员函数
发布时间:2020-12-16 10:08:40 所属栏目:百科 来源:网络整理
导读:有多个库实现一个特定的类 – 我不确定包含哪个库 – 我也没有make文件. 我想通过查看类的成员方法的反汇编来直接在GDB中确认这一点. 如何在GDB中反汇编重载的成员函数? 解决方法 考虑这个测试: struct Foo { int Fn(int x) const { return x + 42; } int
有多个库实现一个特定的类 – 我不确定包含哪个库 – 我也没有make文件.
我想通过查看类的成员方法的反汇编来直接在GDB中确认这一点. 如何在GDB中反汇编重载的成员函数? 解决方法
考虑这个测试:
struct Foo { int Fn(int x) const { return x + 42; } int Fn(void) const { return 24; } }; int main() { Foo f; return f.Fn() + f.Fn(1); } 使用调试信息编译时: (gdb) info func Fn All functions matching regular expression "Fn": File t.cc: int Foo::Fn() const; int Foo::Fn(int) const; (gdb) disas 'Foo::Fn(int) const' Dump of assembler code for function Foo::Fn(int) const: 0x000000000040051e <+0>: push %rbp 0x000000000040051f <+1>: mov %rsp,%rbp 0x0000000000400522 <+4>: mov %rdi,-0x8(%rbp) 0x0000000000400526 <+8>: mov %esi,-0xc(%rbp) 0x0000000000400529 <+11>: mov -0xc(%rbp),%eax 0x000000000040052c <+14>: add $0x2a,%eax 0x000000000040052f <+17>: pop %rbp 0x0000000000400530 <+18>: retq End of assembler dump. 在没有调试信息的情况下编译时: (gdb) info func Fn All functions matching regular expression "Fn": Non-debugging symbols: 0x000000000040051e Foo::Fn(int) const 0x0000000000400532 Foo::Fn() const (gdb) disas 'Foo::Fn() const' Dump of assembler code for function _ZNK3Foo2FnEv: 0x0000000000400532 <+0>: push %rbp 0x0000000000400533 <+1>: mov %rsp,%rbp 0x0000000000400536 <+4>: mov %rdi,-0x8(%rbp) 0x000000000040053a <+8>: mov $0x18,%eax 0x000000000040053f <+13>: pop %rbp 0x0000000000400540 <+14>: retq End of assembler dump. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读