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