Issue 143710
Summary [LLDB] Language categories can't be disabled until a value was formatted
Labels
Assignees
Reporter Nerixyz
    (I feel like I mentioned this somewhere, but I can't find where)

Currently, all language categories are always [enabled by default](https://github.com/llvm/llvm-project/blob/775ad3e49c83407b79dd5ad533204884cb8b23ce/lldb/source/DataFormatters/LanguageCategory.cpp#L30) and the language categories are created on demand (in [`FormatManager::GetCategoryForLanguage`](https://github.com/llvm/llvm-project/blob/775ad3e49c83407b79dd5ad533204884cb8b23ce/lldb/source/DataFormatters/FormatManager.cpp#L601)). This makes it impossible to disable a language category upfront (e.g. in a `.lldbinit`). The following demonstrates this with the C++ language:

**test.cpp**:
```cpp
namespace std {
template <typename T> struct optional {
  T foo;
};
}

int main() {
  std::optional<int> test{42};
  return 0; // break here
}
```
```console
> clang -g test.cpp
> lldb.exe ./a.exe -o "type category disable cplusplus"  -o "b test.cpp:9" -o r -o "p test" -o "type category disable cplusplus" -o "p test"
(lldb) target create "a.exe"
Current executable set to 'F:\Dev\cpp-test\testing\a.exe' (x86_64).
(lldb) type category disable cplusplus
(lldb) b test.cpp:9
Breakpoint 1: where = a.exe`main + 18 at test.cpp:9, address = 0x0000000140007262
(lldb) r
Process 23684 launched: 'F:\Dev\cpp-test\testing\a.exe' (x86_64)
Process 23684 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff6b12d7262 a.exe`main at test.cpp:9
   6
   7    int main() {
   8      std::optional<int> test{42};
-> 9      return 0;
   10   }
(lldb) p test
(std::optional<int>)  Has Value=false  {}
(lldb) type category disable cplusplus
(lldb) p test
(std::optional<int>)  (foo = 42)
```

**Expected**: Both `p test` should print the same (`(std::optional<int>)  (foo = 42)`).
**Current**: The first time, the libstdc++ formatter is used to format the value even though we disabled the category.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to