Use gdb. You can set a breakpoint that writes arguments to the method and continues.
If you insist on doing it the hard way ... It's certainly not easy, but you can use the stack structure for a given architecture / ABI and use the Objective-C runtime to figure out how many arguments and what size to look for. From there I am in uninhabited territory; I have never done this, and I will never worry. So YMMV ...
Within your method, you can get the Method structure, then the number of arguments, then the type of each argument and its size. You can then go through the stack from the address of the self parameter (i.e. &self ), assuming you know what you are 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);
Along the way, you will have to convert the argtype string (using the Objective-C encoding type ) to the size of each argument on the stack.
Of course, you will need to get a format string for each type and call NSLogv with a corresponding array of argument arguments containing the arguments copied from their location on the stack. Probably a lot more work than its value. Use a debugger.
source share