Use gdb. You can set a break point that logs the arguments to the method and continues.
If you insist on doing it the hard way... It s certainly not simple, but you could use the stack structure on a given architecture/ABI and make use of the Objective-C runtime to figure out how many arguments and of what size to look for. From here on out, I m in unchartered territory; I ve never done this nor would I ever bother. So YMMV...
Within your method, you can get the Method
struct, then the number of arguments, then each argument type and the its size. You could then walk the stack from the address of the self
parameter (i.e. &self
), assuming you knew what you were doing...
Method method = class_getInstanceMethod([self class], _cmd);
unsigned nargs = method_getNumberOfArguments(method);
void *start = &self;
for(unsigned i = 0; i<nargs; i++) {
char *argtype = method_copyArgumentType(method, i);
//find arg size from argtype
// walk stack given arg zie
free(argtype);
}
Along the way you d have to convert from the argtype string (using the Objective-C type encodings) to the size of each argument on the stack.
Of course then you d have to derive the format string for each type, and call NSLogv
with an appropriate variable argument array containing the arguments, copied from their location on the stack. Probably a lot more work than its worth. Use the debugger.