[utils] Fix DenseMap debugger printers for the packed used-bit array#201755
Merged
Conversation
DenseMap no longer use in-band sentinel keys. (llvm#200595 and llvm#201281). Update the GDB pretty printer and LLDB data formatters to test the used bit rather than comparing keys. GDB: advancePastEmptyBuckets relied on DenseMapInfo::getEmptyKey(), which could not be evaluated in GDB and so was disabled, leaving the printer to emit empty and erased buckets. It now walks bucket indices and skips any whose used bit is clear. LLDB: DenseMapSynthetic used a key-uniqueness heuristic to guess which buckets were live, which mishandled a lone erased bucket (hence the former tombstones=1 summary note). It now reads the used array directly, so erased entries are skipped exactly. NumTombstones no longer exists, so drop it from the summary. Written by Claude Opus 4.8
Member
Author
|
test scripts |
aengelke
reviewed
Jun 5, 2026
Contributor
aengelke
left a comment
There was a problem hiding this comment.
Looks ok? I never used these (and also never wrote debugger printers myself), so I'm probably not the best person to review this...
kastiglione
reviewed
Jun 7, 2026
Comment on lines
493
to
+496
| for index in range(num_buckets): | ||
| bucket = buckets.GetValueForExpressionPath(f"[{index}]") | ||
| key = bucket.GetChildAtIndex(0) | ||
| key_buckets[str(key.data)].append(index) | ||
|
|
||
| # Heuristic: This is not a multi-map, any repeated (non-unique) keys are | ||
| # either the the empty key or the tombstone key. Populate child_buckets | ||
| # with the indexes of entries containing unique keys. | ||
| for indexes in key_buckets.values(): | ||
| if len(indexes) == 1: | ||
| self.child_buckets.append(indexes[0]) | ||
| word = used.GetValueForExpressionPath(f"[{index >> 5}]").unsigned | ||
| if (word >> (index & 31)) & 1: | ||
| self.child_buckets.append(index) |
Contributor
There was a problem hiding this comment.
I haven't tested it with the updated DenseMap, but I suggest avoiding calling GetValueForExpressionPath("[N]") 32 times for each N, by doing something like:
used_data = used.GetPointeeData(0, num_buckets // 32)
for word_idx, word in enumerate(used_data.uint32):
for bit in range(32):
if (word >> bit) & 1:
self.child_buckets.append(word_idx * 32 + bit)
Member
Author
There was a problem hiding this comment.
Thx for the suggestion! Changed num_buckets // 32 to (N+31)//32, since the number of buckets can be 4/8/16, smaller than 32.
kastiglione
reviewed
Jun 8, 2026
kastiglione
approved these changes
Jun 8, 2026
Contributor
kastiglione
left a comment
There was a problem hiding this comment.
Approving the lldb formatter. Thank you.
Co-authored-by: Dave Lee <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DenseMap no longer use in-band sentinel keys. (#200595 and #201281).
Update the GDB pretty printer and LLDB data formatters to test the used
bit rather than comparing keys.
GDB: advancePastEmptyBuckets relied on DenseMapInfo::getEmptyKey(), which
could not be evaluated in GDB and so was disabled, leaving the printer to
emit empty and erased buckets. It now walks bucket indices and skips any
whose used bit is clear.
LLDB: DenseMapSynthetic used a key-uniqueness heuristic to guess which
buckets were live, which mishandled a lone erased bucket (hence the
former tombstones=1 summary note). It now reads the used array directly,
so erased entries are skipped exactly. NumTombstones no longer exists, so
drop it from the summary.
Written by Claude Opus 4.8