Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 660
ks1322 Avatar asked Sep 12 '11 12:09

ks1322


People also ask

How do I set breakpoint conditions in Visual Studio?

Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.

How do I add a breakpoint to all methods in visual studio?

Press F3 and then press F9 to add a breakpoint.

What does breakpoint mean in Visual Studio?

Breakpoints are the most basic and essential feature of reliable debugging. A breakpoint indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run.


1 Answers

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.

like image 109
Patrick Avatar answered Oct 12 '22 22:10

Patrick