Hata Ayıklayıcı
Tulpar Debug Adapter Protocol (DAP) sunucusuyla geliyor: tulpar debug <dosya.tpr> stdio JSON-RPC adaptörünü açar, DAP destekli
istemci yönlendirir. Resmi VS Code eklentisiyle birlikte tanıdık
Run and Debug panelini kullanabilirsin — .tpr dosyasında
breakpoint koy, F5’e bas, satır satır geç, local’leri incele;
hepsi AOT pipeline’ının --debug ile yazdığı gerçek DWARF debug
info üstüne çalışır.
Arka planda: tulpar debug programını --debug ile AOT-build
eder (tam source-level DWARF), sonra gdb --interpreter=mi3
spawn eder, DAP istekleri ile gdb/MI komutları arasında çeviri
yapar. Sonuç: gdb stabilitesi + VS Code arayüzü.
Gereksinimler
Section titled “Gereksinimler”- Tulpar, DAP sunucusu içerikli (
tulpar debugkomutu, Plan 07 Parça B sonrası). - gdb
PATH’te. Linux dağıtımları gönderiyor; Windows’ta MSYS2 üzerinden (pacman -S mingw-w64-x86_64-gdb); macOS’tabrew install gdb. gdb yoksa adaptörlaunchüzerinde structured “gdb spawn’lanamadı” hatası döner. - VS Code +
vscode-tulparv0.4.0 veya üstü (ayrıca Open VSX üzerinde).
VS Code: 30 saniyede F5
Section titled “VS Code: 30 saniyede F5”- Tulpar eklentisini Marketplace veya Open VSX’ten yükle.
- VS Code’da herhangi bir
.tprdosyası aç. - Satır numarasının solundaki gutter’a tıklayıp breakpoint koy.
- F5’e bas (veya Command Palette’tan
Tulpar: Debug Filekomutunu çağır). Eklenti dosyayı debug info ile AOT-build eder, DAP sunucusunu spawn eder, breakpoint’e ulaşır.
Kalıcı bir launch config istiyorsan .vscode/launch.json ekle —
eklenti Add Configuration… → Tulpar Debug snippet’ini sunuyor:
{ "version": "0.2.0", "configurations": [ { "type": "tulpar", "request": "launch", "name": "Tulpar: Debug Active File", "program": "${file}", "stopOnEntry": false } ]}Şu an çalışan özellikler
Section titled “Şu an çalışan özellikler”| DAP özelliği | Durum | Notlar |
|---|---|---|
| Line breakpoints | ✅ | Gutter tıklaması veya DAP setBreakpoints. |
| Run to completion | ✅ | configurationDone → -exec-run → terminated event. |
| Stop on breakpoint | ✅ | *stopped,reason=breakpoint-hit → DAP stopped event. |
| Stack trace | ✅ | -stack-list-frames → DAP StackFrame[] file/line ile. |
| Locals / parametreler | ✅ | -stack-list-variables --simple-values. Yaprak değerler. |
| Continue | ✅ | -exec-continue → devam + stopped/terminated. |
| Step over | ✅ | next → -exec-next. |
| Step into | ✅ | stepIn → -exec-step. |
| Step out | ✅ | stepOut → -exec-finish. |
| Pause | ✅ | pause → -exec-interrupt (SIGINT → reason=pause). |
| Konsol çıktısı | ✅ | gdb ~"..." console + @"..." target → DAP output. |
| Terminate / disconnect | ✅ | -gdb-exit gönderir, subprocess’i reap eder. |
Henüz desteklenmeyenler
Section titled “Henüz desteklenmeyenler”| DAP özelliği | Neden ertelendi |
|---|---|
evaluate / watch | Per-frame expression evaluator (-data-evaluate-expression). |
setVariable | Aynı evaluate makinesi + -gdb-set var. |
| Conditional / log breakpoints | -break-insert condition kabul ediyor; UI / wiring eksik. |
| Function / data / instruction breakpoints | Az kullanılan kategoriler; line breakpoint F5 akışını taşıyor. |
| Struct / array drill-down | Variables şu an gdb-printed string. -var-create per-leaf sonraki adım. |
restart request | VS Code şu an teardown + relaunch yapıyor; explicit restart ek round-trip’i atlardı. |
Adaptörü doğrudan çalıştırmak
Section titled “Adaptörü doğrudan çalıştırmak”VS Code dışı bir DAP istemcisiyle entegre ediyorsan, adaptör şekli:
tulpar debug yol/program.tprstdin ve stdout DAP teline ait (Content-Length: N\r\n\r\n<json>
framing, LSP ile aynı). Her diagnostic satır sadece stderr’e
gider. Adaptör initialize üzerinde capability listesini ve
setBreakpoints için hazır olduğunda initialized event’ini
yayınlar.
Diagnostic + sorun giderme
Section titled “Diagnostic + sorun giderme”Adaptör her satırı stderr’e [dap] prefix’iyle log’lar:
[dap] tulpar debug adapter starting (program: hello.tpr)[dap] launch: building hello.tpr with debug info...[dap] launch: build OK, binary=hello.exe[dap] gdb<< (gdb)[dap] gdb<< 1^done,bkpt={number="1",...}[dap] request 'evaluate' rejected: not implemented yet[dap] adapter shutting downAdaptörün kendisini debug ederken stderr’i bir dosyaya yönlendir — stdout DAP’ye ait, sızan tek bir byte framing’i bozar.
Diğer araçlarla ilişki
Section titled “Diğer araçlarla ilişki”tulpar build --debug— LLVM IR’a!DICompileUnit+ per-functionDISubprogram+ per-statementDILocation+ per-variableDILocalVariable/DIGlobalVariableExpressionemit eder. Optimizerverifypipeline’ı (-O0) çalıştırır, source mapping 1:1 kalır.tulpar debug— DAP sunucusu. AOT pipeline’ını--debugile içerden çağırır, sonucu gdb’ye besler.vscode-tulpareklentisi — DAP istemci tarafı.DebugAdapterDescriptorFactorykayıt eder,.tprdosyasında F5’e basıldığındatulpar debug <program>spawn eder.
Üç parça tek DWARF emit pipeline’ını paylaşıyor; gdb ./binary
.tpr satırlarını gösteriyorsa VS Code deneyimi de çalışıyor.