Notice
Recent Posts
Recent Comments
Link
관리 메뉴

김종권의 iOS 앱 개발 알아가기

[iOS - swift] LLDB (Low Level Debugger) 디버깅 방법 본문

iOS 응용 (swift)

[iOS - swift] LLDB (Low Level Debugger) 디버깅 방법

jake-kim 2023. 1. 30. 23:13

LLDB란?

LLDB 커멘드

https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html#//apple_ref/doc/uid/TP40012917-CH2-SW1

  • command와 subcommand는 LLDB 디버거의 객체를 의미
  • LLDB 동작은 Xcode에서 브레이크 포인트를 걸고 실행 시 콘솔창에 (lldb)와 같은 단어가 보이는데 이곳에서 적절한 command를 입력하여 사용

  • thread list 입력 시 현재 스레드의 정보 획득이 가능

 LLDB 커맨드의 특성

  • LLDB는 XCode에만 있는것이 아닌, 일종의 디버깅 표준이므로 LLDB docu를 참고
  • 모든 명령어에는 단축어가 존재하여 빠른 디버깅에 도움
    • ex) 실행하는 명령어 run을 r로만 입력해도 동작

1. LLDB 유용한 커맨드 - po

  • po {instance name}
    • 해당 인스턴스의 정보 출력

2. LLDB 유용한 커맨드 - thread

  • thread list
    • 스레드 목록 보기

  • thread select 1
    • 특정 스레드로 이동하기 - 디버깅할 때 스레드를 변경해가며 파악할때 매우 용이

  • thread step-over
    • 다음 단계 실행
    • Thread는 개별적인 Stack이 생성되는데 여기에 frame 단위를 넣어서, 위치를 기록하고 이 frame이 다음 단계가 실행되는 명령어가 threard step-over를 의미

thread step-over를 입력 후 enter를 입력하면 다음 단계로 이동

  • thread step 까지 입력하면 여러가지가 존재
    • step-in: 다음 state로 진입 (현재가 함수 호출부면, 함수 body 부분으로 들어가는것)
    • step-out: 함수 body부분에 있으면 그 함수를 나와서 다음 단계 부분 위치
    • step-over: 다음 state로 뛰기 (현재가 함수 호출부면, 함수 body로 들어가지 않고 바로 다음줄로 이동)

3. LLDB 유용한 커맨드 - frame

  • Thread는 개별적인 Stack이 생성되는데 여기에 frame 단위를 넣어서, 위치를 기록하는데 이 frame에 대한 출력을 하면 변수에 대한 정보 획득이 가능
  • frame variable
    • 단축어: fv

fv 명령어를 쓰면 현재 property에 관한 데이터 확인도 가능

* 이 밖의 LLDB 커멘드는 해당 사이트 참고

 

* 참고

https://lldb.llvm.org/use/map.html

https://developer.apple.com/documentation/xcode

https://stackoverflow.com/questions/13970271/what-is-the-use-for-the-step-over-thread-and-step-into-thread-commands

https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html#//apple_ref/doc/uid/TP40012917-CH2-SW1

https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/Introduction.html#//apple_ref/doc/uid/TP40012917-CH1-SW1

https://llvm.org/

Comments