-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Delete some GDB debugvis cruft #154195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+64
−312
Closed
Delete some GDB debugvis cruft #154195
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,10 @@ | ||
| from sys import version_info | ||
|
|
||
| import gdb | ||
|
|
||
| if version_info[0] >= 3: | ||
| xrange = range | ||
|
|
||
| ZERO_FIELD = "__0" | ||
| FIRST_FIELD = "__1" | ||
|
|
||
|
|
||
| def unwrap_unique_or_non_null(unique_or_nonnull): | ||
| # BACKCOMPAT: rust 1.32 | ||
| # https://github.com/rust-lang/rust/commit/7a0911528058e87d22ea305695f4047572c5e067 | ||
| # BACKCOMPAT: rust 1.60 | ||
| # https://github.com/rust-lang/rust/commit/2a91eeac1a2d27dd3de1bf55515d765da20fd86f | ||
| ptr = unique_or_nonnull["pointer"] | ||
| return ptr if ptr.type.code == gdb.TYPE_CODE_PTR else ptr[ptr.type.fields()[0]] | ||
|
|
||
|
|
@@ -33,30 +24,6 @@ def unwrap_scalar_wrappers(wrapper): | |
| printer_base = object | ||
|
|
||
|
|
||
| class EnumProvider(printer_base): | ||
| def __init__(self, valobj): | ||
| content = valobj[valobj.type.fields()[0]] | ||
| fields = content.type.fields() | ||
| self._empty = len(fields) == 0 | ||
| if not self._empty: | ||
| if len(fields) == 1: | ||
| discriminant = 0 | ||
| else: | ||
| discriminant = int(content[fields[0]]) + 1 | ||
| self._active_variant = content[fields[discriminant]] | ||
| self._name = fields[discriminant].name | ||
| self._full_name = "{}::{}".format(valobj.type.name, self._name) | ||
| else: | ||
| self._full_name = valobj.type.name | ||
|
|
||
| def to_string(self): | ||
| return self._full_name | ||
|
|
||
| def children(self): | ||
| if not self._empty: | ||
| yield self._name, self._active_variant | ||
|
Comment on lines
-36
to
-57
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mentioned in other file, but this is older GDB support. |
||
|
|
||
|
|
||
| class StdStringProvider(printer_base): | ||
| def __init__(self, valobj): | ||
| self._valobj = valobj | ||
|
|
@@ -131,7 +98,7 @@ def to_string(self): | |
|
|
||
| def children(self): | ||
| return _enumerate_array_elements( | ||
| self._data_ptr + index for index in xrange(self._length) | ||
| self._data_ptr + index for index in range(self._length) | ||
| ) | ||
|
|
||
| def num_children(self): | ||
|
|
@@ -155,7 +122,7 @@ def to_string(self): | |
|
|
||
| def children(self): | ||
| return _enumerate_array_elements( | ||
| self._data_ptr + index for index in xrange(self._length) | ||
| self._data_ptr + index for index in range(self._length) | ||
| ) | ||
|
|
||
| def num_children(self): | ||
|
|
@@ -171,10 +138,7 @@ def __init__(self, valobj): | |
| self._valobj = valobj | ||
| self._head = int(valobj["head"]) | ||
| self._size = int(valobj["len"]) | ||
| # BACKCOMPAT: rust 1.75 | ||
| cap = valobj["buf"]["inner"]["cap"] | ||
| if cap.type.code != gdb.TYPE_CODE_INT: | ||
| cap = cap[ZERO_FIELD] | ||
| cap = valobj["buf"]["inner"]["cap"][ZERO_FIELD] | ||
| self._cap = int(cap) | ||
| self._data_ptr = unwrap_unique_or_non_null(valobj["buf"]["inner"]["ptr"]) | ||
| ptr_ty = gdb.Type.pointer(valobj.type.template_argument(0)) | ||
|
|
@@ -186,7 +150,7 @@ def to_string(self): | |
| def children(self): | ||
| return _enumerate_array_elements( | ||
| (self._data_ptr + ((self._head + index) % self._cap)) | ||
| for index in xrange(self._size) | ||
| for index in range(self._size) | ||
| ) | ||
|
|
||
| def num_children(self): | ||
|
|
@@ -292,17 +256,14 @@ def cast_to_internal(node): | |
| internal_type = gdb.lookup_type(internal_type_name) | ||
| return node.cast(internal_type.pointer()) | ||
|
|
||
| if node_ptr.type.name.startswith("alloc::collections::btree::node::BoxedNode<"): | ||
| # BACKCOMPAT: rust 1.49 | ||
| node_ptr = node_ptr["ptr"] | ||
| node_ptr = unwrap_unique_or_non_null(node_ptr) | ||
| leaf = node_ptr.dereference() | ||
| keys = leaf["keys"] | ||
| vals = leaf["vals"] | ||
| edges = cast_to_internal(node_ptr)["edges"] if height > 0 else None | ||
| length = leaf["len"] | ||
|
|
||
| for i in xrange(0, length + 1): | ||
| for i in range(length + 1): | ||
| if height > 0: | ||
| child_ptr = edges[i]["value"]["value"][ZERO_FIELD] | ||
| for child in children_of_node(child_ptr, height - 1): | ||
|
|
@@ -367,73 +328,6 @@ def display_hint(): | |
| return "map" | ||
|
|
||
|
|
||
| # BACKCOMPAT: rust 1.35 | ||
| class StdOldHashMapProvider(printer_base): | ||
| def __init__(self, valobj, show_values=True): | ||
| self._valobj = valobj | ||
| self._show_values = show_values | ||
|
|
||
| self._table = self._valobj["table"] | ||
| self._size = int(self._table["size"]) | ||
| self._hashes = self._table["hashes"] | ||
| self._hash_uint_type = self._hashes.type | ||
| self._hash_uint_size = self._hashes.type.sizeof | ||
| self._modulo = 2**self._hash_uint_size | ||
| self._data_ptr = self._hashes[ZERO_FIELD]["pointer"] | ||
|
|
||
| self._capacity_mask = int(self._table["capacity_mask"]) | ||
| self._capacity = (self._capacity_mask + 1) % self._modulo | ||
|
|
||
| marker = self._table["marker"].type | ||
| self._pair_type = marker.template_argument(0) | ||
| self._pair_type_size = self._pair_type.sizeof | ||
|
|
||
| self._valid_indices = [] | ||
| for idx in range(self._capacity): | ||
| data_ptr = self._data_ptr.cast(self._hash_uint_type.pointer()) | ||
| address = data_ptr + idx | ||
| hash_uint = address.dereference() | ||
| hash_ptr = hash_uint[ZERO_FIELD]["pointer"] | ||
| if int(hash_ptr) != 0: | ||
| self._valid_indices.append(idx) | ||
|
|
||
| def to_string(self): | ||
| if self._show_values: | ||
| return "HashMap(size={})".format(self._size) | ||
| else: | ||
| return "HashSet(size={})".format(self._size) | ||
|
|
||
| def children(self): | ||
| start = int(self._data_ptr) & ~1 | ||
|
|
||
| hashes = self._hash_uint_size * self._capacity | ||
| align = self._pair_type_size | ||
| len_rounded_up = ( | ||
| ( | ||
| (((hashes + align) % self._modulo - 1) % self._modulo) | ||
| & ~((align - 1) % self._modulo) | ||
| ) | ||
| % self._modulo | ||
| - hashes | ||
| ) % self._modulo | ||
|
|
||
| pairs_offset = hashes + len_rounded_up | ||
| pairs_start = gdb.Value(start + pairs_offset).cast(self._pair_type.pointer()) | ||
|
|
||
| for index in range(self._size): | ||
| table_index = self._valid_indices[index] | ||
| idx = table_index & self._capacity_mask | ||
| element = (pairs_start + idx).dereference() | ||
| if self._show_values: | ||
| yield "key{}".format(index), element[ZERO_FIELD] | ||
| yield "val{}".format(index), element[FIRST_FIELD] | ||
| else: | ||
| yield "[{}]".format(index), element[ZERO_FIELD] | ||
|
|
||
| def display_hint(self): | ||
| return "map" if self._show_values else "array" | ||
|
|
||
|
|
||
| class StdHashMapProvider(printer_base): | ||
| def __init__(self, valobj, show_values=True): | ||
| self._valobj = valobj | ||
|
|
@@ -464,10 +358,6 @@ def __init__(self, valobj, show_values=True): | |
| def _table(self): | ||
| if self._show_values: | ||
| hashbrown_hashmap = self._valobj["base"] | ||
| elif self._valobj.type.fields()[0].name == "map": | ||
| # BACKCOMPAT: rust 1.47 | ||
| # HashSet wraps std::collections::HashMap, which wraps hashbrown::HashMap | ||
| hashbrown_hashmap = self._valobj["map"]["base"] | ||
| else: | ||
| # HashSet wraps hashbrown::HashSet, which wraps hashbrown::HashMap | ||
| hashbrown_hashmap = self._valobj["base"]["map"] | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes Python 2 support, which was probably broken anyway. Not really possible to say.