| Issue |
176760
|
| Summary |
LLDB formatters should be target-specific
|
| Labels |
lldb
|
| Assignees |
|
| Reporter |
Michael137
|
Currently type summaries/synthetic providers are global (shared between debugger instances). But a type with the same name might be implemented differently between two debugger sessions (or even targets). We should make the format management target-specific.
Below is an example:
Consider this C++ program:
```
struct Foo {};
int main() {
Foo f;
__builtin_debugtrap();
}
```
Compiled as `clang++ -g main.cpp -o ~/a.out` on macOS.
Then run the following (e.g., on macOS run `xcrun python3 debuggers.py`):
```
import lldb
import os
def get_new_debugger():
dbg = lldb.SBDebugger.Create()
dbg.SetAsync(False)
target = dbg.CreateTarget("~/a.out")
assert target
process = target.LaunchSimple(None, None, os.getcwd())
assert process
assert process.GetState() == lldb.eStateStopped
th = process.GetSelectedThread()
assert th
frame = th.GetSelectedFrame()
assert frame.name == "main"
return dbg, frame
d1, f1 = get_new_debugger()
d1.HandleCommand("type summary add -x Foo --summary-string 'Test Summary'")
assert f1.FindVariable("f").GetSummary() == "Test Summary"
d2, f2 = get_new_debugger()
assert f2.FindVariable("f").GetSummary() == "Test Summary"
lldb.SBDebugger.Destroy(d1)
lldb.SBDebugger.Destroy(d2)
```
Note how we only added a type summary for `Foo` in one of the debugger instances, but it still applied to the other instance.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs