当前位置:网站首页>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
边栏推荐
- JUC summary
- 「中高级试题」:MVCC实现原理是什么?
- Solve the problem that the remote host cannot connect to the MySQL database
- 时间复杂度和空间复杂度
- POM文件详解
- 最新战报:十项认证,五项最佳实践
- SuperMap iclient for leaflet loads Gauss Kruger projection three-dimensional zonation CGCS2000 geodetic coordinate system WMTs service
- Familiarize you with the "phone book" of cloud network: DNS
- JSON data transfer parameters & date type parameter transfer
- Ultimate doll 2.0 | cloud native delivery package
猜你喜欢

云智技术论坛工业专场 明天见!

Multi objective optimization series 1 --- explanation of non dominated sorting function of NSGA2

Docker swarm cluster builds highly available MySQL active and standby

How to build a customer-centric product blueprint: suggestions from the chief technology officer
![[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

JS page turning, kkpager.js page turning

历时15年、拥有5亿用户的飞信,彻底死了

Re bet overseas: Alibaba, jd.com and SF again fight for "internal power"

How to quickly design a set of cross end components that support rendering rich text content

Solve the problem that JUnit of idea console cannot be input with scanner
随机推荐
最新战报:十项认证,五项最佳实践
Concept and handling of exceptions
php使用sqlserver
Codeforces round 810 (Div. 2) [competition record]
Oom caused by improper use of multithreading
万字长文,浅谈企业数字化建模蓝图
Pass parameters to the routing component
一文学透MySQL表的创建和约束
The serialization class in unity is in JSON format
Comparator (interface between comparable and comparator)
Ultimate doll 2.0 | cloud native delivery package
404 pages and routing hooks
Pytoch learning notes (I) installation and use of common functions
"Intermediate and advanced test questions": what is the implementation principle of mvcc?
Algorithm -- continuous sequence (kotlin)
Solve the problem that the remote host cannot connect to the MySQL database
Upload pictures to get width and height
官宣!艾德韦宣集团与百度希壤达成深度共创合作
Unicode file parsing methods and existing problems
重押海外:阿里、京东、顺丰再拼“内力”
