简体   繁体   English

Code::Blocks 调试器:如何在逐行执行时“进入”函数?

[英]Code::Blocks Debugger : how to `step into` functions on line-by-line execution?

When debugging a C++ program on Code::Blocks 20.03 , I press SHIFT+F7 to step into the program, then I begin pressing F7 to go to the next line and watch variables changing in "real time".Code::Blocks 20.03上调试 C++ 程序时,我按SHIFT+F7 step into程序,然后开始按F7转到next linewatch变量“实时”变化。

But Code::Blocks 20.03's debugger won't enter any functions beside main , making it pretty useless, or forcing me to not use any function besides main (a bad programming practice).但是 Code::Blocks 20.03 的调试器不会输入除main之外的任何函数,这使得它非常无用,或者迫使我不使用除main之外的任何函数(一种不好的编程习惯)。

How can I make Code::Blocks 20.03's debugger enter the functions too?如何让 Code::Blocks 20.03 的调试器也进入函数?

  1. Set a breakpoint (red circle) exactly on the line the function main is defined;在定义函数main的行上设置breakpoint (红色圆圈);
  2. Instead of pressing F8 (the same as clicking Debug->Start/Continue ), which would make the program just run until the last line and exit (only flashing on the screen before disappearing), press Shift+F7 (the same as clicking Debug->Step Into ), in order to make the debugger enter the function and not just run it completely and return its result;不要按F8 (与单击Debug->Start/Continue相同),这会使程序运行到最后一行并退出(仅在屏幕上闪烁,然后消失),而是按Shift+F7 (与单击Debug->Step Into相同) Debug->Step Into ),为了让调试器进入函数而不是完全运行它并返回它的结果;
  3. Press F7 (the same as clicking Debug->Next line ) to keep watching the program run "step-by-step";F7 (与点击Debug->Next line相同)继续观察程序“一步一步”运行;
  4. When any other function is called, and the debugger is on that line (yellow arrow), you may enter that other function too, by repeating step 2.当调用任何其他函数并且调试器位于该行(黄色箭头)时,您也可以通过重复步骤 2 输入该其他函数。

Reference: ImageCraft - CodeBlocks Debugger Functions .参考: ImageCraft - CodeBlocks 调试器函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM