Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:25:14+00:00 2026-06-13T02:25:14+00:00

I have a gdb script I am working on to trace all objective-C method

  • 0

I have a gdb script I am working on to trace all objective-C method calls that pass through objc_msgSend but Ive encountered a problem I cant seem to deal with. After review of the Objective-C runtime source code I have developed the following script to print [ ] at each break on objc_msgSend. The issue is that there are situations in which data_NEVER_USE is not a valid pointer but is also not null. The only indicator that I can find of whether a class is initialized is in id->data_NEVER_USE->flags & RW_REALIZED. What aspect of class initialization am I missing here that would allow me to skip this case?

b objc_msgSend
c
commands
silent

if (*$r0 == 0)
    continue
end

set $id = (class_t *)$r0
set $sel = $r1      
print *$id  
if($id->data_NEVER_USE != 0)
    set $data = (class_ro_t *) ($id->data_NEVER_USE)
    if (($data->flags & 0x80000000) && ($data->name))
        set $classname = $data->name
        printf "[%s ", $classname
    else
        continue
    end
end

if ($sel != 0)
    printf "%s", $sel
else
    printf "null"
end

printf "]\n"
continue
end

I appreciate any help on this. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:25:15+00:00Added an answer on June 13, 2026 at 2:25 am

    These 2 methods have worked reasonably well for me. Note that in my example I am manually starting “SomeApp” in order to monitor it as soon as it starts up.

    gdb
    (gdb) attach --waitfor 'SomeApp'
    
    **this is where you manually start SomeApp on your device**
    
    call (void)instrumentObjcMessageSends(YES)
    

    The “instrumentObjcMessageSends” enables/disables message logging from within the runtime. Here’s some more information on this method.

    Another option, again still using GDB on your iDevice, is to write a small command like this:

    FooPad:~ root# gdb
    (gdb) attach SBSettings
    Attaching to process 440.
    Reading symbols for shared libraries . done
    Reading symbols for shared libraries ............................. done
    0x35686004 in mach_msg_trap ()
    
    (gdb) break objc_msgSend
    Breakpoint 1 at 0x3323ef72
    
    (gdb) commands
    Type commands for when breakpoint 1 is hit, one per line.
    End with a line saying just "end".
    
    >printf "-[%s %s]\n", (char *)class_getName(*(long *)$r0,$r1),$r1
    >c
    >end
    
    (gdb) c
    Continuing.
    // a ton of information will follow
    

    As soon as you press “c” (right above line that reads “Continuing.”, your screen will fill with function names and arguments.

    And finally follow these instructions to get a working GDB on your iDevice. For posterity I’ll post the short instructions here:

    GNU Debugger (gdb) is used to analyze the run time behavior of an iOS
    application. In recent iOS versions, GNU Debugger directly downloaded
    from the Cydia is broken and not functioning properly. Following the
    Pod 2g blog post also did not help me.

    To get rid of this problem, add http://cydia.radare.org to cydia
    source and download the latest GNU Debugger (build 1708). GDB build
    1708 is working for iOS 5.x.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked through GDB documentation, but haven't found anything that works or shows
I'm working in GDB on S390x I have a function that essentially does this:
Through GDB I have determined that the segfault is occuring somewhere in this block
When I start GDB from the command line I have no problems. But when
I'm outside gdb's target executable and I don't even have a stack that corresponds
Is there a way that I can script the initialization file for GDB so
I have a gdb backtrace on it that yields this: #0 match_at (reg=0xcce4a00, str=0xd47b101
We have installed GDB on AIX 6.1 (gdb-6.0-1.aix5.1.ppc_AIX.rpm) and I notice that there is
I have a program that I'd like to debug with gdb via emacs. In
I have gdb 7.3 and device that supports hardware watchpoints. I type such consequent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.