[cfe-dev] Debugging Information

Chris Lattner clattner at apple.com
Sat Nov 10 18:51:03 PST 2007


On Nov 10, 2007, at 12:04 PM, Cédric Venet wrote:

>>>> I am investigating adding debugging information to clang. Do you
>>>> think it to
>>>> soon? (I would like to add a -g flag to the drivers and add
>>>> conditional llvm
>>>> debug intrinsic emission in CodeGen).
>>>> Do you have already some idea on the question? (I studied llvm-gcc
>>>> debug
>>>> generation and would add something similar)
>>
>> I'm not currently involved with the efforts on the CodeGen module.
>> Chris, Devang?

Noone is working on extending clang to produce debug info.  Note that - 
emit-llvm in general is still pretty early on.  It is sufficient to  
run a bunch of small programs, but still has a number of limitations.   
We'll probably focus on getting -emit-llvm to 100% completeness and  
correctness before tackling debug info.

If you wanted to tackle debug info, I think it would be a great  
project!  It is also nicely parallelizable.  I'd get a copy of llvm- 
gcc and see the debug info it emits at -O0 -g for reference.

> I started coding and have a few functionalities working but I hesitate
> between two possible implementations.
>
> What I started doing is:
>
> - Add members and accessor functions to CodeGenModule and  
> CodeGenFuntion.
> - Insert code directly in the code generating function of these class,
> conditionnaly activated on a flag:

I'd suggest adding a new class, e.g. CodeGenDebugInfo that holds the  
debug related information.  This is the model that llvm-gcc uses it  
it's llvm-convert.cpp and llvm-debug.cpp files.  The nice thing about  
this is that you can then do stuff like:

void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
[...]

  // Create subprogram descriptor.
  if (DebugInfo)
    DebugInfo->CreateSubProgramDesc(...);


The nice thing about this model is that it keeps the debug info  
emission code localized in one file, while making the hooks into it  
obvious.

> Sorry for the long long mail...

No problem!  I'm glad you're interested in this area,

> Ps2: Should the first letter of method be a upper or a lower case:
> setA(); or SetA();
> getA();
> isA();

There isn't a standard naming scheme :-/ , I'd just follow the example  
of the code that it interacts with.

> ps3: If my English is too bad, says it and I will try to do better.  
> The
> thing is I lake practice and I have never be good in grammar (even  
> In my
> natural language)

Your English is excellent!

-Chris



More information about the cfe-dev mailing list