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.

Eimantas
  • 48,927
  • 17
  • 132
  • 168
user635064
  • 6,219
  • 12
  • 54
  • 100

1 Answers1

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.)

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • 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 – user635064 Mar 26 '11 at 07:17
  • @user: 0x3xxxxxxx would be the location of some Apple libraries. Are you sure you have cleared all previous break points? – kennytm Mar 26 '11 at 07:24
  • 4
    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 Feb 28 '12 at 03:53
  • 1
    @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. – Paul Semionov Mar 26 '13 at 05:32