《九阴真经: iOS黑客攻防秘籍》新书发布,干货满满,快来看看吧!

iOS 安全论坛 - 专注于研究 iOS 安全

 找回密码
 立即注册
查看: 180|回复: 5

dyld, lldb, llvm, debugserver这些开源的代码怎么进行调试

[复制链接]

3

主题

19

帖子

121

积分

注册会员

Rank: 2

积分
121
发表于 2019-11-20 15:56:45 | 显示全部楼层 |阅读模式
有教程没有
回复

使用道具 举报

90

主题

331

帖子

1294

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1294
发表于 2019-11-21 12:34:55 | 显示全部楼层
你想调试某个进程,必须要有另一个进程去挂载它。你用 lldb 去调试某个进程时,首先执行的第一行代码就是 dyld 的
  1. $ lldb
  2. (lldb) process connect connect://127.0.0.1:12345
  3. Process 2850 stopped
  4. * thread #1, stop reason = signal SIGSTOP
  5.     frame #0: 0x0000000100151000 dyld`_dyld_start
  6. dyld`_dyld_start:
  7. ->  0x100151000 <+0>:  mov    x28, sp
  8.     0x100151004 <+4>:  and    sp, x28, #0xfffffffffffffff0
  9.     0x100151008 <+8>:  mov    x0, #0x0
  10.     0x10015100c <+12>: mov    x1, #0x0
  11. Target 0: (dyld) stopped.
复制代码
dyld 是开源,你可以对照代码去调试,各个版本的代码都在这里 https://opensource.apple.com/source/dyld/

你说的调试 LLVM 是指的调试 pass 吗?如果是调试 pass 可以参考这个:https://www.exchen.net/%e5%bc%80 ... 8%aa-llvm-pass.html
回复

使用道具 举报

3

主题

19

帖子

121

积分

注册会员

Rank: 2

积分
121
 楼主| 发表于 2019-11-21 13:44:04 | 显示全部楼层
exchen 发表于 2019-11-21 12:34
你想调试某个进程,必须要有另一个进程去挂载它。你用 lldb 去调试某个进程时,首先执行的第一行代码就是 d ...

老哥强啊, 本来只是想通过动态调试看源码比较爽一点, 这又发现新大陆了.
回复

使用道具 举报

3

主题

19

帖子

121

积分

注册会员

Rank: 2

积分
121
 楼主| 发表于 2019-11-22 10:45:44 | 显示全部楼层
exchen 发表于 2019-11-21 12:34
你想调试某个进程,必须要有另一个进程去挂载它。你用 lldb 去调试某个进程时,首先执行的第一行代码就是 d ...

https://www.exchen.net/%e5%bc%80 ... 8%aa-llvm-pass.html

求助 卡在生成xcode项目了, llvm9.0, cef9.0, xcode11
error在楼下.
回复

使用道具 举报

3

主题

19

帖子

121

积分

注册会员

Rank: 2

积分
121
 楼主| 发表于 2019-11-22 10:48:26 | 显示全部楼层


(base)  ~/Downloads/llvm-9.0.0.src/build  cmake -G Xcode CMAKE_BUILD_TYPE="Debug" ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- The ASM compiler identification is AppleClang
-- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken
CMake Error at /usr/local/share/cmake-3.11/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/mac/Downloads/llvm-9.0.0.src/build/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/xcodebuild" "-project" "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_c1c45" "-configuration" "Debug"
    note: Using new build system
    2019-11-22 10:35:41.957 xcodebuild[95976:1759924] unable to create build operation: Error Domain=com.apple.xcbuild Code=1 "unknown error while handling message: missingTarget(guid: "95282c4d0b99d00bc16ec68ba7d39c24d9999beaac079f27cb6c67b78e341ed8")" UserInfo={NSLocalizedDescription=unknown error while handling message: missingTarget(guid: "95282c4d0b99d00bc16ec68ba7d39c24d9999beaac079f27cb6c67b78e341ed8")}

    ** BUILD FAILED **





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:49 (project)


-- Configuring incomplete, errors occurred!
See also "/Users/mac/Downloads/llvm-9.0.0.src/build/CMakeFiles/CMakeOutput.log".
See also "/Users/mac/Downloads/llvm-9.0.0.src/build/CMakeFiles/CMakeError.log".


----------------------------------------------------------------------------------------------------------------
CMakeError.log:

Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)":
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Checking whether the ASM compiler is HP using "-V" did not match "HP C":
clang: error: unsupported option '-V -Wno-framework-include-private-from-public'
clang: error: no input files
Checking whether the ASM compiler is Intel using "--version" did not match "(ICC)":
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Checking whether the ASM compiler is SunPro using "-V" did not match "Sun C":
clang: error: unsupported option '-V -Wno-framework-include-private-from-public'
clang: error: no input files
Checking whether the ASM compiler is XL using "-qversion" did not match "XL C":
clang: error: unknown argument '-qversion', did you mean '--version'?
clang: error: no input files
Checking whether the ASM compiler is MSVC using "/?" did not match "Microsoft":
clang: error: no such file or directory: '/?'
clang: error: no input files
Checking whether the ASM compiler is TI using "-h" did not match "Texas Instruments":
clang: error: unknown argument: '-h'
clang: error: no input files
Checking whether the ASM compiler is IAR using "" did not match "IAR Assembler":
clang: error: no input files
Checking whether the ASM compiler is ARMCC using "" did not match "(ARM Compiler)|(ARM Assembler)":
clang: error: no input files
Checking whether the ASM compiler is NASM using "-v" did not match "(NASM version)":
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Found CUDA installation: /usr/local/cuda, version unknown
Checking whether the ASM compiler is YASM using "--version" did not match "(yasm)":
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Checking whether the ASM compiler is ADSP using "-version" did not match "Analog Devices":
clang: error: unknown argument '-version', did you mean '--version'?
clang: error: no input files
Determining if the CXX compiler works failed with the following output:
Change Dir: /Users/mac/Downloads/llvm-9.0.0.src/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/xcodebuild" "-project" "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_2d89a" "-configuration" "Debug"
note: Using new build system
2019-11-22 10:28:49.320 xcodebuild[95766:1755866] unable to create build operation: Error Domain=com.apple.xcbuild Code=1 "unknown error while handling message: missingTarget(guid: "95282c4d0b99d00bc16ec68ba7d39c24c5cd7757800fd6105a84995a0bdacfe4")" UserInfo={NSLocalizedDescription=unknown error while handling message: missingTarget(guid: "95282c4d0b99d00bc16ec68ba7d39c24c5cd7757800fd6105a84995a0bdacfe4")}

** BUILD FAILED **

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CMakelists.txt

project(LLVM
  VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
  LANGUAGES C CXX ASM)
回复

使用道具 举报

90

主题

331

帖子

1294

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1294
发表于 2019-11-22 21:50:21 | 显示全部楼层
当时我写那个文章的时候用的是 6.0,建议你也用 6.0 的试一下,避免一些坑,先能跑起来。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|iOSHacker

GMT+8, 2020-1-21 05:06 , Processed in 0.050460 second(s), 19 queries .

iOS安全论坛

© 2017-2020 iOS Hacker Inc.

快速回复 返回顶部 返回列表