LLDB란?
LLDB는 Apple이 GDB를 대체하기 위해 LLVM 기반으로 새롭게 개발한 디버거입니다.
Xcode 5부터 기본 디버거로 채택되어, 모든 기존 및 신규 프로젝트에서 자동으로 LLDB를 사용하게 되었습니다.
LLDB는 GDB보다 강력하고 빠르며, 데이터 검사 및 흐름 제어에 있어 현대적인 기능을 제공합니다.
LLDB의 주요 특징
1. Xcode와의 완벽한 통합
LLDB는 Xcode 안에서 완전히 통합되어 작동합니다. UI 디버깅 도구와 디버깅 콘솔에서 LLDB 명령어를 직접 사용할 수 있습니다.
2. 익숙한 명령어 세트
기존 GDB 사용자를 위해 LLDB는 GDB와 유사한 명령어들을 제공합니다.
또한 별칭(alias)을 지정하거나, 단축 명령어를 만들어 손쉽게 사용할 수 있습니다.
3. 확장 가능한 디버거
LLDB는 Python 스크립트와 연동할 수 있습니다.
이를 통해 사용자가 직접 기능을 확장하고 자동화 스크립트를 작성할 수도 있습니다.
LLDB 사용법 요약
명령어 중심의 디버깅
- LLDB는 명령어 기반 인터페이스를 제공합니다. 구문은 일관되고 배우기 쉬우며, help 명령어를 통해 대부분의 사용법을 확인할 수 있습니다.

GDB와의 대응표 제공
GDB에 익숙하다면 LLDB에서 어떤 명령어로 대체되는지 정리된 표를 활용할 수 있다.
GDB and LLDB Command Examples
GDB and LLDB Command Examples The tables in this chapter list commonly used GDB commands and present equivalent LLDB commands and alternative forms. Also listed are the built-in GDB compatibility aliases in LLDB. Notice that full LLDB command names can be
developer.apple.com
명령어
기본 제어 명령어
run 또는 r | 앱 실행 |
process continue 또는 c | 일시 중지된 앱 계속 실행 |
process interrupt 또는 Ctrl + C | 앱 중지 (pause) |
quit | LLDB 종료 |
브레이크포인트 (Breakpoints)
breakpoint set --name viewDidLoad | 함수 이름으로 브레이크포인트 설정 |
br s -f ViewController.swift -l 42 | 특정 파일의 라인에 브레이크포인트 설정 |
br list | 모든 브레이크포인트 목록 확인 |
br disable 1 | 브레이크포인트 1번 비활성화 |
br delete 1 | 브레이크포인트 1번 삭제 |
값 확인/출력 (Print & Inspect)
po self | self 객체를 출력 (description 또는 CustomDebugStringConvertible 사용) |
p self.title | 변수의 값 출력 (po는 출력 형태가 다름) |
frame variable 또는 fr v | 현재 스코프의 모든 변수 출력 |
expression 또는 e | 코드 조각 실행 (e someVar = 3) |
💡 po는 NSLog 같은 출력, p는 내부 구조까지 출력하는 LLDB 고유의 표현 방식입니다.
스택 추적 (Backtrace)
bt | 현재 호출 스택(backtrace) 출력 |
thread backtrace | 활성 쓰레드의 스택 프레임 출력 |
thread list | 실행 중인 모든 쓰레드 목록 |
thread select 2 | 2번 쓰레드로 전환 |
스택 프레임 이동
frame select 0 | 0번 프레임 선택 |
up / down | 이전/다음 프레임으로 이동 |
실행 흐름 조작
next 또는 n | 다음 줄로 이동 (step over) |
step 또는 s | 함수 내부로 들어감 (step into) |
finish | 현재 함수 빠져나옴 (step out) |
직접 해보기
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let randomNumber = getRandomNumber()
print("randomNumber = \(randomNumber)")
}
func getRandomNumber() -> Int {
return Int.random(in: 0...100)
}
}
랜덤 함수를 출력하는 코드로 LLDB를 사용해보았습니다.

print에 Breakpoint를 걸어 실행해주면 아래와 같이 Debug 영역에 나오게 됩니다.

현재 랜덤 값에는 43이라는 숫자가 들어있습니다.
po를 통해 randomNumber를 불러올 수 있고 그 값을 비교할 수 있습니다.
- po : print object의 줄임말
expression을 통해 변수를 선언해주고 값을 넣어줄 수 있습니다.

