Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

invoking functions while debugging with Visual Studio 2005?

Here's something I know is probably possible but I've never managed to do
In VS2005(C++), While debugging, to be able to invoke a function from the code which I'm debugging.
This feature is sometimes essential when debugging complex data structures which can't be explored easily using just the normal capabilities of the watch window.
The watch window seem to allow writing function calls but every time I try it it gives me one error or another.

Error: symbol "func" not found
Error: argument list does not match function
Error: member function not present

Did anyone ever succeed in making this work properly? What am I missing here?

Edit: clearly, the function called should be a symbol that exists in the current scope the debugger is in.

like image 666
shoosh Avatar asked Nov 07 '08 02:11

shoosh


People also ask

How do I Debug in Visual Studio 2005?

If you are inside of Visual Studio with an open project, you can use the Debug menu to get started. The “Start” and “Step Into” commands will both launch your application and begin a debugging session. A second option is to use the “Attach to Process…” command on the Debug menu.

How do you Debug a function?

To debug a function which is defined inside another function, single-step through to the end of its definition, and then call debug on its name. If you want to debug a function not starting at the very beginning, use trace(..., at = *) or setBreakpoint .

How do you Debug a function in C#?

To start debugging, select F5, or choose the Debug Target button in the Standard toolbar, or choose the Start Debugging button in the Debug toolbar, or choose Debug > Start Debugging from the menu bar. The app starts and the debugger runs to the line of code where you set the breakpoint.


1 Answers

Ok, Here's what I found
CXX0040 means that "The C expression evaluator does not support implicit conversions involving constructor calls."
CXX0047 means that "Overloaded functions can be called only if there is an exact parameter match or a match that does not require the construction of an object."

So combined it means that If I want to call a function none of the arguments should have an implicit conversion and none of the arguments should need a construction.
"implicit conversion" in this context seem to include trivial things like converting 'String' to 'const String&'.
"construction" seem to include trivial copy-construction. so passing by value anything that is not a primitive type will result in an error.

So this basically leaves functions that take only primitive types or pointers.
I have just tested this theory successfully.

So if you want to be able to call a method from the watch window, add an overload which takes only pointers and primitives and in the watch window pass the arguments appropriately. To pass an object that is not a primitive pass its address.

like image 187
shoosh Avatar answered Nov 14 '22 19:11

shoosh