GDB 调试技巧(不断更新中......)
2024-09-06 02:22:55
一、break到不同类的同名函数
方法: 在函数前面加类名以及作用域运算符
eg : break A::func //break 到类A的func函数
程序如下:
//gdb_test.cpp
#include<iostream>
class A {
public:
void func() {
std::cout << "A::func() is called" << std::endl;
}
};
class B {
public:
void func() {
std::cout << "B::func() is called" << std::endl;
}
};
int main(int argc,char *argv[])
{
A a;
B b;
a.func();
b.func();
return 0;
}
调试过程如下:
[kiosk@localhost mess]$ gdb gdb_test
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/kiosk/practice/mess/gdb_test...done.
(gdb) b A::func //备注:break 到 A::func()位置处
Breakpoint 1 at 0x4008fa: file gdb_test.cpp, line 13.
(gdb) b B::func //备注:break 到 B::func()位置处
Breakpoint 2 at 0x400924: file gdb_test.cpp, line 20.
(gdb)
最新文章
- sass的四种css编译风格
- [原创]自定义控件之AndroidSegmentControlView,仿IOS平台UISegmentControlView,继承自View
- LINQ to Entities 查询语法
- 2014年互联网IT待遇【转载】
- MyBatis学习总结1
- 安装Visual Studio 2010之后怎样安装MSDN Library
- VIM下Express jade空格问题:expected ";indent";, but got ";newline";
- Libgdx Box2D现实------这缓释微丸(一个:项目介绍)
- 从头开始学JavaScript (八)——变量
- java应用测试报告生成(一): sonarqube配合Jenkins生成测试报告及覆盖率
- 使用Eclipse远程调试
- DBUtils温习2
- #15 time&;datetime&;calendar模块
- [dpdk] dpdk编译成动态库使用 -- PCI port自动发现与pmd动态加载
- 玩转X-CTR100 l STM32F4 l AT24C02 EEPROM存储
- Android 之 沉浸式状态栏及顶部状态栏背景色设置
- Gitlab-通过API管理项目
- C#学习笔记-原型模式
- Git添加本地项目出现fatal: unable to get credential storage lock: File exists
- winform 查看远程服务器上的文件