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