[PATCH] D117779: [LLDB] Add formatters for PointerIntPair, PointerUnion

Dave Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 20 10:00:37 PST 2022


kastiglione added a comment.

Thanks for doing this! I have not used `PointerIntPair` or `PointerUnion`, but I will take a look at those types. I take it these expression evaluations are necessary?



================
Comment at: llvm/utils/lldbDataFormatters.py:175
         max_length = 256
-        length = valobj.GetChildAtIndex(1).GetValueAsUnsigned(max_length)
+        length = min(max_length, valobj.GetChildAtIndex(1).GetValueAsUnsigned(max_length))
         if length == 0:
----------------
when the string length is greater than `max_length`, it would be nice for the returned string to indicate truncation. I just checked a long `std::string` and the output was:

```
"really long string"...
```

Also the max length for `std::string` is 1024, should `StringRef` use 1024 too?


================
Comment at: llvm/utils/lldbDataFormatters.py:182-183
+        string = data.ReadRawData(error, 0, data.GetByteSize()).decode()
+        if error.Fail():
+            return None
+        return '"%s"' % string
----------------
should this print an error message?


================
Comment at: llvm/utils/lldbDataFormatters.py:184
+            return None
+        return '"%s"' % string
+    return None
----------------
what's the best way to handle quotes inside the string? A quick search shows this could use `json` (a hack):

```
return json.dumps(string)
```

for example:

```
json.dumps('hello world') # '"hello world"'
json.dumps('hello "quoted" world') # '"hello \\"quoted\\" world"'
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117779/new/

https://reviews.llvm.org/D117779



More information about the llvm-commits mailing list