Well, here's one way to do it:
Enable debug symbols under Options -> Advanced
Compile your program. Here's mine:
Print "hello"
While 1
Print "world"
For i = 1 To 10
Print i
Next i
Wend
Launch the program under gdb and run it:
$ gdb untitled
Reading symbols from untitled...done.
(gdb) run
When you think your program is stuck, kill it with ^C and switch to thread 2:^C
Thread 1 "untitled" received signal SIGINT, Interrupt.
0x00007ffff7d3ebf0 in __GI___nanosleep (
requested_time=0xb56c10 <Sleep(unsigned int)::ts>, remaining=0x0)
at ../sysdeps/unix/sysv/linux/nanosleep.c:28
28 ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory.
(gdb) thread 2
Get a stack trace:(gdb) bt
#0 __GI___printf_fp_l (fp=fp@entry=0x7ffff55c0bc0, loc=<optimized out>,
info=info@entry=0x7ffff55c0720, args=args@entry=0x7ffff55c0700)
at printf_fp.c:1246
#1 0x00007ffff788f7c9 in ___printf_fp (fp=fp@entry=0x7ffff55c0bc0,
info=info@entry=0x7ffff55c0720, args=args@entry=0x7ffff55c0700)
at printf_fp.c:1267
#2 0x00007ffff788a54b in _IO_vfprintf_internal (s=s@entry=0x7ffff55c0bc0,
format=format@entry=0x4cde7d "% .6E", ap=ap@entry=0x7ffff55c0cf0)
at vfprintf.c:1637
#3 0x00007ffff78ac321 in __IO_vsprintf (
string=0xb48640 <qbs_str_buffer> " 1.000000E+000", format=0x4cde7d "% .6E",
args=args@entry=0x7ffff55c0cf0) at iovsprintf.c:42
#4 0x00007ffff7892774 in __sprintf (s=<optimized out>, format=<optimized out>)
at sprintf.c:32
#5 0x0000000000449876 in qbs_str (value=10) at libqb.cpp:6893
#6 0x00000000004095e7 in QBMAIN (unused=0x0) at ../temp/main.txt:47
#7 0x00000000004091fb in QBMAIN_LINUX (unused=0x0) at qbx.cpp:2084
#8 0x00007ffff7d34fa3 in start_thread (arg=<optimized out>)
at pthread_create.c:486
#9 0x00007ffff79334cf in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Note QBMAIN is at temp/main.txt line 47, so open internal/temp/main.txt and look at line 47:
45 do{
46 tqbs=qbs_new(0,0);
47 qbs_set(tqbs,qbs_add(qbs_str((float)(*__SINGLE_I)),qbs_new_txt(" ")));
48 if (new_error) goto skip6;
49 makefit(tqbs);
50 qbs_print(tqbs,0);
51 qbs_print(nothingstring,1);
52 skip6:
53 qbs_free(tqbs);
54 qbs_cleanup(qbs_tmp_base,0);
55 if(!qbevent)break;evnt(6);}while(r);
Line 55 is a code fragment that is generated after every BASIC line (more or less). The call to evnt(6) indicates that the preceeding code, including line 47, corresponds to line 6 in the BASIC source.