VC++ 2010debugging

Chapter 11
(Basic Debugging operations)


make sure the current build configuration is"debug", not
"release";


in debug mode, the compiler inhibits the optimization
option.(with reason);


you can press "debugging" buttons to step one step at a
time; and you can set breakpoint to run directly to it,
then go one step once;




(Advanced breakpoints)


use debug->window to use breakpoint window;


set things so that execution only breaks when the "hint count"
,which is the number of times the breakpoint has been reached,
reaches a given value.(useful in loop);




(Setting Tracepoints)


use right-click to insert a tracepoint;


the tracepoint action are designated by you! you can print
a message / run a macro


the printed message by the tracepoint action is in the 
"output" pane in the Visual Studio application window




(Starting Debugging)


5 ways debug mode;


"Start Debugging": enable you to move through a program
from a breakpoint to a breakpoint;


"Attach to Process": is used for advanced users,shouldn't
use,easily to cause serious problems;


"Step Into": step into every function that is called


"Step Over": 只执行“用户”写的程序中的statement,即只执行main中
的statement,runs the code that uses function without stopping;


"Run to Cursor": stops at where your cursor resides;


Example(beginning debugging);


use F11 (step into)to start debugging; 


when the debugger starts, 2 tabbed windows apprear below
the Editor window (can choose which window to display);


the "Autos" / "Call Stack" / "Output" tabs


Until a declaration has been executed, you cannot look
at its value or change it.




(Inspecting Variable Values)


explain what those several tabs do you can look at;


setting watch for some variables;


"+" means you can look at some extra information in
"auto" tabs;


"Autos" tab好像很常用,it provides you with all the 
information including both eh memory address and the
data value stored at the address;


(Viewing Variables in the Edit Window)


hovering the cursor over;




(Changing the Value of a Variable)


means change value of variable being used;
"Watch","Autos","Locals" these place to change the value;


you can use this tech to shrink the iteration times;
you can use this tech to test your error handling code
,by setting values that cause errors;


Watch value changing
variable changing: double click
array changing: "+", then change
hexadecimal value changing: directly use another hexadecimal
, or decimal value prefixed by 0n




(Adding Debugging Code)


helps to locate the approximate positions of the err,
having done this, you can stepping through the code;




(Using Assertions)


"assertion" function is declared in "cassert" header,
and assertion tech be used with preprocessor"NDEBUG"
NDEBUG is automatically defined in the release version
of a program;


with assertion, you can get a message;


(Adding Your Own Debugging Code)


add your debugging code together with "NDEBUG", or
with _DEBUG,which defined automatically in VC++ in
the debug version of a program'


define your own preprocessor symbol to control using
different debugging code


convenient to group your debug control symbols into
one header, and #include the header into the file that
contains debugging code;




(Try it Out: Adding Code for Debugging)




(Debugging a Program):关键在于分析debug的思路


press "break" in a message box makes the program stays at the point where the exception occurred;




(The Call Stack)


the call stack stores functions still running;


the sequence of function calls outstanding runs from the most recent call at the top, down to the bottom;


double-clicking the line in "Call Stack" will lead you  to the line when the problem arose;


typically the code causing a bad pointer address is not the code where the error is felt
for this error. you examine the pointer or pointers involved in the statement can ofter lead you to the problem;






(Testing the Extended Class)


思路:在基本功能测试成功后,继续加入拓展功能




(Finding the Next Bug)




(Debugging Dynamic Memory)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值