开发者

Debugging "one line" methods

imagine (in header file):

int getInt() { return m_intValue; }

and

int getInt() 
{
    retur开发者_如何学编程n m_intValue;
}

how can I debug first example, to see m_intValue? In example 2, I can set breakpoint at line one, press F10(step over) and then see (after hovering m_intValue) what is in m_intValue. Or just add BP at return m_intValue line.

But when I place BP at line in first version, I can not see debug infos of m_intValue.

This example is just demonstrative. I know I can see value in place, where I call getInt (see as returning value). But in more complicated cases (e.g. returning value modified because of something going out of scope) I really want to see m_intValue in time of processing return.

Hope you understand my question.

Thank you!


You'll get the breakpoint set at the wrong code. It breaks on the function entrypoint, the this variable won't be initialized yet. You definitely want to favor the 2nd coding style if you want to debug these accessors. Which you shouldn't, it doesn't have a bug.

If you really need to inspect the object with the code written in the 1st snippet then switch to disassembly view and single-step past the stack frame setup code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