[iOS] Swiftμ μ»΄νμΌλ¬ _ LLVM
β€οΈ Swift Compiler _ LLVM
LLVMμ 2000λ μΌλ¦¬λ Έμ΄ λνμμ Chris Lattner μΈ λͺ λͺ μΌλ‘ ꡬμ±λ μ°κ΅¬ νμμ νλ‘κ·Έλλ° μΈμ΄μ μ μ λ° λμ μ»΄νμΌμ λͺ¨λ μ§μν μ μλ νλμ μΈ μ»΄νμΌ μ λ΅μ μ 곡νκΈ° μν μ°κ΅¬ νλ‘μ νΈλ‘ μμλμλ€. intermediate / binary κΈ°κ³ μ½λλ₯Ό ꡬμ±, μ΅μ ν, μμ±νλ λ° μ¬μ©λλ λΌμ΄λΈλ¬λ¦¬λ‘ νλ‘κ·Έλλ¨Έκ° μμ±ν μ½λλ₯Ό μ»΄ν¨ν°κ° μ½μ μ μλ intermediate, binary μ½λλ‘ μ»΄νμΌ νλλ° μ¬μ©λλ€.
π μ»΄ν¨ν°μ νλμ¨μ΄λ Binary Codeλ§ μ½μ μ μλ€. λλ¬Έμ μ°λ¦¬κ° μμ±ν μ½λλ€μ νλμ¨μ΄κ° μ½μ μ μκ² λ°κΏμ£Όλ μμ μ κ±°μ³μΌ νλλ° μ΄λ Intermediate Representation, μ¦ μ€κ°ννμ μ¬μ©ν μ μλ€. μ΄ μ½λλ μμ€ μ½λλ₯Ό νννκΈ° μν΄ κ±°μΉλ, μ»΄νμΌλ¬λ μ½λ μ΅μ ν λꡬμ μν΄ λ΄λΆμ μΌλ‘ μ¬μ©λλ λ°μ΄ν° ꡬ쑰 νΉμ μ½λμ΄λ€. μ΅μ ν, λ³ν λ± μΆκ°μ μΈ μ²λ¦¬λ₯Ό μν΄ μ€κ³λμ΄ μμΌλ©°, μ νλ(μ 보μ μμ€ μ 무)μ λ 립μ±μ μ€μμνλ€. μΆμμ μΈ νλ‘κ·Έλ¨ ννμ΄λ€.
μ€κ° νν - μν€λ°±κ³Ό, μ°λ¦¬ λͺ¨λμ λ°±κ³Όμ¬μ
μν€λ°±κ³Ό, μ°λ¦¬ λͺ¨λμ λ°±κ³Όμ¬μ . μ€κ° νν(intermediate representation, IR)μ μμ€ μ½λλ₯Ό νννκΈ° μν΄ μ»΄νμΌλ¬λ κ°μ λ¨Έμ μ μν΄ λ΄λΆμ μΌλ‘ μ¬μ©λλ λ°μ΄ν° ꡬ쑰 λλ μ½λμ΄λ€. μ€κ° ννμ
ko.wikipedia.org
π μ΄λ―Έ μ‘΄μ¬νλ μ»΄νμΌλ¬, GCC
κΈ°μ‘΄μ GCCλΌλ μ»΄νμΌλ¬κ° μ΄λ―Έ μ‘΄μ¬νκ³ μμλ€. κ·Έλ¬λ μ΄ GCCλ λ¨μΌ λͺ¨λ리μ(λ΄λΆ μμκ° μμ‘΄μ±μ΄ κ°ν, ꡬ쑰μ μΈ κ²°ν©μ΄ κ°λ ₯ν) μ»΄νμΌλ¬λ‘ ꡬμ±λμ΄ μμ΄ νμ₯μ΄ μ΄λ ΅λ€λ λ¨μ μ΄ μμλ€.
GCC, the GNU Compiler Collection - GNU Project
GCC, the GNU Compiler Collection The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages (libstdc++,...). GCC was originally written as the compiler for the GNU operating sy
gcc.gnu.org
π LLVMμ μ₯μ
νμ₯ (λͺ¨λμ±)
LLVMμ κ° μ»΄ν¬λνΈλ€μ μ¬μ¬μ©μ±μ μ€μμν΄μ λͺ¨λνκ° μ λμ΄ μλ€. μ΄λ₯Ό ν΅ν΄ GCCμ νμ₯μ΄ μ΄λ ΅λ€λ λ¨μ μ ν΄κ²°ν μ μλ€.
μ΅μ ν
- Intermediate Representationμ μ¬μ©νμ¬ μ»΄νμΌλ¬ κΈ°λ₯μ μννκΈ°μ μ΅μ νκ° μ©μ΄ν΄μ§λ€. LLVM κΈ°λ°μ μ»΄νμΌλ¬λ μλ‘μ΄ μΈμ΄μ μ§μμ΄λ μ΅μ ν κΈ°λ₯ μΆκ°κ° λ κ°λ¨νκ³ μ μ°νλ€.
- LLVM μ»΄νμΌλ¬λ μ½λ μ΅μ ν λ° μ»΄νμΌ μλ λ©΄μμ μΌλ°μ μΌλ‘ GCCλ³΄λ€ λΉ λ₯΄λ€.
The LLVM Compiler Infrastructure Project
The LLVM Compiler Infrastructure Project
LLVM Overview The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the proj
llvm.org
β€οΈ LLDB _ Low Level Debugger
- Xcode IDEμ λ΄μ₯λμ΄ μλ Command-Line Debug νκ²½
μμ LLVMμμ λͺ¨λν λμ΄ μλ μ»΄ν¬λνΈλ€μ μ΄μ©ν΄ μ§νλ μ£Όμ μλΈ νλ‘μ νΈ μ€ νλκ° λ°λ‘ μ΄ LLDBλΌλ Debuggerμ΄λ€. κΈ°κ³μ΄μ κ°κΉμ΄ μμκΉμ§ λλ²κΉ μ΄ κ°λ₯νλ€λ μ₯μ μ΄ μλ€.
π Debuger
λλ²κ±°λ₯Ό μ¬μ©νλ©΄ μ½λλ₯Ό μμ νμ§ μκ³ λ λ°νμ μ νλ‘κ·Έλ¨μ΄ μ΄λ»κ² λμνλμ§ μ΄ν΄ν μ μκΈ°μ λΆνμν λΉλ μκ°μ μ€μΌ μ μλ€. λλ²κ±°μλ μ€ν νλ¦ μ μ΄μ μν μ κ·Όμ΄λΌλ λ κ°μ§ κΈ°λ³Έ κΈ°λ₯μ΄ μλ€. μ£Όλ‘ μ½λμ μ¬λ¬ μμΉμ Breakpointλ₯Ό μ€μ νμ¬ νλ‘κ·Έλ¨ μ€νμ μ μ΄νλ€. breakpointμ νλ‘κ·Έλ¨μ΄ λλ¬ν λλ§λ€ λλ²κ±°λ νλ‘κ·Έλ¨ μ€νμ μΌμμ μΌλ‘ μ€μ§νκ³ , λ€μν λ³μμ νμ¬ μνλ₯Ό κ²μ¬ λλ μμ νκ³ , λ€μ statementλ‘ λμ΄κ°κ±°λ λ€μ΄κ°κ±°λ νΉμ μ€νμ κ³μνλ λ±μ μμ μ μννλ€.
π Stepping
- Over
- νμ¬ Break κ±Έλ € μλ μ§μ μμ λ°λ‘ λ€μ Statementλ‘ Step Over
- (lldb) next
- (lldb) n
- In
- λ€μ Statementκ° Function CallμΈ κ²½μ° Debuggerλ₯Ό ν΄λΉ ν¨μ λ΄λΆμ μμΉν μμ μ§μ μΌλ‘ μ΄λ
- (lldb) step
- (lldb) s
- Out
- νμ¬ μ§νμ€μΈ functionμ΄ return λ λκΉμ§ νλ‘κ·Έλ¨μ μ§νν ν Break
- (lldb) finish
π po
- description μΆλ ₯
- NSObjectμ debugDescription μΆλ ₯
- 볡μ‘ν λ΄μ©μ description 보기 μ½κ² μΆλ ₯
About LLDB and Debugging
About LLDB and Debugging Debugging refers to creating and using an analytical framework to isolate causal pathways and test hypotheses. The most important tool of debugging is the debugger, which helps you understand how your program behaves at runtime, wi
developer.apple.com
LLDB μ 볡 - μΌκ³°λ·λ·
po λ₯Ό μκ³ κ³μ κ°μ? λͺ°λΌλ μκ΄μμ΅λλ€. LLDB Debugging λ°°μ°λ¬ κ°μλ€! ?
yagom.net