Section 9/161 menit

9. Custom Commands dan Aliases

9. Custom Commands dan Aliases

Membuat Alias untuk Perintah yang Sering Dipakai

swift
# Alias sederhana
(lldb) command alias bfl breakpoint set --file %1 --line %2
# Penggunaan: bfl MyFile.swift 42

(lldb) command alias poc po self
# Ketik "poc" → otomatis po self

(lldb) command alias reload expr UIApplication.shared.keyWindow?.rootViewController?.viewWillAppear(true)

File ~/.lldbinit

Alias dan konfigurasi yang ditulis di ~/.lldbinit akan dimuat otomatis setiap kali LLDB berjalan:

swift
# ~/.lldbinit

# Alias berguna
command alias bfl breakpoint set --file %1 --line %2
command alias poc command script import ~/lldb_scripts/print_self.py

# Setting tampilan
settings set target.x86-disassembly-flavor intel

# Auto-import script Python kustom
command script import ~/lldb_scripts/swift_helpers.py

# Aktifkan logging untuk debugging LLDB sendiri (jarang diperlukan)
# log enable lldb commands

Project-Specific .lldbinit

Untuk konfigurasi per-project, buat file .lldbinit di root project. Xcode 13+ memuat ini otomatis jika setting IDEDebuggerFeatureSetting diaktifkan:

swift
# .lldbinit di root project

# Load script debugging custom untuk project ini
command script import ./scripts/debug_helpers.py

# Breakpoint yang selalu aktif saat debugging project ini
breakpoint set --name "fatalError" --auto-continue false