How to set breakpoint by function name inside anonymous namespace in Visual Studio?

余生颓废 提交于 2019-12-07 03:16:41

问题


I have the following code:

namespace
{
    void Foo()
    {
    }
}

namespace Bar
{
    void Foo()
    {
    }
}

int main()
{
    Foo();
    Bar::Foo();

    return 0;
}

I want to put breakpoint on Foo() inside anonymous namespace by name (Ctrl+B key binding). I can do it for function inside named namespace Bar with no problem by name Bar::Foo. I tried anonymous namespace::Foo for anonymous namespace but VS fails to parse this name, i guess because of whitespace character in name. Also I tried to put different quotation marks but with no luck. Is it possible at all to put this breakpoint?


回答1:


I encountered a similar problem a long time ago (Debugging data in 'anynomous namespaces' (C++)). I wanted to look at the value of a data member in an unnamed namespace, but I couldn't get this done.

Finally, somebody pointed me to http://msdn.microsoft.com/en-us/library/0888kc6a%28VS.80%29.aspx. Maybe you can get the decorated function name and put a breakpoint on that.




回答2:


It looks like Visual Studio can't set breakpoint by function name inside anonymous namespace. Even WinDbg can't do this.

If you have sources you can set breakpoint by line.



来源:https://stackoverflow.com/questions/7388104/how-to-set-breakpoint-by-function-name-inside-anonymous-namespace-in-visual-stud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!