Monday, December 04, 2006

VS2005 debugger - unable to resolve a symbol

VS2005 is a lot better then its predecessor in guessing what exactly do you mean when typing an expression into Watch window (or the cool Immediate view - try it if you havent used it before!). It will correctly evaluate all the variable references, and will even let you execute methods and see their results (but watch out for side-effects, if method modifies some data).

Occasionally, however, it will complain that it cannot find the symbol you are referring to. This can be rather frustrating, but there are actually a few things to try to resolve this successfully:

1) If you are using namespaces, type the fully qualified name, starting with the top namespace, e.g. MyNamespace::SubNamespace::blah. Sometimes VS2005 gets confused with the "using namespace" directives - but to be fair, most of the time its pretty good at it. This works 99% of the time.

2) Some constructs actually do not have proper C++ syntax to get to them, like local struct/class definitions. Last resort is to get a mangled name from the map file, and use that - VS2005 understands it as well.

3) Finally, be creative - there are usually several ways to get to a certain variable or method. If all fails, you can quickly write a dummy method which you can call from debugger, but this is rarely necessary.

No comments: