To change file in the middle of a scope, you can use the second kind
of block descriptor described here:
http://llvm.org/docs/SourceLevelDebugging.html#block-descriptors
and/or take a look at the LLVM IR Clang generates if you #include
source code into a function, for example. (eg: have an include file
with a couple of random statements, have another include file with
more statements, and include those both inside "int main" - then look
at the debug locations on the instructions in the resulting IR)
On Sun, Jun 8, 2014 at 6:21 AM, John.Slagel <john.slagel at gmail.com>
wrote:> I'm writing an old-school BASIC compiler using LLVM to make Windows
> executables (using MingGW linker), everything works great so far, including
> the debug info, with one exception.
>
> A BASIC module (.bas file) doesn't have a "main" function, so
I create a
> fake _main function and use that function as the scope for each
intruction's
> line number debug information. This way I can single step with gdb:
>
> =========== file x.bas =======> print "hello 1"
> print "hello 2"
>
> ============= sample gdb session ==========> D:\dev\BasicParser>gdb
x.exe
> GNU gdb (GDB) 7.4
> <snip>
> Reading symbols from D:\dev\BasicParser\x.exe...done.
> (gdb) b _main
> Breakpoint 1 at 0x401000: file x.bas, line 1.
> (gdb) r
> Starting program: D:\dev\BasicParser\x.exe
> [New Thread 6164.0xc9c]
>
> Breakpoint 1, _main () at x.bas:1
> 1 print "hello 1"
> (gdb) n
> hello 1
> 2 print "hello 2"
> (gdb) n
> hello 2
> [Inferior 1 (process 6164) exited normally]
> (gdb) q
>
>
> The problem I now face is that the flavor of BASIC I support can use
include
> files using the meta-command REM $include:
> As shown in this example:
>
> =========== file a.bas ==============> x$ = "File A"
> 10 print "In file A"
> rem $include: 'b.bi'
> 30 print "Back to file A"
> print "X$=";x$
>
> ========= file b.bi ===========> 15 print "At line 15 in file
b"
> 17 print "At line 17 in file b"
> x$ = "File B"
>
> And when I execute a.exe I get:
>
> In file A
> At line 15 in file b
> At line 17 in file b
> Back to file A
> X$=File B
>
> So the "fake" main function now spans two files.
>
> My question is, if currently I link each instruction to the function's
> scope, what concepts do I need to study to figure out how to make each line
> in a function cross into another file?
> My guess is that I'll need to manage a set of scope blocks for each
> function, where each block comes from a different file, and link each
> instruction to one of these blocks instead of to the function...
>
> Thanks!!
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev