🧠 การดีบัก iBrowe บน Windows ด้วย Symbol และ Source Server เพื่อให้การดีบัก iBrowe บน Windows (x86, x64, arm64) ง่ายขึ้น ไฟล์สัญลักษณ์ (.pdb) และ binary ที่เกี่ยวข้องจะถูกอัปโหลดไปยัง Symbol Server ที่โฮสต์โดย iBrowe

🔗 iBrowe Symbol Server https://ibrowe-symbols.s3.ibrowe.com/

⚠️ หมายเหตุ: ลิงก์นี้ไม่สามารถเปิดผ่านเบราว์เซอร์ได้โดยตรง — ออกแบบมาสำหรับเครื่องมือดีบัก เช่น Visual Studio, WinDbg หรือ LLDB เท่านั้น

⚙️ การตั้งค่า Visual Studio ให้ใช้ Symbol Server วิธีที่ 1 (แนะนำ): ตั้งค่าผ่าน Environment Variable ก่อนเปิด Visual Studio (devenv.exe) ให้รันคำสั่งนี้ใน Command Prompt: set _NT_SYMBOL_PATH=SRVC:\symbolshttps://msdl.microsoft.com/download/symbols;SRV*C:/symbols*https://ibrowe-symbols.s3.ibrowe.com

วิธีที่ 2 (ทางเลือก): ตั้งค่าผ่าน UI ของ Visual Studio ไปที่เมนู: Tools → Options → Debugging → Symbols

เพิ่ม URL นี้ลงไป: https://ibrowe-symbols.s3.ibrowe.com/ Setting-Up-Visual-Studio.png

🧬 การดึง Source Code จาก GitHub อัตโนมัติ ไฟล์ .pdb ของ iBrowe ถูกฝังลิงก์ไปยังซอร์สโค้ดไว้แล้ว ทำให้ Visual Studio สามารถ โหลดซอร์สจาก GitHub อัตโนมัติ แม้คุณจะไม่ได้ clone repo นั้นไว้ในเครื่อง

✅ สิ่งที่ต้องมี:

  • ติดตั้ง Python 3
  • มีคำสั่ง py อยู่ใน PATH

⏬ การทำงาน (เบื้องหลัง) เมื่อคุณกดเข้าไปดูโค้ดใน Stack Frame ระหว่างดีบัก Visual Studio จะถามเพื่อโหลดซอร์ส โดยใช้คำสั่งแบบนี้: cmd /c "mkdir … & py -3 -c “import urllib.request; url = ‘<raw github path>’; open(‘<local>.cc’, ‘wb’).write(urllib.request.urlopen(url).read())”

👉 ให้คลิก “Trust commands from this symbol file” แล้วคลิก “Run” คุณก็จะเห็นบรรทัดของซอร์สจริงในหน้าจอ Visual Studio ทันที

symbolfile.png

⚠️ เกี่ยวกับ PGO และพฤติกรรมตอนดีบัก iBrowe ใช้เทคนิค Profile-Guided Optimization (PGO) สำหรับ build เวอร์ชัน release แม้ว่าจะมีไฟล์ .pdb และซอร์สครบถ้วน คุณอาจสังเกตเห็นว่า:

  • Breakpoint บางจุดข้ามไป
  • ลำดับโค้ดดูไม่ตรงกับที่คาดไว้ สาเหตุ: เป็นผลจากการ optimize แบบ aggressive ซึ่งเป็นเรื่องปกติใน PGO builds

📚 อ้างอิง

  • เอกสารนี้ดัดแปลงจาก Brave Browser: 🔗 Brave Symbol Server Setup

  • iBrowe Symbol Server รองรับ build ที่ดัดแปลงจาก Brave