Files
clang-p2996/lldb/test/API/tools/lldb-vscode/variables/main.cpp
Walter Erquinigo c9a0754b44 [lldb-vscode] Distinguish shadowed variables in the scopes request
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
2021-04-21 15:09:39 -07:00

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
}