Section 1/161 menit
1. Apa Itu LLDB?
1. Apa Itu LLDB?
LLDB (Low Level Debugger) adalah debugger open-source yang menjadi bagian dari proyek LLVM. Sejak Xcode 5, LLDB menggantikan GDB sebagai debugger default untuk semua platform Apple — iOS, macOS, watchOS, tvOS, dan visionOS. LLDB memahami tipe data Swift secara native, termasuk optionals, enums dengan associated values, generics, dan actor.
LLDB bekerja dalam dua mode:
- Interaktif di Xcode: Console LLDB di panel bawah Xcode muncul otomatis saat eksekusi berhenti di breakpoint.
- Standalone via terminal: Bisa digunakan tanpa Xcode menggunakan perintah
lldbatauxcrun lldb.
Posisi LLDB dalam Workflow Debugging
swift
┌─────────────────────────────────────────────────────────┐
│ Xcode / Terminal │
├─────────────────────────────────────────────────────────┤
│ LLDB │
│ ┌──────────────┐ ┌────────────┐ ┌─────────────────┐ │
│ │ Breakpoints │ │ Expression │ │ Python Scripting│ │
│ │ Watchpoints │ │ Evaluator │ │ Custom Commands │ │
│ └──────────────┘ └────────────┘ └─────────────────┘ │
├─────────────────────────────────────────────────────────┤
│ Debug Adapter Protocol │
├─────────────────────────────────────────────────────────┤
│ Process / App yang di-debug (debugee) │
│ ┌─────────┐ ┌──────────┐ ┌────────────────────────┐ │
│ │ Threads │ │ Memory │ │ Registers / Stack │ │
│ └─────────┘ └──────────┘ └────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
Mengapa Swift Developer Perlu LLDB
Bug di Swift seringkali tersembunyi di balik abstraksi tinggi — optionals yang nil tanpa penjelasan, actor yang deadlock, atau SwiftUI view yang tidak re-render. print() tidak bisa menjawab "nilai variabel ini di frame stack tertentu adalah apa?" atau "mengapa thread ini terhenti?". LLDB memberikan visibilitas penuh ke state runtime aplikasi tanpa harus mengubah kode.