Files
clang-p2996/lldb/test/API/commands/expression/formatters/formatters.py
Jonas Devlieghere 2238dcc393 [NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).

If you end up having problems merging this commit because you have made
changes to a python file, the best way to handle that is to run `git
checkout --ours <yourfile>` and then reformat it with black.

RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential revision: https://reviews.llvm.org/D151460
2023-05-25 12:54:09 -07:00

41 lines
1.2 KiB
Python

import lldb
def foo_SummaryProvider(valobj, dict):
a = valobj.GetChildMemberWithName("a")
a_ptr = valobj.GetChildMemberWithName("a_ptr")
bar = valobj.GetChildMemberWithName("b")
i = bar.GetChildMemberWithName("i")
i_ptr = bar.GetChildMemberWithName("i_ptr")
b_ref = bar.GetChildMemberWithName("b_ref")
b_ref_ptr = b_ref.AddressOf()
b_ref = b_ref_ptr.Dereference()
h = b_ref.GetChildMemberWithName("h")
k = b_ref.GetChildMemberWithName("k")
return (
"a = "
+ str(a.GetValueAsUnsigned(0))
+ ", a_ptr = "
+ str(a_ptr.GetValueAsUnsigned(0))
+ " -> "
+ str(a_ptr.Dereference().GetValueAsUnsigned(0))
+ ", i = "
+ str(i.GetValueAsUnsigned(0))
+ ", i_ptr = "
+ str(i_ptr.GetValueAsUnsigned(0))
+ " -> "
+ str(i_ptr.Dereference().GetValueAsUnsigned(0))
+ ", b_ref = "
+ str(b_ref.GetValueAsUnsigned(0))
+ ", h = "
+ str(h.GetValueAsUnsigned(0))
+ " , k = "
+ str(k.GetValueAsUnsigned(0))
)
def foo_SummaryProvider3(valobj, dict, options):
if not isinstance(options, lldb.SBTypeSummaryOptions):
raise Exception()
return foo_SummaryProvider(valobj, dict) + ", WITH_OPTS"