Segger Embedded Studio can not watch struct variable - debugging

Debug STM32F103, can not watch struct variable, which displayed as array.

Related

How to create a temporary variables on the fly in the Immediate Window in MSVS 2013

I've seen on this page that temporary variables can be declared in MSVS.
Here is another Tricks (sic), you can use some “temp” variable to store those data. But you have to declare the variable at “Immediate Window”. [ Please read Tips 3 to know more about using Immediate window with Watch Window ]
However, this doesn't appear to actually work. If I were to do this for instance:
int test;
I get a type name is not allowed. If I do this:
CString s;
I get an identifier "s" is undefined.
Looking at Tip 3 doesn't appear to help.
Considering that this article is dated 2010, I'm assuming that this is for MSVS 2010, but I'd like to get this to work for MSVS 2013.

variable using array 2D

I am writing a program on Visual Studio 2010, and declaring a variable as follows :
int image[512][512];
and the program run well. But when I modify the program as follows:
int image1[512][512];
int image2[512][512];
it is ok when compiling, but error when execution. The program stopped. Any suggestion?
Are you declaring these as non-static local variables? If so, you may be overflowing the (not too big) stack.

Visual studio 2010: how to watch a memory hex location

I tried some suggestions found online but it does not work for me. Im using Visual Studio 2010. Basically I typed loc(kcs(1,4)) (thats my variable) and I obtained 157510036. Its hex is 9636994. So then I typed (INTEGER*)0x9636994 but on the watch window under the "value"column it says "undefined variable INTEGER". I trid lowercase integer or real and same answer. Any suggestion?
I typed (INTEGER*)0x9636994 but on the watch window under the "value"column it says "undefined variable INTEGER".
According to Restrictions on Native C++ Expressions:
Type Casting
If you cast to a type, the type must be known to the debugger. You must have another object of that type in your program. Types created using typedef statements are not supported.
Try using the underlying type. So, for example, if INTEGER is actually an int you would try to watch (int *)0x9636994.
This also assumes that the variable is fixed at 0x9636994 (basically that you're not trying to refer to something transient on the stack).

Getting a List of Symbols Used by My VC++ Code

I am building a tool that process my VC++ source codes. For this, I need to obtain a list of symbols including local variable names and their types used by my codes. I know Visual C++ 2010 already provides a .bsc file that allows the object browser to locate symbols quickly. But this is an interactive tool. I need to obtain a list of the symbols in a file. Is there any tools allowing us to programmatically obtain the list of symbols used in our own VC++ source codes?
I tried the Debug Interface Access SDK provided by Microsoft. It allows us to read the .pdb file for the names of the local variables used. But I also want to obtain the exact type names used in my source codes. e.g.
MYTYPE dwordVar;
DIA SDK allows us to obtain the string "dwordVar" which is the name of a local variable. But it cannot tell its type name is "MYTYPE". It can only tell us what MYTYPE really represents (like unsigned long). But not the symbol "MYTYPE".
If Visual C++ isnt offering this feature, is there any third party tools supporting this feature?
Experimenting with this program:
typedef unsigned long MYTYPE;
int wmain(int argc, wchar_t *argv[])
{
MYTYPE test = 99LU;
}
both DIA SDK and DbgHelp return 16 (SymTagBaseType) for the symtype of the type symbol for test. It would be nice if the type symbol were a Typedef symbol (17/SymTagTypedef), but it might be that the PDB itself does not record whether the source file used a typedef or type name in declaring the type of the local variable.
One possible work-around is to enumerate the SymTagTypedef children of the global scope symbol, building a std::multimap from type IDs of the types to the typedef names. Then, for each local variable, if the multimap contains entries for the Data symbol's type ID (obtained via IDiaSymbol::get_typeId), use the IDiaSession::findLines method to figure out the line(s) on which the Data symbol is declared and search those lines for any of the typedef name strings, possibly performing preprocessing before searching.

What do question marks (???) in Visual Studio watch window signify?

I've run into an exception and looking at variables in the watch window, I'm seeing some question marks (???). Does this mean it's pointing to an invalid address?
It means that the debugger can't figure out its value.
For example, you see this quite a bit if your code involves HWNDs. If you look through the Windows header files, it's defined like this via a macro:
struct HWND__{int unused;}; typedef struct HWND__ *HWND;
So the type of HWND is really the type "pointer to an HWND__". However, the HWND values you get from functions like CreateWindow() aren't actually pointers to anything.
But the debugger will try to figure out the value of the unused member in the struct, but can't do it:
You will also see these kinds of errors when the watched variable has bad or missing type information.
Is this a C++ style project?
The debugger typically uses the "???" string when it is able to evaluate an expression but is unable to garner any type information for a specific part of the display. This typically occurs because of missing or incorrect PDB symbols.
There is likely a way for this to occur if the expression is accessing corrupted data (overriten virtual tables or RTTI). But I do not 100% know if that is true.
Usually it means the pointer or reference is pointing to inaccessible memory, and thus it cannot get the value to present. For example, if you have a pointer that's supposed to point to a Foo, the debugger will normally interpret the bits that the pointer points to as a Foo--whether the pointer is valid or not. But in some cases, a wild pointer might point to a location that's not even mapped in the process space. In that case, the debugger cannot get the bits.

Resources