Mercurial > projects > ldc
annotate gen/todebug.cpp @ 250:fc9c1a0eabbd trunk
[svn r267] Fixed debug info for global variables.
Cleaned up the debug info code in general.
author | lindquist |
---|---|
date | Wed, 11 Jun 2008 20:53:26 +0200 |
parents | 56199753e637 |
children | e3355ce5444b |
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" |
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
|
4 |
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 #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
|
6 #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
|
7 #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
|
8 |
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 #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
|
10 #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
|
11 #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
|
12 #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
|
13 |
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
|
14 #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
|
15 |
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
|
16 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
|
17 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
18 #define DBG_NULL ( LLConstant::getNullValue(DBG_TYPE) ) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
19 #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
20 #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
|
21 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
22 #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
|
23 |
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 * Emits a global variable, LLVM Dwarf style. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
28 * @param type Type of variable. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
29 * @param values Initializers. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
30 * @param name Name. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
31 * @return The global variable. |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
32 */ |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
33 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
|
34 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
35 LLConstant* c = llvm::ConstantStruct::get(type, values); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
36 LLGlobalValue::LinkageTypes linkage = linkonce ? LLGlobalValue::LinkOnceLinkage : LLGlobalValue::InternalLinkage; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
37 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, linkage, c, name, gIR->module); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
38 gv->setSection("llvm.metadata"); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
39 return gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
40 } |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
41 |
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
|
42 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
43 |
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
|
44 static llvm::GlobalVariable* dbg_compile_units = 0; |
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
|
45 static llvm::GlobalVariable* dbg_global_variables = 0; |
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
|
46 static llvm::GlobalVariable* dbg_subprograms = 0; |
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
|
47 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
48 /** |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
49 * 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
|
50 */ |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
51 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
|
52 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
53 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
|
54 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
|
55 |
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
|
56 if (!gIR->module->getNamedGlobal("llvm.dbg.compile_units")) { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
57 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
58 vals[1] = DtoConstUint(DW_TAG_compile_unit); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
59 dbg_compile_units = emitDwarfGlobal(anchorTy, vals, "llvm.dbg.compile_units", 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
|
60 } |
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
|
61 if (!gIR->module->getNamedGlobal("llvm.dbg.global_variables")) { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
62 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
63 vals[1] = DtoConstUint(DW_TAG_variable); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
64 dbg_global_variables = emitDwarfGlobal(anchorTy, vals, "llvm.dbg.global_variables", 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
|
65 } |
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 if (!gIR->module->getNamedGlobal("llvm.dbg.subprograms")) { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
67 vals[0] = DtoConstUint(llvm::LLVMDebugVersion); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
68 vals[1] = DtoConstUint(DW_TAG_subprogram); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
69 dbg_subprograms = 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
|
70 } |
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
|
71 } |
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
|
72 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
73 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
|
74 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
75 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
|
76 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
|
77 { |
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 case DW_TAG_compile_unit: |
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 return dbg_compile_units; |
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
|
80 case DW_TAG_variable: |
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
|
81 return dbg_global_variables; |
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
|
82 case DW_TAG_subprogram: |
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 return dbg_subprograms; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
84 default: |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
85 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
|
86 } |
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 |
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
|
89 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
91 static const llvm::StructType* getDwarfCompileUnitType() { |
96 | 92 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
|
93 } |
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
|
94 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
95 static const llvm::StructType* getDwarfSubProgramType() { |
96 | 96 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
|
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
99 static const llvm::StructType* getDwarfVariableType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
100 return isaStruct(gIR->module->getTypeByName("llvm.dbg.variable.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
101 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
102 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
103 static const llvm::StructType* getDwarfDerivedTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
104 return isaStruct(gIR->module->getTypeByName("llvm.dbg.derivedtype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
105 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
106 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
107 static const llvm::StructType* getDwarfBasicTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
108 return isaStruct(gIR->module->getTypeByName("llvm.dbg.basictype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
109 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
110 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
111 static const llvm::StructType* getDwarfCompositeTypeType() { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
112 return isaStruct(gIR->module->getTypeByName("llvm.dbg.compositetype.type")); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
113 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
114 |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
115 static const llvm::StructType* getDwarfGlobalVariableType() { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
116 return isaStruct(gIR->module->getTypeByName("llvm.dbg.global_variable.type")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
117 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
118 |
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
|
119 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
120 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
121 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
|
122 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
123 std::vector<LLConstant*> vals; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
124 vals.push_back(DBG_TAG(DW_TAG_compile_unit)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
125 vals.push_back(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
|
126 |
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
|
127 vals.push_back(DtoConstUint(DW_LANG_C));// _D)); // doesn't seem to work |
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
|
128 vals.push_back(DtoConstStringPtr(m->srcfile->name->toChars(), "llvm.metadata")); |
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
|
129 std::string srcpath(FileName::path(m->srcfile->name->toChars())); |
140 | 130 if (srcpath.empty()) { |
131 const char* str = get_current_dir_name(); | |
132 assert(str != NULL); | |
133 srcpath = str; | |
134 } | |
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
|
135 vals.push_back(DtoConstStringPtr(srcpath.c_str(), "llvm.metadata")); |
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
|
136 vals.push_back(DtoConstStringPtr("LLVMDC (http://www.dsource.org/projects/llvmdc)", "llvm.metadata")); |
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
|
137 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 } |
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
|
142 |
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
|
143 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
144 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
145 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
|
146 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
147 std::vector<LLConstant*> vals; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
148 vals.push_back(DBG_TAG(DW_TAG_subprogram)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
149 vals.push_back(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
|
150 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
151 vals.push_back(DBG_CAST(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
|
152 vals.push_back(DtoConstStringPtr(fd->toPrettyChars(), "llvm.metadata")); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
153 vals.push_back(vals.back()); |
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
|
154 vals.push_back(DtoConstStringPtr(fd->mangle(), "llvm.metadata")); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
155 vals.push_back(DBG_CAST( DtoDwarfCompileUnit(fd->getModule()) )); |
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
|
156 vals.push_back(DtoConstUint(fd->loc.linnum)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
157 vals.push_back(DBG_NULL); |
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
|
158 vals.push_back(DtoConstBool(fd->protection == PROTprivate)); |
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
|
159 vals.push_back(DtoConstBool(fd->getModule() == gIR->dmodule)); |
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
|
160 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
161 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
|
162 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
163 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
164 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
165 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
166 static LLGlobalVariable* dwarfTypeDescription(Loc loc, 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
|
167 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
168 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
169 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
170 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
|
171 { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
172 Type* t = type->toBasetype(); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
173 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
174 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
|
175 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
176 std::vector<LLConstant*> vals; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
177 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
178 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
179 vals.push_back(DBG_TAG(DW_TAG_base_type)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
180 |
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 // context |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
182 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
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 // name |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
185 vals.push_back(DtoConstStringPtr(type->toChars(), "llvm.metadata")); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
186 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
187 // compile unit where defined |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
188 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
189 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
190 // line number where defined |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
191 vals.push_back(DtoConstInt(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
192 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
193 // size in bits |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
194 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
195 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
196 // alignment in bits |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
197 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
198 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
199 // offset in bits |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
200 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
201 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
202 // FIXME: dont know what this is |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
203 vals.push_back(DtoConstUint(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
204 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
205 // 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
|
206 unsigned id; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
207 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
|
208 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
209 if (type->isunsigned()) |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
210 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
|
211 else |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
212 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
|
213 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
214 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
|
215 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
216 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
|
217 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
218 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
219 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
220 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
|
221 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
222 vals.push_back(DtoConstUint(id)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
223 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
224 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
|
225 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
226 |
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
229 static LLGlobalVariable* dwarfDerivedType(Loc loc, Type* type, llvm::GlobalVariable* compileUnit) |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
230 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
231 const LLType* T = DtoType(type); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
232 Type* t = DtoDType(type); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
233 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
234 // defaults |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
235 LLConstant* name = getNullPtr(getVoidPtrType()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
236 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
237 // find tag |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
238 unsigned tag; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
239 if (t->ty == Tpointer) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
240 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
241 tag = DW_TAG_pointer_type; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
242 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
243 else |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
244 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
245 assert(0 && "unsupported derivedtype for debug info"); |
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 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
248 std::vector<LLConstant*> vals; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
249 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
250 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
251 vals.push_back(DBG_TAG(tag)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
252 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
253 // context |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
254 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
255 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
256 // name |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
257 vals.push_back(name); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
258 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
259 // compile unit where defined |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
260 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
261 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
262 // line number where defined |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
263 vals.push_back(DtoConstInt(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
264 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
265 // size in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
266 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
267 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
268 // alignment in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
269 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
270 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
271 // offset in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
272 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
273 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
274 // FIXME: dont know what this is |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
275 vals.push_back(DtoConstUint(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
276 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
277 // base type |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
278 Type* nt = t->nextOf(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
279 LLGlobalVariable* nTD = dwarfTypeDescription(loc, nt, compileUnit, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
280 if (nt->ty == Tvoid || !nTD) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
281 vals.push_back(DBG_NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
282 else |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
283 vals.push_back(DBG_CAST(nTD)); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
284 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
285 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
|
286 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
287 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
288 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
289 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
290 static LLGlobalVariable* dwarfMemberType(Loc loc, Type* type, llvm::GlobalVariable* compileUnit, const char* c_name, unsigned offset) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
291 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
292 const LLType* T = DtoType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
293 Type* t = DtoDType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
294 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
295 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
296 LLConstant* name; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
297 if (c_name) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
298 name = DtoConstStringPtr(c_name, "llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
299 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
300 name = getNullPtr(getVoidPtrType()); |
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 std::vector<LLConstant*> vals; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
303 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
304 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
305 vals.push_back(DBG_TAG(DW_TAG_member)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
306 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
307 // context |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
308 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
309 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
310 // name |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
311 vals.push_back(name); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
312 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
313 // compile unit where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
314 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
315 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
316 // line number where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
317 vals.push_back(DtoConstInt(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
318 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
319 // size in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
320 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
321 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
322 // alignment in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
323 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
324 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
325 // offset in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
326 vals.push_back(LLConstantInt::get(LLType::Int64Ty, offset*8, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
327 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
328 // FIXME: dont know what this is |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
329 vals.push_back(DtoConstUint(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
330 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
331 // base type |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
332 LLGlobalVariable* nTD = dwarfTypeDescription(loc, t, compileUnit, NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
333 if (t->ty == Tvoid || !nTD) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
334 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
335 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
336 vals.push_back(DBG_CAST(nTD)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
337 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
338 return emitDwarfGlobal(getDwarfDerivedTypeType(), vals, "llvm.dbg.derivedtype"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
339 } |
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
342 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
343 static LLGlobalVariable* dwarfCompositeType(Loc loc, Type* type, llvm::GlobalVariable* compileUnit) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
344 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
345 const LLType* T = DtoType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
346 Type* t = DtoDType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
347 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
348 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
349 LLConstant* name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
350 LLGlobalVariable* members = NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
351 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
352 // prepare tag and members |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
353 unsigned tag; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
354 if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
355 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
356 tag = DW_TAG_structure_type; |
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 LLGlobalVariable* len = dwarfMemberType(loc, Type::tsize_t, compileUnit, "length", 0); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
359 assert(len); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
360 LLGlobalVariable* ptr = dwarfMemberType(loc, t->nextOf()->pointerTo(), compileUnit, "ptr", global.params.is64bit?8:4); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
361 assert(ptr); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
362 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
363 const LLArrayType* at = LLArrayType::get(DBG_TYPE, 2); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
364 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
365 std::vector<LLConstant*> elems; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
366 elems.push_back(DBG_CAST(len)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
367 elems.push_back(DBG_CAST(ptr)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
368 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
369 // elems[0]->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
370 // elems[1]->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
371 // at->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
372 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
373 LLConstant* ca = LLConstantArray::get(at, elems); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
374 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
375 members->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
376 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
377 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
378 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
379 assert(0 && "unsupported compositetype for debug info"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
380 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
381 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
382 std::vector<LLConstant*> vals; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
383 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
384 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
385 vals.push_back(DBG_TAG(tag)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
386 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
387 // context |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
388 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
389 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
390 // name |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
391 vals.push_back(name); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
392 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
393 // compile unit where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
394 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
395 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
396 // line number where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
397 vals.push_back(DtoConstInt(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
398 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
399 // size in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
400 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
401 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
402 // alignment in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
403 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
404 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
405 // offset in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
406 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
407 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
408 // FIXME: dont know what this is |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
409 vals.push_back(DtoConstUint(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
410 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
411 // FIXME: ditto |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
412 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
413 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
414 // members array |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
415 if (members) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
416 vals.push_back(DBG_CAST(members)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
417 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
418 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
419 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
420 return emitDwarfGlobal(getDwarfCompositeTypeType(), vals, "llvm.dbg.compositetype"); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
421 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
422 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
423 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
424 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
425 static LLGlobalVariable* dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
426 { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
427 assert(vd->isDataseg()); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
428 LLGlobalVariable* compileUnit = DtoDwarfCompileUnit(gIR->dmodule); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
429 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
430 std::vector<LLConstant*> vals; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
431 vals.push_back(DBG_TAG(DW_TAG_variable)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
432 vals.push_back(DBG_CAST(getDwarfAnchor(DW_TAG_variable))); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
433 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
434 vals.push_back(DBG_CAST(compileUnit)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
435 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
436 vals.push_back(DtoConstStringPtr(vd->mangle(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
437 vals.push_back(DtoConstStringPtr(vd->toPrettyChars(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
438 vals.push_back(DtoConstStringPtr(vd->toChars(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
439 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
440 vals.push_back(DBG_CAST(DtoDwarfCompileUnit(vd->getModule()))); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
441 vals.push_back(DtoConstUint(vd->loc.linnum)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
442 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
443 LLGlobalVariable* TY = dwarfTypeDescription(vd->loc, vd->type, compileUnit, NULL); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
444 vals.push_back(TY ? DBG_CAST(TY) : DBG_NULL); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
445 vals.push_back(DtoConstBool(vd->protection == PROTprivate)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
446 vals.push_back(DtoConstBool(vd->getModule() == gIR->dmodule)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
447 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
448 vals.push_back(DBG_CAST(ll)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
449 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
450 return emitDwarfGlobal(getDwarfGlobalVariableType(), vals, "llvm.dbg.global_variable"); |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
451 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
452 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
453 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
|
454 { |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
455 assert(!vd->isDataseg() && "static variable"); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
456 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
457 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
|
458 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
|
459 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
|
460 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
461 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
|
462 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
463 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
|
464 // tag |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
465 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
|
466 // context |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
467 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
|
468 // name |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
469 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
|
470 // compile unit where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
471 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
|
472 // line number where defined |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
473 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
|
474 // type descriptor |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
475 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
|
476 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
477 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
|
478 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
479 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
480 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
481 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
482 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
|
483 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
484 LLSmallVector<LLValue*,2> args; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
485 args.push_back(DtoBitCast(var, DBG_TYPE)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
486 args.push_back(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
|
487 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
|
488 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
489 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
490 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
491 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
492 static LLGlobalVariable* dwarfTypeDescription(Loc loc, Type* type, LLGlobalVariable* cu, const char* c_name) |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
493 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
494 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
495 if (t->ty == Tvoid) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
496 return NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
497 else if (t->isintegral() || t->isfloating()) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
498 return dwarfBasicType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
499 else if (t->ty == Tpointer) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
500 return dwarfDerivedType(loc, type, cu); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
501 else if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
502 return dwarfCompositeType(loc, type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
503 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
504 if (global.params.warnings) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
505 warning("%s: unsupported type for debug info: %s", loc.toChars(), type->toChars()); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
506 return NULL; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
507 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
508 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
509 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
510 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
511 void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
512 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
513 // get compile units |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
514 LLGlobalVariable* thisCU = DtoDwarfCompileUnit(gIR->dmodule); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
515 LLGlobalVariable* varCU = thisCU; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
516 if (vd->getModule() != gIR->dmodule) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
517 varCU = DtoDwarfCompileUnit(vd->getModule()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
518 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
519 // get type description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
520 Type* t = vd->type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
521 LLGlobalVariable* TD = dwarfTypeDescription(vd->loc, vd->type, thisCU, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
522 if (TD == NULL) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
523 return; // unsupported |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
524 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
525 // get variable description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
526 LLGlobalVariable* VD; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
527 VD = dwarfVariable(vd, TD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
528 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
529 // declare |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
530 dwarfDeclare(ll, VD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
531 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
532 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
533 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
534 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
535 LLGlobalVariable* DtoDwarfCompileUnit(Module* m) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
536 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
537 // we might be generating for an import |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
538 if (!m->ir.irModule) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
539 m->ir.irModule = new IrModule(m); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
540 else if (m->ir.irModule->dwarfCompileUnit) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
541 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
542 if (m->ir.irModule->dwarfCompileUnit->getParent() == gIR->module) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
543 return m->ir.irModule->dwarfCompileUnit; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
544 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
545 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
546 LLGlobalVariable* gv = dwarfCompileUnit(m); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
547 m->ir.irModule->dwarfCompileUnit = gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
548 return gv; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
549 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
550 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
551 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
552 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
553 LLGlobalVariable* DtoDwarfSubProgram(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
554 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
555 // FIXME: duplicates ? |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
556 return dwarfSubProgram(fd, DtoDwarfCompileUnit(gIR->dmodule)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
557 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
558 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
559 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
560 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
561 LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
562 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
563 // FIXME: duplicates ? |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
564 return dwarfGlobalVariable(ll, vd); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
565 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
566 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
567 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
568 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
569 void DtoDwarfFuncStart(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
570 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
571 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
572 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
|
573 } |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
574 |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
575 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
576 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
577 void DtoDwarfFuncEnd(FuncDeclaration* fd) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
578 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
579 assert(fd->ir.irFunc->dwarfSubProg); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
580 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
|
581 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
582 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
583 ////////////////////////////////////////////////////////////////////////////////////////////////// |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
584 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
585 void DtoDwarfStopPoint(unsigned ln) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
586 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
587 LLSmallVector<LLValue*,3> args; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
588 args.push_back(DtoConstUint(ln)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
589 args.push_back(DtoConstUint(0)); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
590 FuncDeclaration* fd = gIR->func()->decl; |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
591 args.push_back(DBG_CAST(DtoDwarfCompileUnit(fd->getModule()))); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
247
diff
changeset
|
592 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
|
593 } |