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