그래서 마침내 필자는 작업하고있는 프레임 워크에 디버깅 기호 (doh!)가 없다는 것을 알게되었습니다. 이것이 LLDB가 아무것도 찾을 수없는 이유입니다. 삭제 된 바이너리로 작업하는 것은 조금 더 많은 작업을 필요로하며 Apple Technical Note 2239은 Objective-C 런타임을 사용하여 중단 점을 설정합니다. 다음은 LLDB로 최대한 번역 된 예제 코드입니다.
$ lldb /Applications/TextEdit.app
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) […]
(lldb) target create "/Applications/TextEdit.app"
Current executable set to '/Applications/TextEdit.app' (x86_64).
(lldb) r
Process 2463 launched: '/Applications/TextEdit.app/Contents/MacOS/TextEdit' (x86_64)
Process 2463 stopped
* thread #1: tid = 0x437c7a, 0x00007fffea1603ba libsystem_kernel.dylib`mach_msg_trap + 10, stop reason = signal SIGSTOP
frame #0: 0x00007fffea1603ba libsystem_kernel.dylib`mach_msg_trap + 10
libsystem_kernel.dylib`mach_msg_trap:
-> 0x7fffea1603ba <+10>: ret
0x7fffea1603bb <+11>: nop
libsystem_kernel.dylib`mach_msg_overwrite_trap:
0x7fffea1603bc <+0>: mov r10, rcx
0x7fffea1603bf <+3>: mov eax, 0x1000020
(lldb) # Try to find the
(lldb) # -[DocumentController openUntitledDocumentAndDisplay:error:]
(lldb) # symbol.
(lldb) break set -S openUntitledDocumentAndDisplay:error:
Breakpoint 1: where = AppKit`-[NSDocumentController openUntitledDocumentAndDisplay:error:], address = 0x00007fffd21d244f
(lldb) # These are not the droids we're looking for. It turns out that
(lldb) # TextEdit ships with its symbols stripped, so we'll have to do
(lldb) # this the hard way.
(lldb) #
(lldb) # Get the Class object for the DocumentController class.
(lldb) expr -- void *$class = (void *)objc_getClass("DocumentController")
(lldb) # Get the SEL object for the "openUntitledDocumentAndDisplay:error:" method.
(lldb) expr -- void *$sel=(void *)sel_getUid("openUntitledDocumentAndDisplay:error:")
(lldb) # Get a pointer to the method implementation.
(lldb) po (void*)class_getMethodImplementation($class, $sel)
0x0000000100006df4
(lldb) # Set a breakpoint on the method.
(lldb) b 0x0000000100006df4
Breakpoint 2: where = TextEdit`___lldb_unnamed_symbol74$$TextEdit, address = 0x0000000100006df4
(lldb) # Resume execution, and then create a new, untitled document.
(lldb) c
Process 2463 resuming
Process 2463 stopped
* thread #1: tid = 0x437c7a, 0x0000000100006df4 TextEdit`___lldb_unnamed_symbol74$$TextEdit, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x0000000100006df4 TextEdit`___lldb_unnamed_symbol74$$TextEdit
TextEdit`___lldb_unnamed_symbol74$$TextEdit:
-> 0x100006df4 <+0>: push rbp
0x100006df5 <+1>: mov rbp, rsp
0x100006df8 <+4>: push r15
0x100006dfa <+6>: push r14
중단하려는 기호와 시도한 예제를 몇 가지 알려주십시오. 그렇지 않으면 무엇이 잘못 될지 추측하기가 어렵습니다. –
좀 더 자세히 : 내 Mac에서 위치 서비스에 문제가 있습니다 (사용 설정하지 못했습니다). 나는 class-dump + LLDB가이 문제에 대해 밝힐 수 있기를 바랬다. LLDB에서 시스템 환경 설정을 실행하면서 유망한 소리를내는 메소드에 연결하려고 시도하지만'b - [SomeClass someSelector]'는 코드가 기본 이진 파일이 아닌 환경 설정 창이나 프레임 워크에 있으므로 LLDB가 작동하지 않습니다. 그것을 찾지 마라. 'rbreak someSelector'를 사용하면 메소드가 발견되어 거기에 중단 점이 놓이지 만, 중단 점은해야 할 때 활성화되지 않습니다. –
노력하고있는 소리가 효과가 있어야합니다. 이런 식으로 중단 점을 설정 한 후에 "break list"는 무엇을 말합니까? BTW, 향후 참조를 위해 특정 셀렉터의 모든 인스턴스를 중단하려면 "break set -S someSelector"라고 말할 수 있지만이 경우에는 차이가 없어야합니다. –