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