当前位置:网站首页>GDB common commands
GDB common commands
2022-07-26 13:50:00 【one point zero one】
GDB It mainly completes the following four functions :
- Start your program , You can run the program according to your custom requirements .
- You can make the debugged program stop at the breakpoint you specified .( Breakpoints can be conditional expressions )
- When the program is stopped , You can check what's going on in your program at this point .
- Dynamically change the execution environment of your program .
Common commands :
——————————————————————————————————————————————————
Linux How to use gdb debugging core file
**
1.core file
**
core Files are in the running state of the program Memory Image appears when the program is running segmentation fault(core dumped) When it's wrong , The program stops running , And produce core file .
Use gdb debugging core Files can help us quickly locate the program Segment error The location of . Executable programs should be compiled with -g Compilation options , Generate debugging information .
When the memory accessed by the program exceeds the memory space given by the system , It will produce Segmentation fault(core dumped), therefore , The main situations of segment errors are :
- Access to non-existent memory address
- Access system protected memory address
- Array access out of bounds, etc
core dumped It's also called core dump , When an exception occurs while the program is running , When the program exits abnormally , The operating system stores the current memory status of the program in a core In file .
**
2. control core Whether the file is generated
**
- Use ulimit -c The command can be viewed core File generation switch . If the result is 0, This function is turned off , Will not generate core file .
- Use ulimit -c filesize command , Can restrict core File size (filesize The unit is kb). If the generated information exceeds this size , Will be cut , In the end, the process is incomplete core file . example :ulimit -c 1024
- Use ulimit -c unlimited said core Unlimited file size .
- By command at the terminal ulimit -c unlimited It's just a temporary change , Invalid after restart , There are three ways to permanently modify .
stay /etc/rc.local Add a line to the list ulimit -c unlimited stay /etc/profile Add a line to the list ulimit -c unlimited- 1
- 2
3.core File name and build path
core The default file name is core.pid,pid It refers to the process number of the program that generated the segment error .
The default path is the current directory of the program that generated the segment error .
modify core File name and path
4.gdb debugging core Document steps
Use gdb debugging core File to find the location of the segment error in the program , Need executable program plus -g Compile command options .
The common ones are the following ( Recommend the first ):
Step one :
(1) start-up gdb Get into core file , Command format :gdb [exec file] [ core file]
example :gdb ./test test.core
(2) After entering , Find segment error location :where perhaps bt
You can locate the specific location of specific files in the source program , A segment error occurred .
Step two :
(1) start-up gdb Get into core file , Command format :gdb -core=[core file]
example :gdb -core=test.core
(2) When entering gdb after , Appoint core Symbol table corresponding to the file , Command format :file [exec file]
stay gdb Input bt command When encountering segment errors , Input bt command , You can track errors
边栏推荐
- 异步线程池在开发中的使用
- .net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手
- 循环队列(c语言实现)
- 带你熟悉云网络的“电话簿”:DNS
- Docker integrates the redis sentinel mode (one master, two slave and three sentinels)
- WPS凭什么拒绝广告?
- JUC summary
- Pytorch学习笔记(三)模型的使用、修改、训练(CPU/GPU)及验证
- JS submit the form to determine whether the user name and password are empty
- 历时15年、拥有5亿用户的飞信,彻底死了
猜你喜欢

MySQL's practice of SQL analysis and optimization from the index principle

【C语言学习者必会的题目集锦1】巩固基础,稳步提高

「中高级试题」:MVCC实现原理是什么?

估值15亿美元的独角兽被爆裁员,又一赛道遇冷?

Videojs to canvas pause, play, switch video

Feixin, which lasted 15 years and had 500million users, was completely dead

Force deduction ----- the number of words in the string
![[oauth2] VII. Wechat oauth2 authorized login](/img/1a/3f2b9fc57759a1fa3fda1451492e5c.png)
[oauth2] VII. Wechat oauth2 authorized login

How can red star Macalline design cloud upgrade the traditional home furnishing industry in ten minutes to produce film and television level interior design effects

大小端模式
随机推荐
Solve the problem that the remote host cannot connect to the MySQL database
白帽子揭秘:互联网千亿黑产吓退马斯克
Mobile dual finger scaling event (native), e.originalevent.touches
[collection of topics that C language learners must know 1] consolidate the foundation and steadily improve
Explain four interesting NPM usages with charts
【OAuth2】八、OAuth2登录的配置逻辑-OAuth2LoginConfigurer和OAuth2ClientConfigurer
JS download files, filesaver.js export txt and Excel files
Pass parameters to the routing component
Activity. Onstop() delay 10 seconds? Wonderful investigation process
Multithreaded completable future usage
JS object assignment problem
Tianyi cloud web application firewall (edge cloud version) supports the detection and interception of Apache spark shell command injection vulnerabilities
Tdsql-c serverless: help start-ups achieve cost reduction and efficiency increase
"Intermediate and advanced test questions": what is the implementation principle of mvcc?
Photoshop (cc2020) unfinished
估值15亿美元的独角兽被爆裁员,又一赛道遇冷?
[oauth2] VII. Wechat oauth2 authorized login
(Reprint) creation methods of various points in ArcGIS Engine
Ros2 learning (1) introduction to ros2
JS, e.pagex, pagey modal box drag
