Debugging swift compiler using GDB


(Leo) #1

Hi there, i have been using GDB to debug swift compiler on linux. However, since i moved to the new swift version 5, i have noticed the failure of using GDB. Here is a simple example:

root# gdb swift
(gdb) r -g t.swift
Starting program: /root/lei/swift_install/usr/bin/swift -g t.swift
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".
process 9352 is executing new program: /root/lei/swift_install/usr/bin/swift
/build/gdb-QP3A9N/gdb-8.1/gdb/breakpoint.c:13230: internal-error: void delete_breakpoint(breakpoint*): Assertion `bpt != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

Any ideas?

(Davide C. C. Italiano) #2

I'm not aware of any swift support in gdb. You might want to try lldb.
Also, FWIW, gdb bugs are better suited for the gdb bugtracker/mailing list.

Please let me know if you have other questions.

(Leo) #3

@dcci, I haven't had any successful experience using lldb to debug swift compiler since the older version, e.g., v4. lldb works fine with swift executables but not swift compiler itself.

I understand that it looks like a problem for gdb. But the error only happens when i tried to debug my fresh built swift-v5 and swift master. It works perfectly with swift-v4.2 though. That's why i posted here to see if anyone else might have encountered similar issue while debugging the swift compiler.

Btw, what are the "standard" debugging tools for debugging swift compiler? I have only used gdb so far. I am interested to learn more.

(Davide C. C. Italiano) #4

My bad. I thought you were debugging swift executables, not the swift compiler itself.

Looking at your log, it seems that gdb is hitting an assertion:

/build/gdb-QP3A9N/gdb-8.1/gdb/breakpoint.c:13230: internal-error: void delete_breakpoint(breakpoint*): Assertion `bpt != NULL' failed.

I do recommend you to report this to them, as it's probably the best course of action.