[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 08:12:31 PST 2020


dblaikie added inline comments.


================
Comment at: debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb:42-47
+# CHECK: llvm::PointerIntPair = {pointer = {{.*}}, value = 1}
+p PointerIntPair
+
+# CHECK: llvm::PointerUnion containing int * = {pointer = {{.*}}}
+p PointerUnion
+
----------------
If you aren't testing the pointer value anyway, you could make it null & then you can test directly for that?


================
Comment at: llvm/utils/gdb-scripts/prettyprinters.py:324
+    try:
+      name = val.type.template_argument(3).name + '::NumLowBitsAvailable'
+      bits_available = gdb.parse_and_eval(name)
----------------
Any chance of avoiding stringification/parsing here? could this be written as val.type.template_argument(3)['NumLowBitsAvailable'] instead? (I'm guessing not, but figured I'd check)

Oh, looks like maybe that does work: https://sourceware.org/gdb/current/onlinedocs/gdb/Types-In-Python.html - though it seems maybe gdb.Fields can only provide their value if they're an enum (enumval), maybe not if they're static? Even if the final name has to be stringified and eval'd - it'd still be nice to avoid string concatenation to create the name, if reasonably feasible.




================
Comment at: llvm/utils/gdb-scripts/prettyprinters.py:327-328
+    except:
+      # Above fails if NumLowBitsAvailable is an enum or is optimized away.
+      bits_available = pointer_type.target().alignof.bit_length() - 1
+    value_mask = (1 << bits_available) - 1
----------------
Might be best just to say we can't print this thing if the trait isn't available, to err on the safe side of not giving possibly incorrect/misleading information?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557





More information about the llvm-commits mailing list