I have a member variable struct in a C++ class I'm debugging in Visual Studio 2008 Professional. I would like to break any time the struct changes. Is it possible to do this, or must I look for every possible point in the code it could change, and set breakpoints there?
If you can determine the address of the member, you can set a data breakpoint on it:
https://msdn.microsoft.com/en-us/library/5557y8b4.aspx#BKMK_Set_a_data_change_breakpoint__native_C___only_
Related
I am trying to get Visual Studio to stop on a breakpoint anytime a variable I am calling it accessed.
For example:
float someNum=0;
is initialized but never changed. If I say,
float someOtherNum=someNum;
OR
someFunction(someNum);
How can I have Visual Studio stop at this reference? Should I be using breakpoints for this or is there some other tool that Visual Studio has?
Please not the reason that I am not just looking for "someNum" is because it is simplified from someObject->someOtherObject->someNum and there are lots of calls with different structures accessing this variable.
Edit:
I have used the visual studio Data Breakpoint. This does not seem to be a solution to my problem as the Data Breakpoint seems to be reliant on changing the value of the variable and not just when the memory is accessed for its variable.
You can use a watchpoint in VS. Here is a link to a tutorial: http://www.youtube.com/watch?v=JPBnbhbVFjY
We are doing QT development in Visual Studio 2010. I would like to be able to see the contents of A QDomNode variable in the Visual Studio Debugger.
It is possible to customize the display of variables in the Visual Studio Debugger by customizing the autoexp.dat file. The QT Add in for Visual Studio adds many customizations to autoexp.dat that enable you to see relevant information for QT classes, and there are a number of discussions on customizing the autoexep.dat that include a customization for QDomNode that appear to originate from this Daniel Albuschat blog entry QT Debugging with Visual Studio 2005. However, QDomNode is still not visible to me even with the described modifcations to autoexp.dat.
I notice that QDomNode uses a member variable QDomNodePrivate* impl as a PIMPL to hide its data members behind. This is similar to the "d" pointer commonly used in QT, notably in QString, which is able to see data correctly... Any pointers would be appreciated...
A simple preview would be:
QDomNode|*::QDomNode{
preview ($e.impl->name)
}
But this does not really work, because the debugger can see the structure of impl only when it is "inside" qdom.cpp wich contains the definition of QDomNodePrivate. You can test this by stepping inside some QDom method. One "hacky" solution would be to copy the class definition of QDomNodePrivate into some header file that you include in your program.
And don't forget: You have to be Administrator to successfully edit autoexp.dat!
I'm using the visual studio POCO Template for the Entity Framework, so far it has worked great, but since my database/tables are not Upper Cammel Case, but UPPER case, every time that i need to regenerate the entities, i also need to (manually) change the entities on the edmx to be upper cammel case... which is really annoying
what i would like to do is to change the template to translate the Database tables and columns to upper cammel case E.G.
MY_TABLE_NAME => MyTableName
For that i need to understand how the template (tt file) works, and if possible debugg it to know where the change needs to be made.
Thanks!
Grab a T4 template editor from the visual studio gallery. Don't worry, they all suck in one way or another.
A T4 template is about as complex as an ASPX page without codebehind. Its pretty simple to edit them. As for debugging, I believe you have to spin up one instance of Visual Studio and debug it by attaching another instance. Its a bit of a daunting task for someone without a lot of experience.
Depending on yours, the best thing might be to create a simple console application that has a single method to adjust your table names, then copypaste (please don't downvote me!) that method body into your T4 template.
You can include in the T4's C# code a call to
System.Diagnostics.Debugger.Break();
then when executed will "hit" the breakpoint, and ask to attach the debugger, attach Visual Studio (the 2nd Visual Studio will be debugging the first Visual Studio).
In Visual Studio 2010 sometimes when I want to get the value of a variable while debugging, it tells me that it "does not exist in this context" when it obviously does.
I have found that if I use the variable, as in the screenshot below, then it is able to show it.
Has anyone experienced this? Visual Studio 2008 never did this.
How can I get Visual Studio 2010 to always show me variable values while debugging?
alt text http://www.deviantsart.com/upload/jcnr1s.png
Hazarding a guess..
Could it be that your running in Release mode and the variable has been optimized out? Once you actually use the value, then it no longer can optimize the value out?
Is GetListOfFileNames() deferring execution? Try tacking .ToList() on it.
Is there a way to debug code on Visual C++ 2008 Express, such as I can watch a variable for certain value(s) and, when it assumes this value, to break?
For instance, I want to break when xbecomes 5. In gdb I would set a breakpoint then a condition that x == 5. How can I do it (if possible) on Visual C++ 2008 Express?
Although built in support for it is missing in the express editions, there is another way around it.
I found this on another answer for a similar question.
#if DEBUG
if( node.Name == "Book" )
System.Diagnostics.Debugger.Break();
#endif
The example shows that if the Name property matches "Book", a breakpoint occurs.
Here is the original question:
How Do I: Create a Breakpoint Using Conditions? [C# Express]
This is not possible in the Express versions of Visual Studio. But it is possible in the full versions.
It seems it's possible to do this even in express, at least here it worked. After marking the breakpoint, I right-clicked on its mark, and set a "Condition" (it couldn't be easier than that)
!Setting a condition
Then you can write an expression which evaluates to true. My colleague who has just showed this to me said they have some issues using this for comparing strings, but it's pretty neat for simple comparisons using ints.
!Condition window
However, as said in the other answer, this is not so fast as typing the break code directly.
Lucky! Visual Studio 2010 Express of C/C++ does support it. See How to: Specify a Breakpoint Condition.
I've tried it.