Mercurial > projects > ldc
annotate gen/todebug.cpp @ 785:ac39e5449ca5
Apply Elrood's CMake changes from #124. Thanks a lot!
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 24 Nov 2008 18:17:58 +0100 |
parents | e4e50f4b58cd |
children | 340acf1535d0 |
rev | line source |
---|---|
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
1 #include "gen/llvm.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
2 #include "llvm/Support/Dwarf.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
3 #include "llvm/CodeGen/MachineModuleInfo.h" |
285
297690b5d4a5
[svn r306] Fixed: it's now possible to compile and link llvmdc with MinGW32 and msys on Win32 :D I tried it myself ;) Building the runtime still needs some work, but it's a step in the right direction.
lindquist
parents:
268
diff
changeset
|
4 #include "llvm/System/Path.h" |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
5 |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
6 #include "declaration.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
7 #include "module.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
8 #include "mars.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
9 |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
10 #include "gen/todebug.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
11 #include "gen/irstate.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
12 #include "gen/tollvm.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
13 #include "gen/logger.h" |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
14 |
139
0ab29b838084
[svn r143] Fixed: a few bugs in debug information, still only line info, but should be correct files now :)
lindquist
parents:
136
diff
changeset
|
15 #include "ir/irmodule.h" |
0ab29b838084
[svn r143] Fixed: a few bugs in debug information, still only line info, but should be correct files now :)
lindquist
parents:
136
diff
changeset
|
16 |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
17 using namespace llvm::dwarf; |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
18 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
19 #define DBG_NULL ( LLConstant::getNullValue(DBG_TYPE) ) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
20 #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
21 #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
22 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
23 #define DBG_TAG(X) ( llvm::ConstantExpr::getAdd( DtoConstUint( X ), DtoConstUint( llvm::LLVMDebugVersion ) ) ) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
24 |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
25 ////////////////////////////////////////////////////////////////////////////////////////////////// |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
26 |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
27 /** |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
28 * Emits a global variable, LLVM Dwarf style. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
29 * @param type Type of variable. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
30 * @param values Initializers. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
31 * @param name Name. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
32 * @return The global variable. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
33 */ |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
34 static LLGlobalVariable* emitDwarfGlobal(const LLStructType* type, const std::vector<LLConstant*> values, const char* name, bool linkonce=false) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
35 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
36 LLConstant* c = llvm::ConstantStruct::get(type, values); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
37 LLGlobalValue::LinkageTypes linkage = linkonce ? LLGlobalValue::LinkOnceLinkage : LLGlobalValue::InternalLinkage; |
252 | 38 LLGlobalVariable* gv = new LLGlobalVariable(type, true, linkage, c, name, gIR->module); |
39 gv->setSection("llvm.metadata"); | |
40 return gv; | |
41 } | |
42 | |
43 /** | |
44 * Emits a global variable, LLVM Dwarf style, only declares. | |
45 * @param type Type of variable. | |
46 * @param name Name. | |
47 * @return The global variable. | |
48 */ | |
49 static LLGlobalVariable* emitDwarfGlobalDecl(const LLStructType* type, const char* name, bool linkonce=false) | |
50 { | |
51 LLGlobalValue::LinkageTypes linkage = linkonce ? LLGlobalValue::LinkOnceLinkage : LLGlobalValue::InternalLinkage; | |
52 LLGlobalVariable* gv = new LLGlobalVariable(type, true, linkage, NULL, name, gIR->module); | |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
53 gv->setSection("llvm.metadata"); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
54 return gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
55 } |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
56 |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
57 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
58 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
59 /** |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
60 * Emits the Dwarf anchors that are used repeatedly by LLVM debug info. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
61 */ |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
62 static void emitDwarfAnchors() |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
63 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
64 const llvm::StructType* anchorTy = isaStruct(gIR->module->getTypeByName("llvm.dbg.anchor.type")); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
65 std::vector<LLConstant*> vals(2); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
66 |
252 | 67 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); |
68 vals[1] = DtoConstUint(DW_TAG_compile_unit); | |
69 gIR->dwarfCUs = emitDwarfGlobal(anchorTy, vals, "llvm.dbg.compile_units", true); | |
70 | |
71 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); | |
72 vals[1] = DtoConstUint(DW_TAG_variable); | |
73 gIR->dwarfGVs = emitDwarfGlobal(anchorTy, vals, "llvm.dbg.global_variables", true); | |
74 | |
75 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); | |
76 vals[1] = DtoConstUint(DW_TAG_subprogram); | |
77 gIR->dwarfSPs = emitDwarfGlobal(anchorTy, vals, "llvm.dbg.subprograms", true); | |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
78 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
79 |
252 | 80 ////////////////////////////////////////////////////////////////////////////////////////////////// |
81 | |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
82 static LLConstant* getDwarfAnchor(dwarf_constants c) |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
83 { |
252 | 84 if (!gIR->dwarfCUs) |
85 emitDwarfAnchors(); | |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
86 switch (c) |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
87 { |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
88 case DW_TAG_compile_unit: |
252 | 89 return gIR->dwarfCUs; |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
90 case DW_TAG_variable: |
252 | 91 return gIR->dwarfGVs; |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
92 case DW_TAG_subprogram: |
252 | 93 return gIR->dwarfSPs; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
94 default: |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
95 assert(0); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
96 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
97 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
98 |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
99 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
100 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
101 static const llvm::StructType* getDwarfCompileUnitType() { |
96 | 102 return isaStruct(gIR->module->getTypeByName("llvm.dbg.compile_unit.type")); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
103 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
104 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
105 static const llvm::StructType* getDwarfSubProgramType() { |
96 | 106 return isaStruct(gIR->module->getTypeByName("llvm.dbg.subprogram.type")); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
107 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
108 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
109 static const llvm::StructType* getDwarfVariableType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
110 return isaStruct(gIR->module->getTypeByName("llvm.dbg.variable.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
111 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
112 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
113 static const llvm::StructType* getDwarfDerivedTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
114 return isaStruct(gIR->module->getTypeByName("llvm.dbg.derivedtype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
115 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
116 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
117 static const llvm::StructType* getDwarfBasicTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
118 return isaStruct(gIR->module->getTypeByName("llvm.dbg.basictype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
119 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
120 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
121 static const llvm::StructType* getDwarfCompositeTypeType() { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
122 return isaStruct(gIR->module->getTypeByName("llvm.dbg.compositetype.type")); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
123 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
124 |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
125 static const llvm::StructType* getDwarfGlobalVariableType() { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
126 return isaStruct(gIR->module->getTypeByName("llvm.dbg.global_variable.type")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
127 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
128 |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
129 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
130 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
131 static LLGlobalVariable* dwarfCompileUnit(Module* m) |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
132 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
133 std::vector<LLConstant*> vals(6); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
134 vals[0] = DBG_TAG(DW_TAG_compile_unit); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
135 vals[1] = DBG_CAST(getDwarfAnchor(DW_TAG_compile_unit)); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
136 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
137 vals[2] = DtoConstUint(DW_LANG_C);// _D)); // doesn't seem to work |
718
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
138 vals[3] = DtoConstStringPtr(FileName::name(m->srcfile->name->toChars()), "llvm.metadata"); |
139
0ab29b838084
[svn r143] Fixed: a few bugs in debug information, still only line info, but should be correct files now :)
lindquist
parents:
136
diff
changeset
|
139 std::string srcpath(FileName::path(m->srcfile->name->toChars())); |
718
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
140 if (!FileName::absolute(srcpath.c_str())) { |
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
141 llvm::sys::Path tmp = llvm::sys::Path::GetCurrentDirectory(); |
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
142 tmp.appendComponent(srcpath); |
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
143 srcpath = tmp.toString(); |
736 | 144 if (!srcpath.empty() && *srcpath.rbegin() != '/' && *srcpath.rbegin() != '\\') |
729
50d01791859c
Always add trailing slash to source path for debug info.
Christian Kamm <kamm incasoftware de>
parents:
718
diff
changeset
|
145 srcpath = srcpath + '/'; |
718
72ee105be27b
Make sure debug info has correct file name and path.
Christian Kamm <kamm incasoftware de>
parents:
702
diff
changeset
|
146 } |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
147 vals[4] = DtoConstStringPtr(srcpath.c_str(), "llvm.metadata"); |
690 | 148 vals[5] = DtoConstStringPtr("LDC (http://www.dsource.org/projects/ldc)", "llvm.metadata"); |
139
0ab29b838084
[svn r143] Fixed: a few bugs in debug information, still only line info, but should be correct files now :)
lindquist
parents:
136
diff
changeset
|
149 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
150 LLGlobalVariable* gv = emitDwarfGlobal(getDwarfCompileUnitType(), vals, "llvm.dbg.compile_unit"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
151 m->ir.irModule->dwarfCompileUnit = gv; |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
152 return gv; |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
153 } |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
154 |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
155 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
156 |
702
353d9d184091
changed uint to unsigned int, thanks Elrood
Christian Kamm <kamm incasoftware de>
parents:
690
diff
changeset
|
157 static LLGlobalVariable* dwarfSubProgram(llvm::GlobalVariable* emitUnit, llvm::GlobalVariable* defineUnit, const char* prettyname, const char* mangledname, unsigned int linenum, bool isprivate) |
686
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
158 { |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
159 std::vector<LLConstant*> vals(11); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
160 vals[0] = DBG_TAG(DW_TAG_subprogram); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
161 vals[1] = DBG_CAST(getDwarfAnchor(DW_TAG_subprogram)); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
162 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
163 vals[2] = DBG_CAST(emitUnit); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
164 vals[3] = DtoConstStringPtr(prettyname, "llvm.metadata"); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
165 vals[4] = vals[3]; |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
166 vals[5] = DtoConstStringPtr(mangledname, "llvm.metadata"); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
167 vals[6] = DBG_CAST(defineUnit); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
168 vals[7] = DtoConstUint(linenum); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
169 vals[8] = DBG_NULL; |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
170 vals[9] = DtoConstBool(isprivate); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
171 vals[10] = DtoConstBool(emitUnit == defineUnit); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
172 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
173 Logger::println("emitting subprogram global"); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
174 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
175 return emitDwarfGlobal(getDwarfSubProgramType(), vals, "llvm.dbg.subprogram"); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
176 } |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
177 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
178 /* |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
179 static LLGlobalVariable* dwarfSubProgram(FuncDeclaration* fd, llvm::GlobalVariable* compileUnit) |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
180 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
181 std::vector<LLConstant*> vals(11); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
182 vals[0] = DBG_TAG(DW_TAG_subprogram); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
183 vals[1] = DBG_CAST(getDwarfAnchor(DW_TAG_subprogram)); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
184 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
185 vals[2] = DBG_CAST(compileUnit); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
186 vals[3] = DtoConstStringPtr(fd->toPrettyChars(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
187 vals[4] = vals[3]; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
188 vals[5] = DtoConstStringPtr(fd->mangle(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
189 vals[6] = DBG_CAST( DtoDwarfCompileUnit(fd->getModule()) ); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
190 vals[7] = DtoConstUint(fd->loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
191 vals[8] = DBG_NULL; |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
192 vals[9] = DtoConstBool(fd->protection == PROTprivate); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
193 vals[10] = DtoConstBool(fd->getModule() == gIR->dmodule); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
194 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
195 Logger::println("emitting subprogram global"); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
diff
changeset
|
196 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
197 return emitDwarfGlobal(getDwarfSubProgramType(), vals, "llvm.dbg.subprogram"); |
686
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
198 }*/ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
199 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
200 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
201 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
202 static LLGlobalVariable* dwarfTypeDescription_impl(Type* type, LLGlobalVariable* cu, const char* c_name); |
252 | 203 static LLGlobalVariable* dwarfTypeDescription(Type* type, LLGlobalVariable* cu, const char* c_name); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
204 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
205 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
206 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
207 static LLGlobalVariable* dwarfBasicType(Type* type, llvm::GlobalVariable* compileUnit) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
208 { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
209 Type* t = type->toBasetype(); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
210 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
211 const LLType* T = DtoType(type); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
212 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
213 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
214 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
215 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
216 vals[0] = DBG_TAG(DW_TAG_base_type); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
217 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
218 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
219 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
220 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
221 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
222 vals[2] = DtoConstStringPtr(type->toChars(), "llvm.metadata"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
223 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
224 // compile unit where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
225 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
226 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
227 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
228 vals[4] = DtoConstInt(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
229 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
230 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
231 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
232 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
233 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
234 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
235 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
236 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
237 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
238 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
239 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
240 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
241 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
242 // dwarf type |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
243 unsigned id; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
244 if (t->isintegral()) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
245 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
246 if (type->isunsigned()) |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
247 id = DW_ATE_unsigned; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
248 else |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
249 id = DW_ATE_signed; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
250 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
251 else if (t->isfloating()) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
252 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
253 id = DW_ATE_float; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
254 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
255 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
256 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
257 assert(0 && "unsupported basictype for debug info"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
258 } |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
259 vals[9] = DtoConstUint(id); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
260 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
261 return emitDwarfGlobal(getDwarfBasicTypeType(), vals, "llvm.dbg.basictype"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
262 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
263 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
264 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
265 |
252 | 266 static LLGlobalVariable* dwarfDerivedType(Type* type, llvm::GlobalVariable* compileUnit) |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
267 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
268 const LLType* T = DtoType(type); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
285
diff
changeset
|
269 Type* t = type->toBasetype(); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
270 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
271 // defaults |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
272 LLConstant* name = getNullPtr(getVoidPtrType()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
273 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
274 // find tag |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
275 unsigned tag; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
276 if (t->ty == Tpointer) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
277 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
278 tag = DW_TAG_pointer_type; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
279 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
280 else |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
281 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
282 assert(0 && "unsupported derivedtype for debug info"); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
283 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
284 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
285 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
286 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
287 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
288 vals[0] = DBG_TAG(tag); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
289 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
290 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
291 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
292 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
293 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
294 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
295 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
296 // compile unit where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
297 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
298 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
299 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
300 vals[4] = DtoConstInt(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
301 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
302 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
303 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
304 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
305 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
306 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
307 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
308 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
309 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
310 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
311 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
312 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
313 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
314 // base type |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
315 Type* nt = t->nextOf(); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
316 LLGlobalVariable* nTD = dwarfTypeDescription_impl(nt, compileUnit, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
317 if (nt->ty == Tvoid || !nTD) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
318 vals[9] = DBG_NULL; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
319 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
320 vals[9] = DBG_CAST(nTD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
321 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
322 return emitDwarfGlobal(getDwarfDerivedTypeType(), vals, "llvm.dbg.derivedtype"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
323 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
324 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
325 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
326 |
252 | 327 static LLGlobalVariable* dwarfMemberType(unsigned linnum, Type* type, LLGlobalVariable* compileUnit, LLGlobalVariable* definedCU, const char* c_name, unsigned offset) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
328 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
329 const LLType* T = DtoType(type); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
285
diff
changeset
|
330 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
331 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
332 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
333 LLConstant* name; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
334 if (c_name) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
335 name = DtoConstStringPtr(c_name, "llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
336 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
337 name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
338 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
339 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
340 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
341 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
342 vals[0] = DBG_TAG(DW_TAG_member); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
343 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
344 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
345 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
346 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
347 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
348 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
349 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
350 // compile unit where defined |
252 | 351 if (definedCU) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
352 vals[3] = DBG_CAST(definedCU); |
252 | 353 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
354 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
355 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
356 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
357 vals[4] = DtoConstInt(linnum); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
358 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
359 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
360 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
361 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
362 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
363 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
364 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
365 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
366 vals[7] = LLConstantInt::get(LLType::Int64Ty, offset*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
367 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
368 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
369 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
370 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
371 // base type |
252 | 372 LLGlobalVariable* nTD = dwarfTypeDescription(t, compileUnit, NULL); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
373 if (t->ty == Tvoid || !nTD) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
374 vals[9] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
375 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
376 vals[9] = DBG_CAST(nTD); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
377 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
378 return emitDwarfGlobal(getDwarfDerivedTypeType(), vals, "llvm.dbg.derivedtype"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
379 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
380 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
381 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
382 |
252 | 383 static LLGlobalVariable* dwarfCompositeType(Type* type, llvm::GlobalVariable* compileUnit) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
384 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
385 const LLType* T = DtoType(type); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
285
diff
changeset
|
386 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
387 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
388 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
389 LLConstant* name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
390 LLGlobalVariable* members = NULL; |
252 | 391 unsigned linnum = 0; |
392 LLGlobalVariable* definedCU = NULL; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
393 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
394 // prepare tag and members |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
395 unsigned tag; |
252 | 396 |
397 // declare final global variable | |
398 LLGlobalVariable* gv = NULL; | |
399 | |
400 // dynamic array | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
401 if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
402 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
403 tag = DW_TAG_structure_type; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
404 |
252 | 405 LLGlobalVariable* len = dwarfMemberType(0, Type::tsize_t, compileUnit, NULL, "length", 0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
406 assert(len); |
252 | 407 LLGlobalVariable* ptr = dwarfMemberType(0, t->nextOf()->pointerTo(), compileUnit, NULL, "ptr", global.params.is64bit?8:4); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
408 assert(ptr); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
409 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
410 const LLArrayType* at = LLArrayType::get(DBG_TYPE, 2); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
411 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
412 std::vector<LLConstant*> elems(2); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
413 elems[0] = DBG_CAST(len); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
414 elems[1] = DBG_CAST(ptr); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
415 |
252 | 416 LLConstant* ca = LLConstantArray::get(at, elems); |
417 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); | |
418 members->setSection("llvm.metadata"); | |
419 | |
420 name = DtoConstStringPtr(t->toChars(), "llvm.metadata"); | |
421 } | |
422 | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
423 // struct/class |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
424 else if (t->ty == Tstruct || t->ty == Tclass) |
252 | 425 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
426 AggregateDeclaration* sd; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
427 if (t->ty == Tstruct) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
428 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
429 TypeStruct* ts = (TypeStruct*)t; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
430 sd = ts->sym; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
431 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
432 else |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
433 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
434 TypeClass* tc = (TypeClass*)t; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
435 sd = tc->sym; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
436 } |
252 | 437 assert(sd); |
438 | |
439 IrStruct* ir = sd->ir.irStruct; | |
440 assert(ir); | |
441 if (ir->dwarfComposite) | |
442 return ir->dwarfComposite; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
443 |
252 | 444 // set to handle recursive types properly |
445 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype"); | |
446 ir->dwarfComposite = gv; | |
447 | |
448 tag = DW_TAG_structure_type; | |
449 | |
450 name = DtoConstStringPtr(sd->toChars(), "llvm.metadata"); | |
451 linnum = sd->loc.linnum; | |
452 definedCU = DtoDwarfCompileUnit(sd->getModule()); | |
453 | |
454 std::vector<LLConstant*> elems; | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
455 elems.reserve(ir->offsets.size()); |
252 | 456 for (IrStruct::OffsetMap::iterator i=ir->offsets.begin(); i!=ir->offsets.end(); ++i) |
457 { | |
458 unsigned offset = i->first; | |
459 IrStruct::Offset& o = i->second; | |
460 | |
461 LLGlobalVariable* ptr = dwarfMemberType(o.var->loc.linnum, o.var->type, compileUnit, definedCU, o.var->toChars(), offset); | |
462 elems.push_back(DBG_CAST(ptr)); | |
463 } | |
464 | |
465 const LLArrayType* at = LLArrayType::get(DBG_TYPE, elems.size()); | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
466 LLConstant* ca = LLConstantArray::get(at, elems); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
467 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
468 members->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
469 } |
252 | 470 |
471 // unsupported composite type | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
472 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
473 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
474 assert(0 && "unsupported compositetype for debug info"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
475 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
476 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
477 std::vector<LLConstant*> vals(11); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
478 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
479 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
480 vals[0] = DBG_TAG(tag); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
481 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
482 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
483 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
484 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
485 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
486 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
487 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
488 // compile unit where defined |
252 | 489 if (definedCU) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
490 vals[3] = DBG_CAST(definedCU); |
252 | 491 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
492 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
493 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
494 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
495 vals[4] = DtoConstInt(linnum); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
496 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
497 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
498 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
499 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
500 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
501 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
502 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
503 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
504 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
505 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
506 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
507 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
508 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
509 // FIXME: ditto |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
510 vals[9] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
511 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
512 // members array |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
513 if (members) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
514 vals[10] = DBG_CAST(members); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
515 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
516 vals[10] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
517 |
252 | 518 // set initializer |
519 if (!gv) | |
520 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype"); | |
521 LLConstant* initia = LLConstantStruct::get(getDwarfCompositeTypeType(), vals); | |
522 gv->setInitializer(initia); | |
523 | |
524 return gv; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
525 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
526 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
527 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
528 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
529 static LLGlobalVariable* dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
530 { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
531 assert(vd->isDataseg()); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
532 LLGlobalVariable* compileUnit = DtoDwarfCompileUnit(gIR->dmodule); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
533 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
534 std::vector<LLConstant*> vals(12); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
535 vals[0] = DBG_TAG(DW_TAG_variable); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
536 vals[1] = DBG_CAST(getDwarfAnchor(DW_TAG_variable)); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
537 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
538 vals[2] = DBG_CAST(compileUnit); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
539 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
540 vals[3] = DtoConstStringPtr(vd->mangle(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
541 vals[4] = DtoConstStringPtr(vd->toPrettyChars(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
542 vals[5] = DtoConstStringPtr(vd->toChars(), "llvm.metadata"); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
543 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
544 vals[6] = DBG_CAST(DtoDwarfCompileUnit(vd->getModule())); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
545 vals[7] = DtoConstUint(vd->loc.linnum); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
546 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
547 LLGlobalVariable* TY = dwarfTypeDescription_impl(vd->type, compileUnit, NULL); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
548 vals[8] = TY ? DBG_CAST(TY) : DBG_NULL; |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
549 vals[9] = DtoConstBool(vd->protection == PROTprivate); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
550 vals[10] = DtoConstBool(vd->getModule() == gIR->dmodule); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
551 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
552 vals[11] = DBG_CAST(ll); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
553 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
554 return emitDwarfGlobal(getDwarfGlobalVariableType(), vals, "llvm.dbg.global_variable"); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
555 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
556 |
252 | 557 ////////////////////////////////////////////////////////////////////////////////////////////////// |
558 | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
559 static LLGlobalVariable* dwarfVariable(VarDeclaration* vd, LLGlobalVariable* typeDescr) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
560 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
561 assert(!vd->isDataseg() && "static variable"); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
562 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
563 unsigned tag; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
564 if (vd->isParameter()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
565 tag = DW_TAG_arg_variable; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
566 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
567 tag = DW_TAG_auto_variable; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
568 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
569 std::vector<LLConstant*> vals(6); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
570 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
571 vals[0] = DBG_TAG(tag); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
572 // context |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
573 vals[1] = DBG_CAST(gIR->func()->dwarfSubProg); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
574 // name |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
575 vals[2] = DtoConstStringPtr(vd->toChars(), "llvm.metadata"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
576 // compile unit where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
577 vals[3] = DBG_CAST(DtoDwarfCompileUnit(vd->getModule())); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
578 // line number where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
579 vals[4] = DtoConstUint(vd->loc.linnum); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
580 // type descriptor |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
581 vals[5] = DBG_CAST(typeDescr); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
582 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
583 return emitDwarfGlobal(getDwarfVariableType(), vals, "llvm.dbg.variable"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
584 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
585 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
586 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
587 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
588 static void dwarfDeclare(LLValue* var, LLGlobalVariable* varDescr) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
589 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
590 LLSmallVector<LLValue*,2> args(2); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
591 args[0] = DtoBitCast(var, DBG_TYPE); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
592 args[1] = DBG_CAST(varDescr); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
593 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.declare"), args.begin(), args.end()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
594 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
595 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
596 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
597 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
598 static LLGlobalVariable* dwarfTypeDescription_impl(Type* type, LLGlobalVariable* cu, const char* c_name) |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
599 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
600 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
601 if (t->ty == Tvoid) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
602 return NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
603 else if (t->isintegral() || t->isfloating()) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
604 return dwarfBasicType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
605 else if (t->ty == Tpointer) |
252 | 606 return dwarfDerivedType(type, cu); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
607 else if (t->ty == Tarray || t->ty == Tstruct || t->ty == Tclass) |
252 | 608 return dwarfCompositeType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
609 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
610 return NULL; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
611 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
612 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
613 static LLGlobalVariable* dwarfTypeDescription(Type* type, LLGlobalVariable* cu, const char* c_name) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
614 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
615 Type* t = type->toBasetype(); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
616 if (t->ty == Tclass) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
617 return dwarfTypeDescription_impl(type->pointerTo(), cu, c_name); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
618 else |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
619 return dwarfTypeDescription_impl(type, cu, c_name); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
620 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
621 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
622 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
623 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
624 void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
625 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
626 Logger::println("D to dwarf local variable"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
627 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
628 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
629 // get compile units |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
630 LLGlobalVariable* thisCU = DtoDwarfCompileUnit(gIR->dmodule); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
631 LLGlobalVariable* varCU = thisCU; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
632 if (vd->getModule() != gIR->dmodule) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
633 varCU = DtoDwarfCompileUnit(vd->getModule()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
634 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
635 // get type description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
636 Type* t = vd->type->toBasetype(); |
252 | 637 LLGlobalVariable* TD = dwarfTypeDescription(vd->type, thisCU, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
638 if (TD == NULL) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
639 return; // unsupported |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
640 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
641 // get variable description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
642 LLGlobalVariable* VD; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
643 VD = dwarfVariable(vd, TD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
644 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
645 // declare |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
646 dwarfDeclare(ll, VD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
647 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
648 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
649 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
650 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
651 LLGlobalVariable* DtoDwarfCompileUnit(Module* m) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
652 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
653 Logger::println("D to dwarf compile_unit"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
654 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
655 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
656 // we might be generating for an import |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
657 if (!m->ir.irModule) |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
658 m->ir.irModule = new IrModule(m, m->srcfile->toChars()); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
659 else if (m->ir.irModule->dwarfCompileUnit) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
660 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
661 if (m->ir.irModule->dwarfCompileUnit->getParent() == gIR->module) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
662 return m->ir.irModule->dwarfCompileUnit; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
663 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
664 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
665 LLGlobalVariable* gv = dwarfCompileUnit(m); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
666 m->ir.irModule->dwarfCompileUnit = gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
667 return gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
668 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
669 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
670 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
671 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
672 LLGlobalVariable* DtoDwarfSubProgram(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
673 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
674 Logger::println("D to dwarf subprogram"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
675 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
676 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
677 // FIXME: duplicates ? |
686
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
678 return dwarfSubProgram( |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
679 DtoDwarfCompileUnit(gIR->dmodule), |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
680 DtoDwarfCompileUnit(fd->getModule()), |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
681 fd->toPrettyChars(), fd->mangle(), |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
682 fd->loc.linnum, |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
683 fd->protection == PROTprivate); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
684 } |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
685 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
686 ////////////////////////////////////////////////////////////////////////////////////////////////// |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
687 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
688 LLGlobalVariable* DtoDwarfSubProgramInternal(const char* prettyname, const char* mangledname) |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
689 { |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
690 Logger::println("D to dwarf subprogram"); |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
691 LOG_SCOPE; |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
692 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
693 // FIXME: duplicates ? |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
694 return dwarfSubProgram( |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
695 DtoDwarfCompileUnit(gIR->dmodule), |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
696 DtoDwarfCompileUnit(gIR->dmodule), |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
697 prettyname, mangledname, |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
698 0, |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
699 true); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
700 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
701 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
702 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
703 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
704 LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
705 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
706 Logger::println("D to dwarf global_variable"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
707 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
708 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
709 // FIXME: duplicates ? |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
710 return dwarfGlobalVariable(ll, vd); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
711 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
712 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
713 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
714 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
715 void DtoDwarfFuncStart(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
716 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
717 Logger::println("D to dwarf funcstart"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
718 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
719 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
720 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
721 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(fd->ir.irFunc->dwarfSubProg)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
722 } |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
723 |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
724 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
725 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
726 void DtoDwarfFuncEnd(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
727 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
728 Logger::println("D to dwarf funcend"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
729 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
730 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
731 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
732 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), DBG_CAST(fd->ir.irFunc->dwarfSubProg)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
733 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
734 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
735 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
736 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
737 void DtoDwarfStopPoint(unsigned ln) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
738 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
739 Logger::println("D to dwarf stoppoint at line %u", ln); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
740 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
741 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
742 LLSmallVector<LLValue*,3> args(3); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
743 args[0] = DtoConstUint(ln); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
744 args[1] = DtoConstUint(0); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
745 FuncDeclaration* fd = gIR->func()->decl; |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
746 args[2] = DBG_CAST(DtoDwarfCompileUnit(fd->getModule())); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
747 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.stoppoint"), args.begin(), args.end()); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
748 } |