Let's say I have a carbon objective-c executable, and a crash report. From the crash report, it is apparent that the main method is located at 0x00002639, and the NSApplicationMain method from the AppKit is at 0x93ba0025. I anticipate that the first main method has background processes, and NSApplicationMain is the method typed by the user.

Is there any sort of predictable interval to instructions? I want to make breakpoints at every instruction written by the programmer. Let's say for example that the main after the main method, the instructions are separated by 2, so from 0x93ba0025, the next function would be 0x93ba0027, etc.

Would the above apply, or will I have to do something more to achieve this?



x86/x64 processors use instructions of variable length, so you can't assume that there is a specific number of bytes between instructions.

You'd likely want to use something like a length disassembler in order to figure out the length of a given instruction at a given address.

  • I wanted to determine this to set breakpoints on every instruction in the main method. So then would the break without arguments with gdb work too? It says it will insert breakpoint at next instruction
    – John K
    May 18 '16 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.