-
Notifications
You must be signed in to change notification settings - Fork 9
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
ENH: Add LLDB pretty printers for a few SIMPLNX classes. #1178
base: develop
Are you sure you want to change the base?
ENH: Add LLDB pretty printers for a few SIMPLNX classes. #1178
Conversation
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.
We could combine all pretty printers into one package so that you only have one import to do for lldb. It would also let use share utility code between printers.
""" | ||
|
||
# 1) Retrieve the m_Array child. | ||
std_array_elements = valobj.GetChildMemberWithName("m_Array").GetChildMemberWithName("__elems_") |
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 uses the libc++ implementation which means it won't work with libstdc++ which is typical when using clang and lldb on linux.
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.
What is the other option?
2d091c7
to
d85b01a
Compare
e7047ca
to
6a3aa3e
Compare
* More to come later There is a bit of setup that one must do in order to get LLDB to use these pretty printers. Namely create a file called `.lldbinit` at the top level of your home directory and put the following code in it: ``` command script import /Users/${USER}/Workspace1/simplnx/scripts/lldb_pretty_printers/data_path_pretty_printer.py command script import /Users/${USER}/Workspace1/simplnx/scripts/lldb_pretty_printers/nx_core_array_pretty_printer.py ``` Where you will need to adjust the path to the actual python files based on how you have your environment setup. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
6a3aa3e
to
2a519d1
Compare
I have this script for testing:
import lldb
def data_path_summary(valobj: lldb.SBValue, internal_dict: dict) -> str:
path_valobj: lldb.SBValue = valobj.GetChildMemberWithName('m_Path')
elements = []
element: lldb.SBValue
for element in path_valobj:
str_val: str = element.GetSummary()
if str_val is None:
str_val = '<NULL>'
else:
if len(str_val) >= 2 and str_val.startswith('"') and str_val.endswith('"'):
str_val = str_val[1:-1]
elements.append(str_val)
return f"\"{'/'.join(elements)}\""
def array_summary(valobj: lldb.SBValue, internal_dict: dict) -> str:
array_valobj: lldb.SBValue = valobj.GetChildMemberWithName('m_Array')
# should "_M_elems" for libstdc++ and "__elems" for libc++
std_array_elements: lldb.SBValue = array_valobj.child[0]
if std_array_elements is None:
return '<unavailable>'
elements = []
element: lldb.SBValue
for element in std_array_elements:
elem_value = element.GetValue()
if elem_value is None:
elem_value = element.GetSummary()
if elem_value is None:
elem_value = '<unavailable>'
elements.append(elem_value)
return f"({', '.join(elements)})"
def add_type_summary(debugger: lldb.SBDebugger, func_name: str, type_name: str, type_name_is_regex: bool = False) -> None:
regex_flag = '-x' if type_name_is_regex else ''
debugger.HandleCommand(
f'type summary add -F nxprinter.{func_name} {regex_flag} "{type_name}"'
)
def __lldb_init_module(debugger: lldb.SBDebugger, internal_dict: dict):
add_type_summary(debugger, 'data_path_summary', 'nx::core::DataPath')
add_type_summary(debugger, 'array_summary', 'nx::core::Array<.*,.*>', type_name_is_regex=True) |
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
There is a bit of setup that one must do in order to get LLDB to use these pretty
printers. Namely create a file called
.lldbinit
at the top level of your homedirectory and put the following code in it:
Where you will need to adjust the path to the actual python files based on how you have your environment setup.