1*e3723e1fSApple OSS Distributionsfrom xnu import * 2*e3723e1fSApple OSS Distributions 3*e3723e1fSApple OSS Distributions@lldb_command("showcoreanalyticsformatstr") 4*e3723e1fSApple OSS Distributionsdef PrintCoreAnalyticsFormatStr(cmd_args=None): 5*e3723e1fSApple OSS Distributions """ Pretty prints the full format string for a core analyics event 6*e3723e1fSApple OSS Distributions Usage: showcoreanalyticsformatstr <event> 7*e3723e1fSApple OSS Distributions """ 8*e3723e1fSApple OSS Distributions if cmd_args is None or len(cmd_args) == 0: 9*e3723e1fSApple OSS Distributions raise ArgumentError("Please specify an event.") 10*e3723e1fSApple OSS Distributions 11*e3723e1fSApple OSS Distributions #event_ptr = kern.GetValueFromAddress(cmd_args[0], "struct _ca_event *").GetSBValue().GetValueAsUnsigned() 12*e3723e1fSApple OSS Distributions #print(event_ptr) 13*e3723e1fSApple OSS Distributions event = kern.GetValueFromAddress(cmd_args[0], "struct _ca_event *") 14*e3723e1fSApple OSS Distributions event_name = str(event.format_str) 15*e3723e1fSApple OSS Distributions print(event_name) 16*e3723e1fSApple OSS Distributions curr = event.format_str.GetSBValue().GetValueAsUnsigned() 17*e3723e1fSApple OSS Distributions offset = len(event_name) + 1 18*e3723e1fSApple OSS Distributions while True: 19*e3723e1fSApple OSS Distributions val = kern.GetValueFromAddress(curr + offset, "char *") 20*e3723e1fSApple OSS Distributions as_string = str(val) 21*e3723e1fSApple OSS Distributions if len(as_string) == 0: 22*e3723e1fSApple OSS Distributions break 23*e3723e1fSApple OSS Distributions offset = offset + len(as_string) + 1 24*e3723e1fSApple OSS Distributions print(as_string) 25