[all-commits] [llvm/llvm-project] c9a075: [lldb-vscode] Distinguish shadowed variables in th...

walter erquinigo via All-commits all-commits at lists.llvm.org
Wed Apr 21 15:10:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c9a0754b443ba73623574db880a7b0b14826fedb
      https://github.com/llvm/llvm-project/commit/c9a0754b443ba73623574db880a7b0b14826fedb
  Author: Walter Erquinigo <a20012251 at gmail.com>
  Date:   2021-04-21 (Wed, 21 Apr 2021)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
    M lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
    M lldb/test/API/tools/lldb-vscode/variables/main.cpp
    M lldb/tools/lldb-vscode/JSONUtils.cpp
    M lldb/tools/lldb-vscode/JSONUtils.h
    M lldb/tools/lldb-vscode/lldb-vscode.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list