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