LLDB(Low-Level Debugger)
LLVM은 컴파일 프로젝트이고 그 서브 프로젝트인 LLDB는 디버깅을 맡고 있다.
LLDB는 LLVM의 Debugger Component를 개발하는 서브 프로젝트이다.
C, C++, Objective-C, Swift를 지원하며, 현재 Xcode의 기본 디버거로 내장되어 있다.
기본 문법
(lldb) command [subcommand] -option "this is argument"
구성요소: Command, Subcommand, Option, Argument
예시: (lldb) breakpoint set --file test.c --line 12
breakpoint(Command)와 set(Subcommand)을 이용하며 --file option을 통해 test.c 파일 내 --line option을 통해 12번째 라인에 중단점을 set 해줍니다.
Help
// LLDB에서 제공하는 Command가 궁금하다면,
(lldb) help
// 특정 Command의 Subcommand나, Option이 궁금하다면,
(lldb) help breakpoint
(lldb) help breakpoint set
Apropos
//referent count를 체크할 수 있는 명령어가 있을까? 궁금하다면,
(lldb) apropos "refernce count"
// 결과 # The following commands may relate to 'reference count': # refcount -- Inspect the reference count data for a Swift object
breakpoint 걸기
그냥 왼쪽 행 번호 클릭해서 사용 중...
명령어를 줄여서 사용할 수도 있구나...
함수명, 파일 라인(행)에 걸 수도 있구나...
Condtion 조건에 따라
//viewWillAppear 호출시, animated가 true인 경우에만 break
(lldb) breakpoint set --name "viewWillAppear" --condition animated
(lldb) br s -n "viewWillAppear" -c animated
Command 실행 & AutoContinue
-command (-C) option을 이용하면 break시 원하는 lldb command를 실행 할 수 있습니다.
–auto-continue (-G) option의 기능은 auto continue로, command 실행 후 break에 걸린채로 있지 않고 프로그램을 자동 진행하게 해줍니다`
(lldb) breakpoint set -n "viewDidLoad" --command "po $arg1" -G1
(lldb) br s -n "viewDidLoad" -C "po $arg1" -G1
b (_regexp-break) Command
# 특정 이름을 가진 function에서 break
(lldb) b viewDidLoad
# 현재 파일 20번째 line에서 break
(lldb) b 20
# 특정 파일 20번째 line에서 break
(lldb) b ViewController.swift:12
# 현재 파일 내 특정 text를 포함한 line에서 break
(lldb) b /stop here/
# 특정 주소값에서 break
(lldb) b 0x1234000
Stepping
run next(n) step-in(s) finish
버튼을 눌러서 사용하자
Expression
po
음... 아직까진 어떻게 사용할지 별로 감이 안오네
https://yagom.net/courses/start-lldb/lessons/expression/topic/po/
출처: https://yagom.net/courses/start-lldb/lessons/lldblow-level-debugger란/
'🦅Swift Syntax' 카테고리의 다른 글
#2. 자바 데이터 타입, 변수 그리고 배열 [자바] (0) | 2021.04.15 |
---|---|
#1-1. LLVM은 무엇이며 스위프트 코드는 어떻게 실행하는 것인가 [스위프트] (0) | 2021.04.14 |
#1. JVM은 무엇이며 자바 코드는 어떻게 실행하는 것인가 [자바] (0) | 2021.04.14 |
어떻게 공부할 것인가?(학습방법) (0) | 2021.04.14 |