[llvm-commits] [llvm] r78603 - in /llvm/trunk/lib/Target/PIC16: PIC16DebugInfo.cpp PIC16DebugInfo.h

Devang Patel dpatel at apple.com
Thu Aug 13 10:14:30 PDT 2009


On Aug 12, 2009, at 10:26 PM, Sanjiv Gupta wrote:

> Hi Devang,
> Do we have a plan to include information about composite types also  
> in DbgFinder? Currently I can see only llvm.debug.global_variables.

I updated DebugInfoFinder in the previous revision (78602) to keep  
track of all types (DIType). DICompositeType is derived from DIType.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090810/084064.html

-
Devang

>
>
> - Sanjiv
>
> Devang Patel wrote:
>> Author: dpatel
>> Date: Mon Aug 10 17:11:20 2009
>> New Revision: 78603
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=78603&view=rev
>> Log:
>> Do not rely on magic "llvm.dbg.*" global variable name to find  
>> debug info.
>> PIC16 developers, please verify.
>> Modified:
>>    llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp
>>    llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h
>>
>> Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=78603&r1=78602&r2=78603&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original)
>> +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Mon Aug 10  
>> 17:11:20 2009
>> @@ -17,6 +17,7 @@
>> #include "llvm/CodeGen/MachineFunction.h"
>> #include "llvm/Support/DebugLoc.h"
>> #include "llvm/Support/FormattedStream.h"
>> +#include "llvm/ADT/SmallString.h"
>>  using namespace llvm;
>> @@ -117,6 +118,8 @@
>>   CTy.getName(TagName);
>>   // UniqueSuffix is .number where number is obtained from
>>   // llvm.dbg.composite<number>.
>> +  // FIXME: This will break when composite type is not represented  
>> by
>> +  // llvm.dbg.composite* global variable. This is not supported.
>>   std::string UniqueSuffix = "." + Ty.getGV()- 
>> >getNameStr().substr(18);
>>   TagName += UniqueSuffix;
>>   unsigned short size = CTy.getSizeInBits()/8;
>> @@ -290,7 +293,7 @@
>> /// composite type.
>> ///  void PIC16DbgInfo::EmitCompositeTypeElements (DICompositeType  
>> CTy,
>> -                                              std::string  
>> UniqueSuffix) { +                                               
>> unsigned SuffixNo) {
>>   unsigned long Value = 0;
>>   DIArray Elements = CTy.getTypeArray();
>>   for (unsigned i = 0, N = Elements.getNumElements(); i < N; i++) {
>> @@ -305,18 +308,19 @@
>>     DITy.getName(ElementName);
>>     unsigned short ElementSize = DITy.getSizeInBits()/8;
>>     // Get mangleddd name for this structure/union  element.
>> -    std::string MangMemName = ElementName + UniqueSuffix;
>> +    SmallString<128> MangMemName(ElementName.begin(),  
>> ElementName.end());
>> +    MangMemName.append_uint_32(SuffixNo);
>>     PopulateDebugInfo(DITy, TypeNo, HasAux, ElementAux, TagName);
>>     short Class = 0;
>>     if( CTy.getTag() == dwarf::DW_TAG_union_type)
>>       Class = PIC16Dbg::C_MOU;
>>     else if  (CTy.getTag() == dwarf::DW_TAG_structure_type)
>>       Class = PIC16Dbg::C_MOS;
>> -    EmitSymbol(MangMemName, Class, TypeNo, Value);
>> +    EmitSymbol(MangMemName.c_str(), Class, TypeNo, Value);
>>     if (CTy.getTag() == dwarf::DW_TAG_structure_type)
>>       Value += ElementSize;
>>     if (HasAux)
>> -      EmitAuxEntry(MangMemName, ElementAux, PIC16Dbg::AuxSize,  
>> TagName);
>> +      EmitAuxEntry(MangMemName.c_str(), ElementAux,  
>> PIC16Dbg::AuxSize, TagName);
>>   }
>> }
>> @@ -324,49 +328,49 @@
>> /// and union declarations.
>> ///
>> void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) {
>> -  for(iplist<GlobalVariable>::iterator I =  
>> M.getGlobalList().begin(),
>> -      E = M.getGlobalList().end(); I != E; I++) {
>> -    // Structures and union declaration's debug info has  
>> llvm.dbg.composite
>> -    // in its name.
>> -    // FIXME: Checking and relying on llvm.dbg.composite name is  
>> not a good idea.
>> -    if(I->getNameStr().find("llvm.dbg.composite") !=  
>> std::string::npos) {
>> -      GlobalVariable *GV = cast<GlobalVariable >(I);
>> -      DICompositeType CTy(GV);
>> -      if (CTy.getTag() == dwarf::DW_TAG_union_type ||
>> -          CTy.getTag() == dwarf::DW_TAG_structure_type ) {
>> -        std::string name;
>> -        CTy.getName(name);
>> -        std::string DIVar = I->getName();
>> -        // Get the number after llvm.dbg.composite and make  
>> UniqueSuffix from -        // it.
>> -        std::string UniqueSuffix = "." + DIVar.substr(18);
>> -        std::string MangledCTyName = name + UniqueSuffix;
>> -        unsigned short size = CTy.getSizeInBits()/8;
>> -        int Aux[PIC16Dbg::AuxSize] = {0};
>> -        // 7th and 8th byte represent size of structure/union.
>> -        Aux[6] = size & 0xff;
>> -        Aux[7] = size >> 8;
>> -        // Emit .def for structure/union tag.
>> -        if( CTy.getTag() == dwarf::DW_TAG_union_type)
>> -          EmitSymbol(MangledCTyName, PIC16Dbg::C_UNTAG);
>> -        else if  (CTy.getTag() == dwarf::DW_TAG_structure_type)  
>> -          EmitSymbol(MangledCTyName, PIC16Dbg::C_STRTAG);
>> -
>> -        // Emit auxiliary debug information for structure/union  
>> tag. -        EmitAuxEntry(MangledCTyName, Aux, PIC16Dbg::AuxSize);
>> -
>> -        // Emit members.
>> -        EmitCompositeTypeElements (CTy, UniqueSuffix);
>> -
>> -        // Emit mangled Symbol for end of structure/union.
>> -        std::string EOSSymbol = ".eos" + UniqueSuffix;
>> -        EmitSymbol(EOSSymbol, PIC16Dbg::C_EOS);
>> -        EmitAuxEntry(EOSSymbol, Aux, PIC16Dbg::AuxSize,  
>> MangledCTyName);
>> -      }
>> +  DebugInfoFinder DbgFinder;
>> +  DbgFinder.processModule(M);
>> +  unsigned SuffixNo = 0;
>> +  for (DebugInfoFinder::iterator I =  
>> DbgFinder.global_variable_begin(),
>> +         E = DbgFinder.global_variable_end(); I != E; ++I) {
>> +    DICompositeType CTy(*I);
>> +    if (CTy.isNull())
>> +      continue;
>> +    if (CTy.getTag() == dwarf::DW_TAG_union_type ||
>> +        CTy.getTag() == dwarf::DW_TAG_structure_type ) {
>> +      std::string Name;
>> +      CTy.getName(Name);
>> +      SmallString<128> MangledCTyName(Name.begin(), Name.end());
>> +      MangledCTyName.append_uint_32(++SuffixNo);
>> +      unsigned short size = CTy.getSizeInBits()/8;
>> +      int Aux[PIC16Dbg::AuxSize] = {0};
>> +      // 7th and 8th byte represent size of structure/union.
>> +      Aux[6] = size & 0xff;
>> +      Aux[7] = size >> 8;
>> +      // Emit .def for structure/union tag.
>> +      if( CTy.getTag() == dwarf::DW_TAG_union_type)
>> +        EmitSymbol(MangledCTyName.c_str(), PIC16Dbg::C_UNTAG);
>> +      else if  (CTy.getTag() == dwarf::DW_TAG_structure_type)  
>> +        EmitSymbol(MangledCTyName.c_str(), PIC16Dbg::C_STRTAG);
>> +      +      // Emit auxiliary debug information for structure/ 
>> union tag. +      EmitAuxEntry(MangledCTyName.c_str(), Aux,  
>> PIC16Dbg::AuxSize);
>> +      +      // Emit members.
>> +      EmitCompositeTypeElements (CTy, SuffixNo);
>> +      +      // Emit mangled Symbol for end of structure/union.
>> +      SmallString<128> EOSSymbol(Name.begin(), Name.end());
>> +      EOSSymbol += ".eos";
>> +      EOSSymbol.append_uint_32(SuffixNo);
>> +      EmitSymbol(EOSSymbol.c_str(), PIC16Dbg::C_EOS);
>> +      EmitAuxEntry(EOSSymbol.c_str(), Aux, PIC16Dbg::AuxSize,  
>> +                   MangledCTyName.c_str());
>>     }
>>   }
>> }
>> +
>> /// EmitFunctBeginDI - Emit .bf for function.
>> ///
>> void PIC16DbgInfo::EmitFunctBeginDI(const Function *F) {
>>
>> Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h?rev=78603&r1=78602&r2=78603&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h (original)
>> +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Mon Aug 10  
>> 17:11:20 2009
>> @@ -145,8 +145,7 @@
>>     short getStorageClass(DIGlobalVariable DIGV);
>>     void EmitFunctBeginDI(const Function *F);
>>     void EmitCompositeTypeDecls(Module &M);
>> -    void EmitCompositeTypeElements (DICompositeType CTy,
>> -                                    std::string UniqueSuffix);
>> +    void EmitCompositeTypeElements (DICompositeType CTy, unsigned  
>> Suffix);
>>     void EmitFunctEndDI(const Function *F, unsigned Line);
>>     void EmitAuxEntry(const std::string VarName, int  
>> Aux[],                        int num = PIC16Dbg::AuxSize,  
>> std::string TagName = "");
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>




More information about the llvm-commits mailing list