سؤال

There's an undocumented (private) framework for OS X called MobileDevice. It's used to get data from iOS devices. I'm in the process of writing an application that uses it and I want to be able to extract the number of charge cycles on the iOS device's battery. The function for doing this in MobileDevice is called AMDeviceCopyValue(). It takes 3 arguments: the address of the device (just an integer), the domain of the value you'd like to copy (a C string), and the key of the value you'd like to copy (another C string.)

Since this framework isn't documented, it's difficult to find what strings you need to use. Some of them have been posted online, but not the one for counting charge cycles. Another program I found online already does this, iCopyBot: http://www.icopybot.com/blog/check-ipad-iphone-battery-charge-cycle-count-without-jailbreaking.htm

I'd like to launch iCopyBot in LLDB, and then have LLDB print out the domain and key arguments that iCopyBot passes to AMDeviceCopyValue() each time it's called. The framework is sensitive about timing, so I can't have it halting mid-execution - it needs to just print the arguments that were passed and keep going.

Can anyone show me what I have to do? I've already managed to launch iCopyBot in LLDB and I have set a breakpoint each time that function is called, but the command "frame variable" doesn't print out anything for me (the documentation for LLDB that I got off of Apple's website suggests that it should print the arguments that were passed in... it didn't work for me.)

هل كانت مفيدة؟

المحلول

To surmise what was learned from my discussion in the comments of the question with H2CO3:

You can load any program you want in LLDB by typing the following command:

lldb <path to application executable>

To set a breakpoint on a function, type in the following command after lldb has started:

breakpoint set -b <name of function>

To actually start the program in lldb, type in the following once it's loaded and has the breakpoints you want:

run

To view the variables at the breakpoint, even without the debugger symbols (IE, because this isn't a program that you have the source to) type in:

register read

If anything in the list looks like it has a CoreFoundation or Obj-C object, type the following:

po <register of object>

And finally, if you think there's a C string being pointed to by one of the variables, you can use this:

p (char*)<register of string>

There's a lot more you can do with lldb than I covered here. Just type help from the lldb prompt to see more of what it can do. This covers everything I wanted to know when I first posted this question yesterday, though.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top