Quickies

[categories] [index] [all (531)] [latest]

gdb
  1. (gdb) inf files
    Symbols from "/private/tmp/hello".
    Mac OS X executable:
        /private/tmp/hello, file type mach-o-le.
        Entry point: 0x000000f4
        0x00000000 - 0x00000042 is LC_SEGMENT.__TEXT in /private/tmp/hello
        0x000000e8 - 0x00000128 is LC_SEGMENT.__TEXT.__text in /private/tmp/hello
    
  2. (gdb) break setPassword:
    (gdb) break -[Person setPassword:]
    
    (gdb) po self
    <Person: 0x10010c7a0>
    (gdb) po [invocation debugDescription]
    Some day, NSInvocation will have a useful debug
    (gdb) p (char *)_cmd
    $1 = 0x10fbb "setPassword:"
    
    (gdb) frame
    (gdb) info locals
    (gdb) info (classes|selectors) [regex]
    (gdb) list +[Person string]
    (gdb) call [self setPassword:@"welcome"]
    
    (gdb) where
    #0  0x0000b4b3 in -[AppDelegate application:didFinishLaunchingWithOptions:] (...)
    #1  0x00444c89 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
    #2  0x00446d88 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()'),
    
  3. (gdb) thread apply all where
    
  4. (gdb) info args
    self = (AppController *) 0x12b9f0
    _cmd = (SEL) 0x12f33
    aNotification = (NSNotification *) 0x264a320
    

    i386 - on the stack

    (int *)($ebp+8)     self
    (int *)($ebp+12)    cmd
    (int *)($ebp+16)    arg2
    (int *)($ebp+20)    arg3
    (int *)($ebp+24)    arg4
    (int *)($ebp+28)    arg5
    
    (int *)$eax         return address
    

    ex: (gdb) po *(int*)($ebp+8)

    i386 - in registers

    $esi       self
    $edx       cmd
    $ecx       arg2
    

    x86_64 - in registers

    $rdi          self
    $rsi          cmd
    $rdx          arg2
    $rcx          arg3
    $r8           arg4
    $r9           arg5
    
    $rax          return address
    

    ex: (gdb) po $rax