The debugger shows this for DateTime structs:
After looking at the docs for lldb to see how to format it, I see I can format integers as hex:
type format add -f hex i32
I tried something similar for DateTime
type format add --format hex chrono::datetime::DateTime<chrono::offset::utc::Utc>
It's not picking up the chrono type even though frame variable shows this as the type. Even after this step is done, not sure how to parse the date to string.
Using @Jim Ingham hints in the other answer and a touchup to this formula
launch.json file by adding"initCommands": [
"command source '${workspaceFolder}/my_type_formatters'"
]
my_type_formatters to the root of the project.command script import simd.py
type summary add -F simd.GetSummary chrono::datetime::DateTime<chrono::offset::utc::Utc>
simd.py file to the root of the project with:from datetime import datetime,timedelta
def GetSummary(valobj, internal_dict):
ymdf = valobj.GetChildMemberWithName('datetime').GetChildMemberWithName('date').GetChildMemberWithName('ymdf').GetValue();
secs = valobj.GetChildMemberWithName('datetime').GetChildMemberWithName('time').GetChildMemberWithName('secs').GetValue();
year = int(ymdf) >> 13
day_of_year = (int(ymdf) & 8191) >> 4;
date = datetime(year -1, 12, 31) + timedelta(days=day_of_year) + timedelta(seconds=int(secs))
return date.strftime('%Y-%m-%d %H:%M:%S')
Result: