================
@@ -228,7 +228,24 @@ void SetValueForKey(lldb::SBValue &v, llvm::json::Object
&object,
strm << "<error: " << error.GetCString() << ">";
} else {
auto tryDumpSummaryAndValue = [&strm](lldb::SBValue value) {
- llvm::StringRef val = value.GetValue();
+ std::string val;
+ // Whenever the value is a non-synthetic address, we format it ourselves
+ // to use as few chars as possible because the variables pane on VS Code
+ // is by default narrow.
+ if (!value.IsSynthetic() && value.GetType().IsPointerOrReferenceType()) {
+ lldb::addr_t address = value.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+ if (address == LLDB_INVALID_ADDRESS) {
+ val = "<invalid address>";
+ } else if (address == 0) {
+ val = "<null>";
+ } else {
+ llvm::raw_string_ostream os(val);
+ os << llvm::format_hex(address, 0);
+ }
----------------
clayborg wrote:
I wouldn't mess with the values or try to display them in any fancy way, I
would always use:
```
llvm::raw_string_ostream os(val);
os << llvm::format_hex(address, 0);
```
Users might encode -1 into their pointers as a special value and you wouldn't
want to see "<invalid address>" as the value. Also I would rather see "0x0"
instead of "<null>".
https://github.com/llvm/llvm-project/pull/66534
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits