4

I have an executable and I am debugging it using gdb. This is my first time using gdb so bear with me please.

I want to set a breakpoint at a function and I know the name of the function using class dump. Now it won't let me add breakpoint to that function because it say's that there's no symbol table. I tried adding the symbol table but it still complains that no symbol table loaded.

So, is there's anyway I can set a breakpoint at this method? It's an objective c method, not c (If that makes a difference). All I need to do is examine the argument of this method.

1
  • How are you invoking GDB? Command line? Commented Mar 26, 2011 at 7:03

1 Answer 1

8

In class-dump there is an -A option will can print the function's address, e.g.

@interface FooObject : NSObject
{
}

- (void)y;  // IMP=0x100000d54

@end

With this you can set a break point using the address:

(gdb) b *0x100000d54
Breakpoint 1 at 0x100000d54

Note that, unless you have stripped the executable, you should always be possible to set a break point using the method's name

(gdb) b -[FooObject y]
Breakpoint 2 at 0x100000d60

(The address isn't the same as the latter skips some frame set-up code.)

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, just did that, and although I set the breakpoint at 0x00420d10, it stopped at "Breakpoint 1, 0x35af7d10". This is not what I set the break point to? Thanks again
@user: 0x3xxxxxxx would be the location of some Apple libraries. Are you sure you have cleared all previous break points?
With class-dump-z -A i only ge the VM offset, e.g.0x97179, which i think need to add with application's base address, how can i get the base address when an application get loaded?
@jim.huang: base address is 0x1000, but with ASLR (iOS 6): in gdb console prompt use command "info sharedLibrary" and grab the address at the very beginning of the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.