This project is read-only.

how te create a pdb from scratch?

Topics: PDB Writer
Jun 19, 2011 at 5:55 PM

Hi there,

 

I am working on a DSL(Domain Specific Language). Of course, this is just a programming language just like any other, but specialized.

The parsing(ANTLR) has been setup and works great. So is the creation of a DLL with CCIAST. It works very nicely!! However, I want my DLL to be debuggable. This works by creating a PDB file, and CCI seems to have support for it. However, I can't figure out how it works. I can create a PdbWriter instance and pass it to the PE writer. But how do I feed it with information during the creation of statements/expressions with cciast?

 

Cheers,

 

Martin

Jun 20, 2011 at 7:23 AM

This discussion should probably move to cciast.codeplex.com. I've updated the HelloAST sample in that repository to write out a PDB file. Have a look and see if that gets you going.

Jun 20, 2011 at 2:33 PM

Thanks for the update on the sample, it helped a bit.

 

The PDB is created, and I managed to get some variable(Property) information in it. When debugging the DLL I can inspect the value of a variable!!

 

What I dont get to work is this:

Assign a group of statements to a line of source code. Suppose in my DSL I have the line: 

Foo = 1;

The parser uses the Assignment class to create assignment IL code. I provide source location information, but when I debug the generated DLL it sees the whole source as 1 line. The whole source code is set as a breakpoint(RED in default VS2010 color scheme). Even if i provide 2 lines of code, the VS2010 debugger sees the whole source as 1 statement. How do I 'attach' a single line of DSL source code to a group of AST Statements? (or the other way around -> This bunch of AST Statements represents the following piece of text).

 

Cheers

 

Martin

Jun 20, 2011 at 3:27 PM

When you create the AST node for a statement it must have a (startline, startcol, endline, endcol) source location that is unique, otherwise the debugger doesn't know how to map cursor locations to executable instructions. Only statement source locations are emitted to the PDB file.

The AST itself should preserve the invariant that the source location of a node always spans the source locations of its children. This doesn't matter much for PDB generation, but is useful for looking things up by source location, which is what happens when you write your own editor plug-in, or if you do incremental compilation.

Jun 20, 2011 at 4:09 PM

"Only statement source locations are emitted" Very usefull information!!! Thanks! :)

Got it almost working, I'll post an example when its done, for future readers ;)