当前位置:网站首页>Several ways to add breakpoints using GDB
Several ways to add breakpoints using GDB
2022-06-29 02:50:00 【Hello,C++!】
1. Normal breakpoints
Setting breakpoints based on the number of lines of code is the most common way , stay debug Breakpoints can be configured before the program runs . Such as :
(gdb) b src/main.cpp:127
When the program is executed to main.cpp File first 127 The breakpoint will be triggered when the line .
2. Conditional breakpoints
seeing the name of a thing one thinks of its function , This breakpoint is triggered when certain conditions are met , It is more suitable for abnormal troubleshooting . Setting mode (gdb)break line-or-function if (condition), Such as :
(gdb) b src/main.cpp:127 if cnt==10
3. Data breakpoints
Is to set the breakpoint according to the address , It can only be in debug After the program runs, set , Because only after running , You can easily get the address of the variable . A breakpoint is triggered when the content of the address changes . There are two ways to set data breakpoints , One is to directly point out the address value , Such as :
(gdb) b *0x400522
Note that it must be added * Number . The way to get the address value is , Set the normal breakpoint first , At the breakpoint print & Variable name You can get the address of the variable . The other, of course, is to directly set the variable name , Such as :
(gdb) b & Variable name
4. Function breakpoints
This kind of breakpoint is a breakpoint that will be triggered when the program executes to a program . The setting method is as follows: :
(gdb) b funcName
But function breakpoints are not valid for all functions , Such as optimized static functions and inline Functions, etc , You may not be able to trigger breakpoints .
5. monitor
Setting monitoring must also be done after the program runs . Such as :
(gdb) watch * Address # When the content referred to by the address changes, the breakpoint
(gdb) watch var # When var When the value changes , The breakpoint
(gdb) watch (condition) # When the conditions are met , The breakpoint
Monitoring is also known as hardware breakpoints . You can monitor the changes of stack variables and heap variables , When the value of the monitored variable changes , The program was stopped .
边栏推荐
- 今日直播|Apache Pulsar x KubeSphere 在线 Meetup 火热来袭
- String method exercise
- Application of fsockopen function
- leetcode 统计放置房子的方式数
- Exec function of PHP
- STM32L4系列单片机ADC通过内部参考电压精确计算输入电压
- PMP项目管理概述
- If you dare to write MQ message queue middleware on your resume, you must win these questions!
- PWN攻防世界Level2
- SQL training 01
猜你喜欢
随机推荐
String segment combination
[sans titre]
18. ` BS object. Nom du noeud. Suivant Sibling ` get Brother Node
China's flexible employment has reached 200million
Programmers whose monthly salary is less than 30K must recite the interview stereotype. I'll eat it first
Apache does not parse PHP files, but directly displays the source code
sql连续登录问题
Understanding and design of high concurrency
[linear algebra] 1.1 second and third order determinants
[untitled]
Quelques tests pour compléter l'environnement wasm
安装kibana
双击事件与单击事件的那些事
Map and set use pari as the key value. How to define
Square root of X
[issue 259] uncover how count is executed in MySQL?
信息学奥赛一本通 1361:产生数(Produce) | 洛谷 P1037 [NOIP2002 普及组] 产生数
Informatics Olympiad all in one 1361: production | Luogu P1037 [noip2002 popularization group] production
[Algèbre linéaire] 1.1 déterminant du deuxième et du troisième ordre
音响是如何把微弱声音放大呢



![[issue 259] uncover how count is executed in MySQL?](/img/bc/ee26eba95f408ea887d6aa06301a0b.jpg)





![[線性代數] 1.1 二階與三階行列式](/img/ea/70b59c64d3287a887e371a9181fe45.png)