Emit DWARF sections with NVPTX

Hi all,

I'm emitting PTX code from an LLVM module using
TargetMachine::addPassesToEmitFile, and I'm currently trying to add
debug information to the mix. The goal is to load and run my PTX code
under cuda-memcheck.

My IR contains proper debug information, which results in `.loc`
statements generated by NVPTX. Additionally, I set the -debug-compile
flag (using cl::ParseCommandLineOptions, is there another way to do
this?). The resulting PTX code doesn't contain a debug_info section
though, making it invalid (ptxas complains "Debug information not found
in presence of .target debug").

How do I configure LLVM to emit those DWARF sections? I found
MCContext::GenDwarfForAssembly, but that doesn't seem easy to modify
when using addPassesToEmitFile, and when I did (hackishly) the resulting
PTX only contained a seemingly invalid top-level "Lline_table_start0:".

Thanks,