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