Skip to content
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

Helper files for debuggers #1158

Merged
merged 12 commits into from
Nov 9, 2023
37 changes: 37 additions & 0 deletions src/debug/gdb/conduit-gdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
# other details. No copyright assignment is required to contribute to Conduit.

import gdb.printing
import itertools


class HostDevicePtrPrinter:
"""Print a host_device_ptr object."""

def __init__(self, val):
self.val = val

def to_string(self):
num_elements = self.val['m_elems']

if num_elements > 0:
return "{{ size = {0} }}".format(num_elements)
else:
return "nullptr"

def display_hint(self):
return 'array'

def children (self):
for i in range(self.val['m_elems']):
yield "[{0}]".format(i), self.val['m_active_pointer'][i]


def build_pretty_printer():
pp = gdb.printing.RegexpCollectionPrettyPrinter("care")
pp.add_printer('host_device_ptr', 'host_device_ptr', HostDevicePtrPrinter)
return pp


gdb.printing.register_pretty_printer(gdb.current_objfile(), build_pretty_printer())
78 changes: 78 additions & 0 deletions src/debug/msvs/ConduitNode.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="conduit::Node">
<!-- Node can be empty, object, list, or leaf. -->
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_EMPTY_ID">empty conduit::Node</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_OBJECT_ID">object {{ size: { m_children.size() } }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_LIST_ID">list {{ size: { m_children.size() } }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_INT8_ID">int8 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_INT16_ID">int16 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_INT32_ID">int32 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_INT64_ID">int64 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_UINT8_ID">uint8 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_UINT16_ID">uint16 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_UINT32_ID">int32 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_UINT64_ID">int64 {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_FLOAT32_ID">float {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_FLOAT64_ID">double {{ size: {m_schema->m_dtype.m_num_ele} }}</DisplayString>
<DisplayString Condition="m_schema->m_dtype.m_id == CONDUIT_CHAR8_STR_ID">string: { (char *)m_data }</DisplayString>
<DisplayString>leaf value</DisplayString>
<Expand>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_LIST_ID">
<Size>m_children.size()</Size>
<ValuePointer>m_children._Mypair._Myval2._Myfirst</ValuePointer>
</ArrayItems>
<CustomListItems Condition="m_schema->m_dtype.m_id == CONDUIT_OBJECT_ID">
<Variable Name="i" InitialValue="0"/>
<Variable Name="hier" InitialValue="(conduit::Schema::Schema_Object_Hierarchy *)(m_schema->m_hierarchy_data)"/>
<Size>m_children.size()</Size>
<Loop Condition="i&lt;m_children.size()">
<!-- This works only if the order of the children hasn't been messed up. -->
<!-- I haven't found a way to get a temporary Node here in the loop. -->
Comment on lines +30 to +31
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in the simple case, for objects that get created and never have Nodes removed. I don't know if I can get this to work in the general case, where the order might get perturbed.

<Item Name="{hier->object_order[i]}">m_children[i]</Item>
<Exec>i++</Exec>
</Loop>
</CustomListItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_INT8_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(signed char *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_INT16_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(signed short *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_INT32_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(signed int *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_INT64_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(signed long *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_UINT8_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(unsigned char *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_UINT16_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(unsigned short *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_UINT32_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(unsigned int *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_UINT64_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(unsigned long *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_FLOAT32_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(float *)m_data</ValuePointer>
</ArrayItems>
<ArrayItems Condition="m_schema->m_dtype.m_id == CONDUIT_FLOAT64_ID">
<Size>m_schema->m_dtype.m_num_ele</Size>
<ValuePointer>(double *)m_data</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
11 changes: 11 additions & 0 deletions src/debug/totalview/ConduitNode.tvd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
# other details. No copyright assignment is required to contribute to Conduit.

::TV::TTF::RTF::build_struct_transform {
name {^(class|struct) (conduit::)?Node$}
members {
{ size { m_elems } }
{ data { m_active_pointer} }
}
}