VSCode doesn't render multiple variables with the same name in the variables view. It only renders one of them. This is a situation that happens often when there are shadowed variables.
The nodejs debugger solves this by adding a number suffix to the variable, e.g. "x", "x2", "x3" are the different x variables in nested blocks.
In this patch I'm doing something similar, but the suffix is " @ <file_name:line>), e.g. "x @ main.cpp:17", "x @ main.cpp:21". The fallback would be an address if the source and line information is not present, which should be rare.
This fix is only needed for globals and locals. Children of variables don't suffer of this problem.
When there are shadowed variables
{F16182150}
Without shadowed variables
{F16182152}
Modifying these variables through the UI works
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D99989
27 lines
476 B
C++
27 lines
476 B
C++
|
|
#define BUFFER_SIZE 32
|
|
struct PointType {
|
|
int x;
|
|
int y;
|
|
int buffer[BUFFER_SIZE];
|
|
};
|
|
|
|
int g_global = 123;
|
|
static int s_global = 234;
|
|
|
|
int main(int argc, char const *argv[]) {
|
|
static float s_local = 2.25;
|
|
PointType pt = { 11,22, {0}};
|
|
for (int i=0; i<BUFFER_SIZE; ++i)
|
|
pt.buffer[i] = i;
|
|
int x = s_global - g_global - pt.y; // breakpoint 1
|
|
{
|
|
int x = 42;
|
|
{
|
|
int x = 72;
|
|
s_global = x; // breakpoint 2
|
|
}
|
|
}
|
|
return 0; // breakpoint 3
|
|
}
|