Skip to content

Commit

Permalink
ui: show instances of type
Browse files Browse the repository at this point in the history
Closes #188
  • Loading branch information
ivanyu committed Nov 20, 2022
1 parent 243e965 commit bd7d4bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pyheap-ui/src/pyheap_ui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def objects(address: int) -> str:

obj = heap.objects[address]

is_type_type = obj.type == heap.header.well_known_types.get("type")
type_instances = None
if is_type_type:
type_instances = [
addr for addr, obj in heap.objects.items() if obj.type == address
]
return render_template(
"objects.html",
tab_object_active=True,
Expand All @@ -121,6 +127,8 @@ def objects(address: int) -> str:
types=heap.types,
retained_heap=retained_heap,
well_known_container_type=well_known_container_types().get(obj.type),
is_type_type=is_type_type,
type_instances=type_instances,
)


Expand Down
24 changes: 23 additions & 1 deletion pyheap-ui/src/pyheap_ui/templates/objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h2 class="accordion-header" id="panelAttributesPublic">
<div class="accordion-item">
<h2 class="accordion-header" id="panelElements">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelElements-collapse" aria-expanded="false"
data-bs-target="#panelElements-collapse" aria-expanded="true"
aria-controls="panelElements-collapse">
Elements
</button>
Expand All @@ -166,6 +166,28 @@ <h2 class="accordion-header" id="panelElements">
</div>
{% endif %}

{% if is_type_type %}
<div class="accordion-item">
<h2 class="accordion-header" id="panelInstances">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#panelInstances-collapse" aria-expanded="false"
aria-controls="panelInstances-collapse">
Type instances
</button>
</h2>
<div id="panelInstances-collapse" class="accordion-collapse collapse"
aria-labelledby="panelInstances">
<div class="accordion-body text-truncate overflow-scroll">
<ul class="list-unstyled">
{% for addr in type_instances %}
<li>{{ render_element(addr) }}
{% endfor %}
</ul>
</div>
</div>
</div>
{% endif %}

<div class="accordion-item">
<h2 class="accordion-header" id="panelReferents">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
Expand Down

0 comments on commit bd7d4bb

Please sign in to comment.