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