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