관련 문서
About LLDB and Xcode
About LLDB and Xcode With the release of Xcode 5, the LLDB debugger becomes the foundation for the debugging experience on OS X. LLDB is Apple’s “from the ground up” replacement for GDB, developed in close coordination with the LLVM compilers to brin
developer.apple.com
🐛 LLDB
Next Tutorial
lldb.llvm.org
'iOS > Xcode' 카테고리의 다른 글
[ Xcode ] Xcode 단축키 모음 (1) | 2024.01.10 |
---|
LLDB란?
LLDB는 Apple이 GDB를 대체하기 위해 LLVM 기반으로 새롭게 개발한 디버거입니다.
Xcode 5부터 기본 디버거로 채택되어, 모든 기존 및 신규 프로젝트에서 자동으로 LLDB를 사용하게 되었습니다.
LLDB는 GDB보다 강력하고 빠르며, 데이터 검사 및 흐름 제어에 있어 현대적인 기능을 제공합니다.
LLDB의 주요 특징
1. Xcode와의 완벽한 통합
LLDB는 Xcode 안에서 완전히 통합되어 작동합니다. UI 디버깅 도구와 디버깅 콘솔에서 LLDB 명령어를 직접 사용할 수 있습니다.
2. 익숙한 명령어 세트
기존 GDB 사용자를 위해 LLDB는 GDB와 유사한 명령어들을 제공합니다.
또한 별칭(alias)을 지정하거나, 단축 명령어를 만들어 손쉽게 사용할 수 있습니다.
3. 확장 가능한 디버거
LLDB는 Python 스크립트와 연동할 수 있습니다.
이를 통해 사용자가 직접 기능을 확장하고 자동화 스크립트를 작성할 수도 있습니다.
LLDB 사용법 요약
명령어 중심의 디버깅
- LLDB는 명령어 기반 인터페이스를 제공합니다. 구문은 일관되고 배우기 쉬우며, help 명령어를 통해 대부분의 사용법을 확인할 수 있습니다.

GDB와의 대응표 제공
GDB에 익숙하다면 LLDB에서 어떤 명령어로 대체되는지 정리된 표를 활용할 수 있다.
GDB and LLDB Command Examples
GDB and LLDB Command Examples The tables in this chapter list commonly used GDB commands and present equivalent LLDB commands and alternative forms. Also listed are the built-in GDB compatibility aliases in LLDB. Notice that full LLDB command names can be
developer.apple.com
명령어
기본 제어 명령어
run 또는 r | 앱 실행 |
process continue 또는 c | 일시 중지된 앱 계속 실행 |
process interrupt 또는 Ctrl + C | 앱 중지 (pause) |
quit | LLDB 종료 |
브레이크포인트 (Breakpoints)
breakpoint set --name viewDidLoad | 함수 이름으로 브레이크포인트 설정 |
br s -f ViewController.swift -l 42 | 특정 파일의 라인에 브레이크포인트 설정 |
br list | 모든 브레이크포인트 목록 확인 |
br disable 1 | 브레이크포인트 1번 비활성화 |
br delete 1 | 브레이크포인트 1번 삭제 |
값 확인/출력 (Print & Inspect)
po self | self 객체를 출력 (description 또는 CustomDebugStringConvertible 사용) |
p self.title | 변수의 값 출력 (po는 출력 형태가 다름) |
frame variable 또는 fr v | 현재 스코프의 모든 변수 출력 |
expression 또는 e | 코드 조각 실행 (e someVar = 3) |
💡 po는 NSLog 같은 출력, p는 내부 구조까지 출력하는 LLDB 고유의 표현 방식입니다.
스택 추적 (Backtrace)
bt | 현재 호출 스택(backtrace) 출력 |
thread backtrace | 활성 쓰레드의 스택 프레임 출력 |
thread list | 실행 중인 모든 쓰레드 목록 |
thread select 2 | 2번 쓰레드로 전환 |
스택 프레임 이동
frame select 0 | 0번 프레임 선택 |
up / down | 이전/다음 프레임으로 이동 |
실행 흐름 조작
next 또는 n | 다음 줄로 이동 (step over) |
step 또는 s | 함수 내부로 들어감 (step into) |
finish | 현재 함수 빠져나옴 (step out) |
직접 해보기
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let randomNumber = getRandomNumber()
print("randomNumber = \(randomNumber)")
}
func getRandomNumber() -> Int {
return Int.random(in: 0...100)
}
}
랜덤 함수를 출력하는 코드로 LLDB를 사용해보았습니다.

print에 Breakpoint를 걸어 실행해주면 아래와 같이 Debug 영역에 나오게 됩니다.

현재 랜덤 값에는 43이라는 숫자가 들어있습니다.
po를 통해 randomNumber를 불러올 수 있고 그 값을 비교할 수 있습니다.
- po : print object의 줄임말
expression을 통해 변수를 선언해주고 값을 넣어줄 수 있습니다.

관련 문서
About LLDB and Xcode
About LLDB and Xcode With the release of Xcode 5, the LLDB debugger becomes the foundation for the debugging experience on OS X. LLDB is Apple’s “from the ground up” replacement for GDB, developed in close coordination with the LLVM compilers to brin
developer.apple.com
🐛 LLDB
Next Tutorial
lldb.llvm.org
'iOS > Xcode' 카테고리의 다른 글
[ Xcode ] Xcode 단축키 모음 (1) | 2024.01.10 |
---|