当前位置:网站首页>Advanced usage of setting breakpoints during keil debugging

Advanced usage of setting breakpoints during keil debugging

2022-06-22 06:34:00 liht_ one thousand six hundred and thirty-four

Catalog :

1、 Set the number of times the breakpoint runs

2、 Variables match breakpoints

3、 Variable conditions match breakpoints

4、 Print information

5、 Condition matching print information

-----------------------------------------------------------------------------------------------------------------

When debugging the program online , Breaking points is a very effective way , Cooperate with one-step debugging , Can quickly locate problems . But sometimes , Manual break points are not so convenient to use .

such as , Want to be in the first place of a loop N Stop for the first time , Break the point manually , Then keep clicking on one-step operation , Until the cycle runs to N Time .

Another example , I don't know when the variables are changed during the running of the program , It's not easy to locate , I don't know where to hit the manual interruption point . At this point, we need to use some advanced usage of breakpoints .

-----------------------------------------------------------------------------------------------------------------

1、 Set the number of times the breakpoint runs

Take the following procedure for example , Stop the program at the tenth time of the cycle . First, manually make a breakpoint in the loop :

Click on Debug menu , choice BreakPoints:

Pop up the following menu :

The top breakpoint is manually hit , Double click the breakpoint , Will see Expression The information of the breakpoint will be displayed , modify Count The value of is 10, Click on Define, Then close the window . Here's an explanation :

Expression Expression for , That is, the condition of the breakpoint , You can see , The manually set breakpoint ends with \123, It means that main.c Of documents 123 That's ok . There is support for basic >、<、==、!= Wait for the operator .

Count Is the number of times , Indicates how many times the operation is interrupted and once , Manually set breakpoints Count All are 1.

Command For orders , Indicates the command executed when the breakpoint is reached , The default is empty. .

According to the settings above , Run the program . You can see , The program didn't stop immediately when it reached the breakpoint , But in the 10 Time to stop :

-----------------------------------------------------------------------------------------------------------------

2、 Variables match breakpoints

Add variables to Watch window , Right click selection Set Access BreakPoint at xxx. Or pop up the menu just now :

Check Access The way Read or Write, Set up Count value , Click on Define. Choose here Write,Count The value is 4, Indicates that the program will stop when the variable is written for the fourth time .

-----------------------------------------------------------------------------------------------------------------

3、 Variable conditions match breakpoints

Just like the next step , stay Watch window , Right click the variable and select Set Access BreakPoint at xxx. Check Access The way Read or Write, Delete Expression Write down the original content , Fill in the expression “AD== 10”. Click on Define. So when AD==10 The program will stop .

-----------------------------------------------------------------------------------------------------------------

4、 Print information

     Select a manually set breakpoint , And then in Command Fill in below printf(), When running to the breakpoint , The program will not stop , But in Command Window print setting information .

-----------------------------------------------------------------------------------------------------------------

5、 Condition matching print information

Can also be 3 and 4 Use a combination of , as follows :

be AD==10 when , The program is not interrupted , stay Command Window printing information .

There are many advanced uses of breakpoints , Different expressions , Different instructions, etc , For details, please refer to Keil Use help documentation for .

 -----------------------------------------------------------------------------------------------------------------

原网站

版权声明
本文为[liht_ one thousand six hundred and thirty-four]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220537008209.html