当前位置:网站首页>gdb常用命令
gdb常用命令
2022-07-26 13:45:00 【1.01】
GDB主要完成下面四个方面的功能:
- 启动你的程序,可以按照你的自定义的要求随心所欲的运行程序。
- 可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)
- 当程序被停住时,可以检查此时你的程序中所发生的事。
- 动态的改变你程序的执行环境。
常用命令:
——————————————————————————————————————————————————
Linux下如何使用gdb调试core文件
**
1.core文件
**
core文件是程序运行状态的内存映像当程序运行过程中出现segmentation fault(core dumped)错误时,程序停止运行,并产生core文件。
使用gdb调试core文件可以帮我们快速定位程序出现段错误的位置。可执行程序编译时应加上-g编译选项,生成调试信息闭。
当程序访问的内存超出了系统给定的内存空间,就会产生Segmentation fault(core dumped),因此,段错误产生的情况主要有:
- 访问不存在的内存地址
- 访问系统保护的内存地址
- 数组访问越界等
core dumped又叫核心转储,当程序运行过程中发生异常,程序异常退出时,由操作系统把程序当前内存状况储存在一个core文件中。
**
2.控制core文件是否生成
**
- 使用ulimit -c命令可查看core文件的生成开关。若结果为0,则表示关闭了此功能,不会生成core文件。
- 使用ulimit -c filesize命令,可以限制core文件的大小(filesize的单位为kb)。如果生成的信息超过此大小,将会被剪裁,最终说呢过程一个不完整的core文件。例:ulimit -c 1024
- 使用ulimit -c unlimited则表示core文件大小不受限制。
- 在终端通过命令ulimit -c unlimited只是临时修改,重启后无效,永久修改的三种方式。
在/etc/rc.local中增加一行ulimit -c unlimited 在/etc/profile中增加一行ulimit -c unlimited- 1
- 2
3.core文件的名称和生成路径
core默认的文件名称是core.pid,pid指的是产生段错误的程序的进程号。
默认路径是产生段错误的程序的当前目录。
4.gdb调试core文件的步骤
使用gdb调试core文件来查找程序中出现段错误的位置时,需要可执行程序加上-g编译命令选项。
常见的有以下几种(推荐第一种):
步骤一:
(1)启动gdb进入core文件,命令格式:gdb [exec file] [ core file]
例:gdb ./test test.core
(2)进入后,查找段错误位置:where或者bt
可以定位到源程序当中具体文件的具体位置,出现的段错误。
步骤二:
(1)启动gdb进入core文件,命令格式:gdb -core=[core file]
例:gdb -core=test.core
(2)在进入gdb后,指定core文件对应的符号表,命令格式:file [exec file]
在gdb输入bt命令 在遇到段错误时,输入bt命令,即可跟踪错误
边栏推荐
- [oauth2] v. oauth2loginauthenticationfilter
- 官宣!艾德韦宣集团与百度希壤达成深度共创合作
- Sword finger offer (x): rectangular coverage
- Comparator (interface between comparable and comparator)
- The serialization class in unity is in JSON format
- Flutter multi-channel packaging operation
- Pytorch学习笔记(二)神经网络的使用
- Target detection network r-cnn series
- LCL三相pwm整流器(逆变器)
- JSON数据传递参数&日期型参数传递
猜你喜欢

Basic sentence structure of English ----- origin

力扣------字符串中的单词数
![[oauth2] VIII. Configuration logic of oauth2 login -oauth2loginconfigurer and oauth2clientconfigurer](/img/7e/4f652c4d3d72ad563ddbc1c1f1f50b.png)
[oauth2] VIII. Configuration logic of oauth2 login -oauth2loginconfigurer and oauth2clientconfigurer

Uncover the secret of white hat: 100 billion black products on the Internet scare musk away

This article explains the FS file module and path module in nodejs in detail

Algorithm -- continuous sequence (kotlin)

2022年,我们只用一个月就“送走”了这么多互联网产品
![[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve](/img/95/bec94176cadfac112585df259156c9.png)
[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve

With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development

周伟:寻找非共识性投资机会,陪伴延迟满足的创始团队
随机推荐
一文学透MySQL表的创建和约束
.net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手
Concept and handling of exceptions
How to build a customer-centric product blueprint: suggestions from the chief technology officer
JUC summary
Pytorch学习笔记(二)神经网络的使用
Win11+VS2019配置YOLOX
【黑马早报】字节旗下多款APP下架;三只松鼠脱氧剂泄露致孕妇误食;CBA公司向B站索赔4.06亿;马斯克否认与谷歌创始人妻子有婚外情...
《Kotlin系列》之MVVM架构封装(kotlin+mvvm)
「中高级试题」:MVCC实现原理是什么?
Jenkins 中 shell 脚本执行失败却不自行退出
云智技术论坛工业专场 明天见!
[shaders realize overlay to re cover cross dressing effect _shader effect Chapter 9]
The serialization class in unity is in JSON format
【Oauth2】七、微信OAuth2授权登录
向路由组件传递参数
The use of asynchronous thread pool in development
Click El dropdown item/@click.native
Golang端口扫描设计
Detailed relation extraction model casrel
