[Lldb-commits] QBASIC support in LLDB

Enrico Granata egranata at apple.com
Wed Apr 1 10:42:07 PDT 2015

Hi all,
I am excited to announce that over the next couple of days I am going to commit patches that enable LLDB to debug QBASIC programs

This is what your experience will look like

(lldb) target create -Q file.bas
Current executable set to 'qbasic.exe' (i386*).
* no really, we setup DOSBOX to run qbasic on an emulated 386.

You can set a breakpoint by function, obviously, or by line number because it is BASIC

(lldb) break set -n MyFunction
Breakpoint 1: 3 locations.

(lldb) break set -l 386
Breakpoint 2: 1 location.

Launching the program will setup a DOSBOX session, launch QBASIC.EXE inside said session, and then hijack control of DOSBOX so that:
a) we can insert breakpoints as needed
b) we can gather the AST from QBASIC to create types
c) we can gather variable information

(lldb) run
Process 40774 launched: 'qbasic' (i386)*
* no really, we setup DOSBOX to run qbasic on an emulated 386.
Process 40774 stopped
* thread #1: tid = 0xcb3f2, 0x00007fff8c39736b qbasic.exe`main:386, stop reason = breakpoint 2.1
    frame #0: 0x00007fff8c39736b qbasic.exe`main:386
386 IF I$ = "" : PRINT "HELLO WORLD"
387 IF I% > 0: I% = I% - 1
388 IF I% > 0: I% = I% - 1
389 IF I% > 0: GOSUB 401

You can inspect variables
(lldb) frame variable
DIM I% = 12
DIM I$ = ""

as you can see, we changed the default style of “frame variable” to reflect the syntax of BASIC more closely. This is work I am personally quite proud of.
And, of course, Sean spent a considerable amount of time assuring reliable expression evaluation works naturally:

(lldb) expr I% + 12
DIM LRV0% = 24

We decided that $ symbols were confusing - imagine $0$ for a string result - so we went with a LRV prefix (LLDB result variable)

Flow control across subroutine calls is very stable - still a little flakey when it comes to GOSUBs but we plan to enhance that over the coming weeks

I think this is a great addition to LLDB and I look forward to your feedback

disclaimer: you will need to supply your own legally licensed copy of QBASIC.EXE for this to work. If you can’t acquire one, you can build with the LLDB_DISABLE_AWESOMENESS macro defined and that will disable building the QBASIC support

- Enrico
📩 egranata@.com ☎️ 27683

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150401/d61f4876/attachment.html>

More information about the lldb-commits mailing list