zoukankan      html  css  js  c++  java
  • [转]gdb 调试 objc

    源:http://bbs.pediy.com/showthread.php?t=159549

    3. 在没有 symbols的情况下,想要下断 objc method 或者 private framework 里面的 method 就比较麻烦点:

    一种可以通过 class-dump 加参数 -A 导出没有 impl 的 相对地址, 然后用gdb info shared 
    获取 每个模块的 加载基址, 来算出实际 地址, 下断 , 不过这种方法 我算到现在 还没精确断成功过, = =

    还有一种 比较简单有效, 可以通过 objc_getClass 和 class_getInstanceMethod获取 私有类的 实例, 然后通过 method_getImplementation, 获取指定 impl 的 地址, 然后下断:

    b *((long)method_getImplementation((long)class_getInstanceMethod((long)objc_getClass((char*)"UIApplication"), @selector(deactivate))))

    为了方便使用, 可以定义成命令, 放到 .gdbinit 中, 例如:

    define bo
    b *((long)method_getImplementation((long)class_getInstanceMethod((long)objc_getClass((char*)"$arg0"), @selector($arg1))))
    end

    之后只需要:

    bo UIApplication deactivate
    bo SBIconView  touchesBegan:withEvent:

    就行了。。

  • 相关阅读:
    【MySQL】(三)文件
    【MySQL】(二)InnoDB存储引擎
    Linux Shell脚本编程-信号捕获
    Linux Shell脚本编程-数组和字符串处理
    Linux Shell脚本编程-函数
    Linux Shell脚本编程-语句控制
    Linux Shell脚本编程-基础2
    Linux Shell脚本编程-基础1
    Awk
    Sed
  • 原文地址:https://www.cnblogs.com/Proteas/p/3165116.html
Copyright © 2011-2022 走看看