Mercurial > projects > ldc
annotate gen/todebug.cpp @ 707:1556a9328ba1
Fixed bug with generated functions having wrong calling conventions. Thanks downs.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Wed, 15 Oct 2008 20:22:18 +0200 |
parents | 353d9d184091 |
children | 72ee105be27b |
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 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
138 vals[3] = DtoConstStringPtr(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())); |
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
|
140 if (srcpath.empty()) |
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
|
141 srcpath = llvm::sys::Path::GetCurrentDirectory().toString(); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
142 vals[4] = DtoConstStringPtr(srcpath.c_str(), "llvm.metadata"); |
690 | 143 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
|
144 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 } |
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
|
149 |
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
|
150 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
151 |
702
353d9d184091
changed uint to unsigned int, thanks Elrood
Christian Kamm <kamm incasoftware de>
parents:
690
diff
changeset
|
152 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
|
153 { |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
168 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
|
169 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
170 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
|
171 } |
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 /* |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
174 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
|
175 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
176 std::vector<LLConstant*> vals(11); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
177 vals[0] = DBG_TAG(DW_TAG_subprogram); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
178 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
|
179 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
180 vals[2] = DBG_CAST(compileUnit); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
181 vals[3] = DtoConstStringPtr(fd->toPrettyChars(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
182 vals[4] = vals[3]; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
183 vals[5] = DtoConstStringPtr(fd->mangle(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
184 vals[6] = DBG_CAST( DtoDwarfCompileUnit(fd->getModule()) ); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
185 vals[7] = DtoConstUint(fd->loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
186 vals[8] = DBG_NULL; |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
187 vals[9] = DtoConstBool(fd->protection == PROTprivate); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
188 vals[10] = DtoConstBool(fd->getModule() == gIR->dmodule); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
189 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
190 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
|
191 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
192 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
|
193 }*/ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
194 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
195 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
196 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
197 static LLGlobalVariable* dwarfTypeDescription_impl(Type* type, LLGlobalVariable* cu, const char* c_name); |
252 | 198 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
|
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
202 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
|
203 { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
204 Type* t = type->toBasetype(); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
205 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
206 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
|
207 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
208 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
209 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
210 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
211 vals[0] = DBG_TAG(DW_TAG_base_type); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
212 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
213 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
214 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
215 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
216 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
217 vals[2] = DtoConstStringPtr(type->toChars(), "llvm.metadata"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
218 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
219 // compile unit where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
220 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
221 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
222 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
223 vals[4] = DtoConstInt(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
224 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
225 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
226 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
227 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
228 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
229 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
230 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
231 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
232 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
233 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
234 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
235 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
236 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
237 // 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
|
238 unsigned id; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
239 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
|
240 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
241 if (type->isunsigned()) |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
242 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
|
243 else |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
244 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
|
245 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
246 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
|
247 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
248 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
|
249 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
250 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
251 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
252 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
|
253 } |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
254 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
|
255 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
256 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
|
257 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
258 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
259 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
260 |
252 | 261 static LLGlobalVariable* dwarfDerivedType(Type* type, llvm::GlobalVariable* compileUnit) |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
262 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
263 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
|
264 Type* t = type->toBasetype(); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
265 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
266 // defaults |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
267 LLConstant* name = getNullPtr(getVoidPtrType()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
268 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
269 // find tag |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
270 unsigned tag; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
271 if (t->ty == Tpointer) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
272 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
273 tag = DW_TAG_pointer_type; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
274 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
275 else |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
276 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
277 assert(0 && "unsupported derivedtype for debug info"); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
278 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
279 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
280 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
281 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
282 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
283 vals[0] = DBG_TAG(tag); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
284 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
285 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
286 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
287 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
288 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
289 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
290 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
291 // compile unit where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
292 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
293 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
294 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
295 vals[4] = DtoConstInt(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
296 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
297 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
298 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
299 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
300 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
301 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
302 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
303 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
304 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
305 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
306 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
307 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
308 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
309 // base type |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
310 Type* nt = t->nextOf(); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
311 LLGlobalVariable* nTD = dwarfTypeDescription_impl(nt, compileUnit, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
312 if (nt->ty == Tvoid || !nTD) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
313 vals[9] = DBG_NULL; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
314 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
315 vals[9] = DBG_CAST(nTD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
316 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
317 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
|
318 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
319 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
320 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
321 |
252 | 322 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
|
323 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
324 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
|
325 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
326 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
327 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
328 LLConstant* name; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
329 if (c_name) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
330 name = DtoConstStringPtr(c_name, "llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
331 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
332 name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
333 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
334 std::vector<LLConstant*> vals(10); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
335 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
336 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
337 vals[0] = DBG_TAG(DW_TAG_member); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
338 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
339 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
340 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
341 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
342 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
343 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
344 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
345 // compile unit where defined |
252 | 346 if (definedCU) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
347 vals[3] = DBG_CAST(definedCU); |
252 | 348 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
349 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
350 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
351 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
352 vals[4] = DtoConstInt(linnum); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
353 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
354 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
355 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
356 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
357 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
358 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
359 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
360 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
361 vals[7] = LLConstantInt::get(LLType::Int64Ty, offset*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
362 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
363 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
364 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
365 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
366 // base type |
252 | 367 LLGlobalVariable* nTD = dwarfTypeDescription(t, compileUnit, NULL); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
368 if (t->ty == Tvoid || !nTD) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
369 vals[9] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
370 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
371 vals[9] = DBG_CAST(nTD); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
372 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
373 return emitDwarfGlobal(getDwarfDerivedTypeType(), vals, "llvm.dbg.derivedtype"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
374 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
375 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
376 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
377 |
252 | 378 static LLGlobalVariable* dwarfCompositeType(Type* type, llvm::GlobalVariable* compileUnit) |
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 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
|
381 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
382 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
383 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
384 LLConstant* name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
385 LLGlobalVariable* members = NULL; |
252 | 386 unsigned linnum = 0; |
387 LLGlobalVariable* definedCU = NULL; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
388 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
389 // prepare tag and members |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
390 unsigned tag; |
252 | 391 |
392 // declare final global variable | |
393 LLGlobalVariable* gv = NULL; | |
394 | |
395 // dynamic array | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
396 if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
397 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
398 tag = DW_TAG_structure_type; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
399 |
252 | 400 LLGlobalVariable* len = dwarfMemberType(0, Type::tsize_t, compileUnit, NULL, "length", 0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
401 assert(len); |
252 | 402 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
|
403 assert(ptr); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
404 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
405 const LLArrayType* at = LLArrayType::get(DBG_TYPE, 2); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
406 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
407 std::vector<LLConstant*> elems(2); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
408 elems[0] = DBG_CAST(len); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
409 elems[1] = DBG_CAST(ptr); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
410 |
252 | 411 LLConstant* ca = LLConstantArray::get(at, elems); |
412 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); | |
413 members->setSection("llvm.metadata"); | |
414 | |
415 name = DtoConstStringPtr(t->toChars(), "llvm.metadata"); | |
416 } | |
417 | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
418 // struct/class |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
419 else if (t->ty == Tstruct || t->ty == Tclass) |
252 | 420 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
421 AggregateDeclaration* sd; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
422 if (t->ty == Tstruct) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
423 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
424 TypeStruct* ts = (TypeStruct*)t; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
425 sd = ts->sym; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
426 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
427 else |
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 TypeClass* tc = (TypeClass*)t; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
430 sd = tc->sym; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
431 } |
252 | 432 assert(sd); |
433 | |
434 IrStruct* ir = sd->ir.irStruct; | |
435 assert(ir); | |
436 if (ir->dwarfComposite) | |
437 return ir->dwarfComposite; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
438 |
252 | 439 // set to handle recursive types properly |
440 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype"); | |
441 ir->dwarfComposite = gv; | |
442 | |
443 tag = DW_TAG_structure_type; | |
444 | |
445 name = DtoConstStringPtr(sd->toChars(), "llvm.metadata"); | |
446 linnum = sd->loc.linnum; | |
447 definedCU = DtoDwarfCompileUnit(sd->getModule()); | |
448 | |
449 std::vector<LLConstant*> elems; | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
450 elems.reserve(ir->offsets.size()); |
252 | 451 for (IrStruct::OffsetMap::iterator i=ir->offsets.begin(); i!=ir->offsets.end(); ++i) |
452 { | |
453 unsigned offset = i->first; | |
454 IrStruct::Offset& o = i->second; | |
455 | |
456 LLGlobalVariable* ptr = dwarfMemberType(o.var->loc.linnum, o.var->type, compileUnit, definedCU, o.var->toChars(), offset); | |
457 elems.push_back(DBG_CAST(ptr)); | |
458 } | |
459 | |
460 const LLArrayType* at = LLArrayType::get(DBG_TYPE, elems.size()); | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
461 LLConstant* ca = LLConstantArray::get(at, elems); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
462 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
463 members->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
464 } |
252 | 465 |
466 // unsupported composite type | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
467 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
468 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
469 assert(0 && "unsupported compositetype for debug info"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
470 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
471 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
472 std::vector<LLConstant*> vals(11); |
246
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 // tag |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
475 vals[0] = DBG_TAG(tag); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
476 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
477 // context |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
478 vals[1] = DBG_CAST(compileUnit); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
479 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
480 // name |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
481 vals[2] = name; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
482 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
483 // compile unit where defined |
252 | 484 if (definedCU) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
485 vals[3] = DBG_CAST(definedCU); |
252 | 486 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
487 vals[3] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
488 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
489 // line number where defined |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
490 vals[4] = DtoConstInt(linnum); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
491 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
492 // size in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
493 vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
494 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
495 // alignment in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
496 vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
497 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
498 // offset in bits |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
499 vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
500 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
501 // FIXME: dont know what this is |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
502 vals[8] = DtoConstUint(0); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
503 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
504 // FIXME: ditto |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
505 vals[9] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
506 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
507 // members array |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
508 if (members) |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
509 vals[10] = DBG_CAST(members); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
510 else |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
511 vals[10] = DBG_NULL; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
512 |
252 | 513 // set initializer |
514 if (!gv) | |
515 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype"); | |
516 LLConstant* initia = LLConstantStruct::get(getDwarfCompositeTypeType(), vals); | |
517 gv->setInitializer(initia); | |
518 | |
519 return gv; | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
520 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
521 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
522 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
523 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
524 static LLGlobalVariable* dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
525 { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
526 assert(vd->isDataseg()); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
527 LLGlobalVariable* compileUnit = DtoDwarfCompileUnit(gIR->dmodule); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
528 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
529 std::vector<LLConstant*> vals(12); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
530 vals[0] = DBG_TAG(DW_TAG_variable); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
531 vals[1] = DBG_CAST(getDwarfAnchor(DW_TAG_variable)); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
532 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
533 vals[2] = DBG_CAST(compileUnit); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
534 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
535 vals[3] = DtoConstStringPtr(vd->mangle(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
536 vals[4] = DtoConstStringPtr(vd->toPrettyChars(), "llvm.metadata"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
537 vals[5] = DtoConstStringPtr(vd->toChars(), "llvm.metadata"); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
538 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
539 vals[6] = DBG_CAST(DtoDwarfCompileUnit(vd->getModule())); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
540 vals[7] = DtoConstUint(vd->loc.linnum); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
541 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
542 LLGlobalVariable* TY = dwarfTypeDescription_impl(vd->type, compileUnit, NULL); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
543 vals[8] = TY ? DBG_CAST(TY) : DBG_NULL; |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
544 vals[9] = DtoConstBool(vd->protection == PROTprivate); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
545 vals[10] = DtoConstBool(vd->getModule() == gIR->dmodule); |
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 vals[11] = DBG_CAST(ll); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
548 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
549 return emitDwarfGlobal(getDwarfGlobalVariableType(), vals, "llvm.dbg.global_variable"); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
550 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
551 |
252 | 552 ////////////////////////////////////////////////////////////////////////////////////////////////// |
553 | |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
554 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
|
555 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
556 assert(!vd->isDataseg() && "static variable"); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
557 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
562 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
|
563 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
564 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
|
565 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
566 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
|
567 // context |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
568 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
|
569 // name |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
570 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
|
571 // compile unit where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
572 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
|
573 // line number where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
574 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
|
575 // type descriptor |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
576 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
|
577 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
578 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
|
579 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
580 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
581 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
582 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
583 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
|
584 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
585 LLSmallVector<LLValue*,2> args(2); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
586 args[0] = DtoBitCast(var, DBG_TYPE); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
587 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
|
588 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
|
589 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
590 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
591 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
592 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
593 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
|
594 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
595 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
596 if (t->ty == Tvoid) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
597 return NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
598 else if (t->isintegral() || t->isfloating()) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
599 return dwarfBasicType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
600 else if (t->ty == Tpointer) |
252 | 601 return dwarfDerivedType(type, cu); |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
602 else if (t->ty == Tarray || t->ty == Tstruct || t->ty == Tclass) |
252 | 603 return dwarfCompositeType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
604 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
605 return NULL; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
606 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
607 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
608 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
|
609 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
610 Type* t = type->toBasetype(); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
611 if (t->ty == Tclass) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
612 return dwarfTypeDescription_impl(type->pointerTo(), cu, c_name); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
613 else |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
614 return dwarfTypeDescription_impl(type, cu, c_name); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
615 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
616 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
617 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
618 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
619 void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
620 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
621 Logger::println("D to dwarf local variable"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
622 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
623 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
624 // get compile units |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
625 LLGlobalVariable* thisCU = DtoDwarfCompileUnit(gIR->dmodule); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
626 LLGlobalVariable* varCU = thisCU; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
627 if (vd->getModule() != gIR->dmodule) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
628 varCU = DtoDwarfCompileUnit(vd->getModule()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
629 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
630 // get type description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
631 Type* t = vd->type->toBasetype(); |
252 | 632 LLGlobalVariable* TD = dwarfTypeDescription(vd->type, thisCU, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
633 if (TD == NULL) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
634 return; // unsupported |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
635 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
636 // get variable description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
637 LLGlobalVariable* VD; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
638 VD = dwarfVariable(vd, TD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
639 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
640 // declare |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
641 dwarfDeclare(ll, VD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
642 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
643 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
644 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
645 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
646 LLGlobalVariable* DtoDwarfCompileUnit(Module* m) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
647 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
648 Logger::println("D to dwarf compile_unit"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
649 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
650 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
651 // we might be generating for an import |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
652 if (!m->ir.irModule) |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
653 m->ir.irModule = new IrModule(m, m->srcfile->toChars()); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
654 else if (m->ir.irModule->dwarfCompileUnit) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
655 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
656 if (m->ir.irModule->dwarfCompileUnit->getParent() == gIR->module) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
657 return m->ir.irModule->dwarfCompileUnit; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
658 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
659 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
660 LLGlobalVariable* gv = dwarfCompileUnit(m); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
661 m->ir.irModule->dwarfCompileUnit = gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
662 return gv; |
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
666 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
667 LLGlobalVariable* DtoDwarfSubProgram(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
668 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
669 Logger::println("D to dwarf subprogram"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
670 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
671 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
672 // 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 } |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
680 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
681 ////////////////////////////////////////////////////////////////////////////////////////////////// |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
682 |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
683 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
|
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 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
|
686 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
|
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 // 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 0, |
363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
694 true); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
695 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
696 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
697 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
698 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
699 LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
700 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
701 Logger::println("D to dwarf global_variable"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
702 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
703 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
704 // FIXME: duplicates ? |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
705 return dwarfGlobalVariable(ll, vd); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
706 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
707 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
708 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
709 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
710 void DtoDwarfFuncStart(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
711 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
712 Logger::println("D to dwarf funcstart"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
713 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
714 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
715 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
716 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
|
717 } |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
718 |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
719 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
720 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
721 void DtoDwarfFuncEnd(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
722 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
723 Logger::println("D to dwarf funcend"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
724 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
725 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
726 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
727 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
|
728 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
729 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
730 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
731 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
732 void DtoDwarfStopPoint(unsigned ln) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
733 { |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
734 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
|
735 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
736 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
737 LLSmallVector<LLValue*,3> args(3); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
738 args[0] = DtoConstUint(ln); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
739 args[1] = DtoConstUint(0); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
740 FuncDeclaration* fd = gIR->func()->decl; |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
252
diff
changeset
|
741 args[2] = DBG_CAST(DtoDwarfCompileUnit(fd->getModule())); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
742 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
|
743 } |