Giter Club home page Giter Club logo

Comments (5)

mrhappyasthma avatar mrhappyasthma commented on September 26, 2024

Some testing suggests that you can't add a symbolic breakpoint in this way.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on September 26, 2024

One alternative is to breakpoint in the parent, check the type of class of the current instance in the condition of the breakpoint, and then print the frame using memory read --format f --size 8 --count 4 $rsp.

Alternatives I tried were: executing __asm__("int3") inside of the class_addMethod implementation. But that won't work since its assembly.

I also tried adding a symbolic breakpoint to a dummy method using the following, and it failed to resolve it:

e (BOOL)class_addMethod([MyView class], @selector(setFrame:), (IMP)imp_implementationWithBlock(^(id self, CGRect frame) { (void)NSLog(@"test"); }), "v@{CGRect={CGPoint=dd}{CGSize=dd}}")

break set -F '-[MyView setFrame:]' -L objc

Note: I couldn't seem to get the implementation to work by casting a function, so I used imp_implementationWithBlock(). Perhaps it could be done if the actual function exists? But it seems unlikely. The problem seems to be the symbol isn't there for the symbolic breakpoint even though we add an implementation at runtime.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on September 26, 2024

The biggest downside would be handling all of the different calling conventions. Above was working with x86_64.

Using this website, I was using: https://www.raywenderlich.com/615-assembly-register-calling-convention-tutorial

First Argument: RDI
Second Argument: RSI
Third Argument: RDX
Fourth Argument: RCX
Fifth Argument: R8
Sixth Argument: R9

Meaning $rdi would be self and (SEL)$rsi would be _cmd.

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on September 26, 2024

Another useful reference for calling conventions: https://github.com/stephanemoore/archives/blob/master/general/calling-conventions.md

arm64: https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html

arm6: https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARMv7FunctionCallingConventions.html#//apple_ref/doc/uid/TP40009022-SW1

i386: https://wiki.osdev.org/Calling_Conventions#Cheat_Sheets

from happydebugging.

mrhappyasthma avatar mrhappyasthma commented on September 26, 2024

Architecture can be inferred from GetSelectedTarget or target list.

64-bit simulator = x86_64
32-bit simulator = i386
64-bit device = arm64
32-bit device = arm7

https://docs.elementscompiler.com/Platforms/Cocoa/CpuArchitectures/

from happydebugging.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.