[llvm-commits] [llvm-gcc-4.2] r64836 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-debug.cpp
Devang Patel
dpatel at apple.com
Tue Feb 17 14:47:23 PST 2009
Author: dpatel
Date: Tue Feb 17 16:47:23 2009
New Revision: 64836
URL: http://llvm.org/viewvc/llvm-project?rev=64836&view=rev
Log:
The debugger sometimes lookup dynamically in the runtime to find ivar info of any Objective-C classes. It would be very helpful to debugger if the compiler encodes runtime version number in DWARF.
Update llvm-gcc FE to encode objective runtime version number in compile unit and class DIEs.
- This line, and those below, will be ignored--
M gcc/llvm-backend.cpp
M gcc/llvm-debug.cpp
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=64836&r1=64835&r2=64836&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Feb 17 16:47:23 2009
@@ -264,6 +264,18 @@
}
void llvm_lang_dependent_init(const char *Name) {
+
+ // Each input file is encoded as a separate compile unit in LLVM
+ // debugging information output. However, many target specific tool chains
+ // prefer to encode only one compile unit in an object file. In this
+ // situation, the LLVM code generator will include debugging information
+ // entities in the compile unit that is marked as main compile unit. The
+ // code generator accepts maximum one main compile unit per module. If a
+ // module does not contain any main compile unit then the code generator
+ // will emit multiple compile units in the output object file.
+ if (TheDebugInfo)
+ TheDebugInfo->getOrCreateCompileUnit(main_input_filename, true);
+
if (Name)
TheModule->setModuleIdentifier(Name);
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=64836&r1=64835&r2=64836&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Feb 17 16:47:23 2009
@@ -202,18 +202,7 @@
, PrevLineNo(0)
, PrevBB(NULL)
, RegionStack()
-{
-
- // Each input file is encoded as a separate compile unit in LLVM
- // debugging information output. However, many target specific tool chains
- // prefer to encode only one compile unit in an object file. In this
- // situation, the LLVM code generator will include debugging information
- // entities in the compile unit that is marked as main compile unit. The
- // code generator accepts maximum one main compile unit per module. If a
- // module does not contain any main compile unit then the code generator
- // will emit multiple compile units in the output object file.
- DICompileUnit M = getOrCreateCompileUnit(main_input_filename, true);
-}
+{}
/// EmitFunctionStart - Constructs the debug code for entering a function -
/// "llvm.dbg.func.start."
@@ -546,6 +535,27 @@
unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
DW_TAG_union_type;
+ unsigned RunTimeLang = 0;
+ if (TYPE_LANG_SPECIFIC (type)
+ && lang_hooks.types.is_runtime_specific_type (type))
+ {
+ DICompileUnit CU = getOrCreateCompileUnit(main_input_filename);
+ unsigned CULang = CU.getLanguage();
+ switch (CULang) {
+ case DW_LANG_ObjC_plus_plus :
+ RunTimeLang = DW_LANG_ObjC_plus_plus;
+ break;
+ case DW_LANG_ObjC :
+ RunTimeLang = DW_LANG_ObjC;
+ break;
+ case DW_LANG_C_plus_plus :
+ RunTimeLang = DW_LANG_C_plus_plus;
+ break;
+ default:
+ break;
+ }
+ }
+
// Records and classes and unions can all be recursive. To handle them,
// we first generate a debug descriptor for the struct as a forward
// declaration. Then (if it is a definition) we go through and get debug
@@ -561,7 +571,8 @@
getOrCreateCompileUnit(Loc.file),
Loc.line,
0, 0, 0, llvm::DIType::FlagFwdDecl,
- llvm::DIType(), llvm::DIArray());
+ llvm::DIType(), llvm::DIArray(),
+ RunTimeLang);
// forward declaration,
if (TYPE_SIZE(type) == 0)
@@ -667,7 +678,8 @@
getOrCreateCompileUnit(Loc.file),
Loc.line,
NodeSizeInBits(type), NodeAlignInBits(type),
- 0, 0, llvm::DIType(), Elements);
+ 0, 0, llvm::DIType(), Elements,
+ RunTimeLang);
// Now that we have a real decl for the struct, replace anything using the
// old decl with the new one. This will recursively update the debug info.
@@ -856,10 +868,13 @@
if (debugopt && debugopt[0])
Flags = get_arguments();
- DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName,
- Directory,
- version_string, isMain,
- optimize, Flags);
+ // flag_objc_abi represents Objective-C runtime version number. It is zero
+ // for all other language.
+ DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName,
+ Directory,
+ version_string, isMain,
+ optimize, Flags,
+ flag_objc_abi);
CU = NewCU.getGV();
return NewCU;
}
More information about the llvm-commits
mailing list