Mercurial > projects > ldc
annotate gen/todebug.cpp @ 247:56199753e637 trunk
[svn r264] Fixed debug info for global variables.
author | lindquist |
---|---|
date | Mon, 09 Jun 2008 17:49:30 +0200 |
parents | b604c56945b0 |
children | fc9c1a0eabbd |
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 |
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
23 |
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
|
24 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
|
25 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
|
26 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
|
27 |
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
|
28 const llvm::StructType* GetDwarfAnchorType() |
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
|
29 { |
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
|
30 /* |
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
|
31 %llvm.dbg.anchor.type = type { |
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
|
32 uint, ;; Tag = 0 + LLVMDebugVersion |
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
|
33 uint ;; Tag of descriptors grouped by the anchor |
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
|
34 } |
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
|
35 */ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
36 |
96 | 37 const llvm::StructType* t = isaStruct(gIR->module->getTypeByName("llvm.dbg.anchor.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
|
38 |
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
|
39 /* |
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
|
40 %llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { uint 0, uint 17 } ;; 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
|
41 %llvm.dbg.global_variables = linkonce constant %llvm.dbg.anchor.type { uint 0, uint 52 } ;; 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
|
42 %llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { uint 0, uint 46 } ;; 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
|
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 if (!gIR->module->getNamedGlobal("llvm.dbg.compile_units")) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
45 std::vector<LLConstant*> vals; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
46 vals.push_back(DtoConstUint(llvm::LLVMDebugVersion)); |
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
|
47 vals.push_back(DtoConstUint(DW_TAG_compile_unit)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
48 LLConstant* i = llvm::ConstantStruct::get(t, vals); |
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
|
49 dbg_compile_units = new llvm::GlobalVariable(t,true,llvm::GlobalValue::LinkOnceLinkage,i,"llvm.dbg.compile_units",gIR->module); |
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
|
50 dbg_compile_units->setSection("llvm.metadata"); |
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
|
51 } |
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 if (!gIR->module->getNamedGlobal("llvm.dbg.global_variables")) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
53 std::vector<LLConstant*> vals; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
54 vals.push_back(DtoConstUint(llvm::LLVMDebugVersion)); |
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 vals.push_back(DtoConstUint(DW_TAG_variable)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
56 LLConstant* i = llvm::ConstantStruct::get(t, vals); |
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 dbg_global_variables = new llvm::GlobalVariable(t,true,llvm::GlobalValue::LinkOnceLinkage,i,"llvm.dbg.global_variables",gIR->module); |
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 dbg_global_variables->setSection("llvm.metadata"); |
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
|
59 } |
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 if (!gIR->module->getNamedGlobal("llvm.dbg.subprograms")) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
61 std::vector<LLConstant*> vals; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
62 vals.push_back(DtoConstUint(llvm::LLVMDebugVersion)); |
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 vals.push_back(DtoConstUint(DW_TAG_subprogram)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
64 LLConstant* i = llvm::ConstantStruct::get(t, vals); |
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 dbg_subprograms = new llvm::GlobalVariable(t,true,llvm::GlobalValue::LinkOnceLinkage,i,"llvm.dbg.subprograms",gIR->module); |
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 dbg_subprograms->setSection("llvm.metadata"); |
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
|
67 } |
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
|
68 |
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
|
69 return t; |
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 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
72 LLConstant* GetDwarfAnchor(llvm::dwarf::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
|
73 { |
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 GetDwarfAnchorType(); |
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
|
75 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
|
76 { |
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 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 return dbg_subprograms; |
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 } |
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
|
84 assert(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
|
85 return 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
|
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
90 static const llvm::StructType* getDwarfCompileUnitType() { |
96 | 91 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
|
92 } |
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
94 static const llvm::StructType* getDwarfSubProgramType() { |
96 | 95 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
|
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 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
98 static const llvm::StructType* getDwarfVariableType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
99 return isaStruct(gIR->module->getTypeByName("llvm.dbg.variable.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
100 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
101 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
102 static const llvm::StructType* getDwarfDerivedTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
103 return isaStruct(gIR->module->getTypeByName("llvm.dbg.derivedtype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
104 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
105 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
106 static const llvm::StructType* getDwarfBasicTypeType() { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
107 return isaStruct(gIR->module->getTypeByName("llvm.dbg.basictype.type")); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
108 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
109 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
110 static const llvm::StructType* getDwarfCompositeTypeType() { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
111 return isaStruct(gIR->module->getTypeByName("llvm.dbg.compositetype.type")); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
112 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
113 |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
114 static const llvm::StructType* getDwarfGlobalVariableType() { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
115 return isaStruct(gIR->module->getTypeByName("llvm.dbg.global_variable.type")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
116 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
117 |
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
|
118 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
120 LLGlobalVariable* DtoDwarfCompileUnit(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
|
121 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
122 if (!m->ir.irModule) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
123 m->ir.irModule = new IrModule(m); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
124 else if (m->ir.irModule->dwarfCompileUnit) |
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
|
125 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
126 if (m->ir.irModule->dwarfCompileUnit->getParent() == gIR->module) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
127 return m->ir.irModule->dwarfCompileUnit; |
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
|
128 } |
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 |
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
|
130 // create a valid compile unit constant for the current module |
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
|
131 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
132 LLConstant* c = 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
|
133 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
134 std::vector<LLConstant*> vals; |
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(llvm::ConstantExpr::getAdd( |
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 DtoConstUint(DW_TAG_compile_unit), |
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 DtoConstUint(llvm::LLVMDebugVersion))); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
138 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
|
139 |
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
|
140 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
|
141 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
|
142 std::string srcpath(FileName::path(m->srcfile->name->toChars())); |
140 | 143 if (srcpath.empty()) { |
144 const char* str = get_current_dir_name(); | |
145 assert(str != NULL); | |
146 srcpath = str; | |
147 } | |
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
|
148 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
|
149 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
|
150 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
151 c = llvm::ConstantStruct::get(getDwarfCompileUnitType(), vals); |
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
|
152 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
153 llvm::GlobalVariable* gv = new llvm::GlobalVariable(c->getType(), true, llvm::GlobalValue::InternalLinkage, c, "llvm.dbg.compile_unit", gIR->module); |
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 gv->setSection("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
|
155 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
156 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
|
157 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
|
158 } |
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 |
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
161 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
162 LLGlobalVariable* DtoDwarfSubProgram(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
|
163 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
164 std::vector<LLConstant*> vals; |
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
|
165 vals.push_back(llvm::ConstantExpr::getAdd( |
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
|
166 DtoConstUint(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
|
167 DtoConstUint(llvm::LLVMDebugVersion))); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
168 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
|
169 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 vals.push_back(DtoConstStringPtr(fd->mangle(), "llvm.metadata")); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
174 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
|
175 vals.push_back(DtoConstUint(fd->loc.linnum)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
176 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
|
177 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
|
178 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
|
179 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
180 LLConstant* c = llvm::ConstantStruct::get(getDwarfSubProgramType(), vals); |
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
|
181 llvm::GlobalVariable* gv = new llvm::GlobalVariable(c->getType(), true, llvm::GlobalValue::InternalLinkage, c, "llvm.dbg.subprogram", gIR->module); |
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
|
182 gv->setSection("llvm.metadata"); |
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
|
183 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
|
184 } |
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
|
185 |
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
|
186 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
187 |
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
|
188 void DtoDwarfFuncStart(FuncDeclaration* fd) |
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
|
189 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
190 assert(fd->ir.irFunc->dwarfSubProg); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
191 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(fd->ir.irFunc->dwarfSubProg)); |
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
|
192 } |
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
|
193 |
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
|
194 void DtoDwarfFuncEnd(FuncDeclaration* fd) |
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
|
195 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
156
diff
changeset
|
196 assert(fd->ir.irFunc->dwarfSubProg); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
197 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), DBG_CAST(fd->ir.irFunc->dwarfSubProg)); |
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
|
198 } |
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
|
199 |
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
|
200 ////////////////////////////////////////////////////////////////////////////////////////////////// |
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
|
201 |
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
|
202 void DtoDwarfStopPoint(unsigned ln) |
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
|
203 { |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
204 LLSmallVector<LLValue*,3> args; |
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
|
205 args.push_back(DtoConstUint(ln)); |
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
|
206 args.push_back(DtoConstUint(0)); |
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
|
207 FuncDeclaration* fd = gIR->func()->decl; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
208 args.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
|
209 gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.stoppoint"), args.begin(), args.end()); |
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
|
210 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
211 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
212 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
213 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
214 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
|
215 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
216 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
217 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
218 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
|
219 { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
220 Type* t = type->toBasetype(); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
221 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
222 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
|
223 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
224 std::vector<LLConstant*> vals; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
225 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
226 // tag |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
227 vals.push_back(llvm::ConstantExpr::getAdd( |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
228 DtoConstUint(DW_TAG_base_type), |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
229 DtoConstUint(llvm::LLVMDebugVersion))); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
230 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
231 // context |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
232 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
233 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
234 // name |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
235 vals.push_back(DtoConstStringPtr(type->toChars(), "llvm.metadata")); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
236 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
237 // compile unit where defined |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
238 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
239 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
240 // 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
|
241 vals.push_back(DtoConstInt(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
242 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
243 // 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
|
244 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
245 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
246 // 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
|
247 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
248 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
249 // 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
|
250 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
251 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
252 // 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
|
253 vals.push_back(DtoConstUint(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
254 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
255 // 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
|
256 unsigned id; |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
257 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
|
258 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
259 if (type->isunsigned()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
260 id = llvm::dwarf::DW_ATE_unsigned; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
261 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
262 id = llvm::dwarf::DW_ATE_signed; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
263 } |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
264 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
|
265 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
266 id = llvm::dwarf::DW_ATE_float; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
267 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
268 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
269 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
270 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
|
271 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
272 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
|
273 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
274 LLConstant* c = llvm::ConstantStruct::get(getDwarfBasicTypeType(), vals); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
275 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, LLGlobalValue::InternalLinkage, c, "llvm.dbg.basictype", gIR->module); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
276 gv->setSection("llvm.metadata"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
277 return gv; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
278 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
279 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
280 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
281 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
282 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
|
283 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
284 const LLType* T = DtoType(type); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
285 Type* t = DtoDType(type); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
286 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
287 // defaults |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
288 LLConstant* name = getNullPtr(getVoidPtrType()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
289 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
290 // find tag |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
291 unsigned tag; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
292 if (t->ty == Tpointer) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
293 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
294 tag = llvm::dwarf::DW_TAG_pointer_type; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
295 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
296 else |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
297 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
298 assert(0 && "unsupported derivedtype for debug info"); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
299 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
300 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
301 std::vector<LLConstant*> vals; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
302 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
303 // tag |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
304 vals.push_back(llvm::ConstantExpr::getAdd( |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
305 DtoConstUint(tag), |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
306 DtoConstUint(llvm::LLVMDebugVersion))); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
307 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
308 // context |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
309 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
310 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
311 // name |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
312 vals.push_back(name); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
313 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
314 // compile unit where defined |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
315 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
316 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
317 // line number where defined |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
318 vals.push_back(DtoConstInt(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
319 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
320 // size in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
321 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
322 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
323 // alignment in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
324 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
325 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
326 // offset in bits |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
327 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
328 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
329 // FIXME: dont know what this is |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
330 vals.push_back(DtoConstUint(0)); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
331 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
332 // base type |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
333 Type* nt = t->nextOf(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
334 LLGlobalVariable* nTD = dwarfTypeDescription(loc, nt, compileUnit, NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
335 if (nt->ty == Tvoid || !nTD) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
336 vals.push_back(DBG_NULL); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
337 else |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
338 vals.push_back(DBG_CAST(nTD)); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
339 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
340 LLConstant* c = llvm::ConstantStruct::get(getDwarfDerivedTypeType(), vals); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
341 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, LLGlobalValue::InternalLinkage, c, "llvm.dbg.derivedtype", gIR->module); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
342 gv->setSection("llvm.metadata"); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
343 return gv; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
344 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
345 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
346 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
347 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
348 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
|
349 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
350 const LLType* T = DtoType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
351 Type* t = DtoDType(type); |
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 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
354 LLConstant* name; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
355 if (c_name) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
356 name = DtoConstStringPtr(c_name, "llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
357 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
358 name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
359 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
360 std::vector<LLConstant*> vals; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
361 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
362 // tag |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
363 vals.push_back(llvm::ConstantExpr::getAdd( |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
364 DtoConstUint(llvm::dwarf::DW_TAG_member), |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
365 DtoConstUint(llvm::LLVMDebugVersion))); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
366 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
367 // context |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
368 vals.push_back(DBG_CAST(compileUnit)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
369 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
370 // name |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
371 vals.push_back(name); |
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 // compile unit where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
374 vals.push_back(DBG_NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
375 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
376 // line number where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
377 vals.push_back(DtoConstInt(0)); |
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 // size in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
380 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
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 // alignment in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
383 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
384 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
385 // offset in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
386 vals.push_back(LLConstantInt::get(LLType::Int64Ty, offset*8, false)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
387 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
388 // FIXME: dont know what this is |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
389 vals.push_back(DtoConstUint(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
390 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
391 // base type |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
392 LLGlobalVariable* nTD = dwarfTypeDescription(loc, t, compileUnit, NULL); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
393 if (t->ty == Tvoid || !nTD) |
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 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
396 vals.push_back(DBG_CAST(nTD)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
397 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
398 LLConstant* c = llvm::ConstantStruct::get(getDwarfDerivedTypeType(), vals); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
399 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, LLGlobalValue::InternalLinkage, c, "llvm.dbg.derivedtype", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
400 gv->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
401 return gv; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
402 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
403 |
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 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
406 static LLGlobalVariable* dwarfCompositeType(Loc loc, Type* type, llvm::GlobalVariable* compileUnit) |
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 const LLType* T = DtoType(type); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
409 Type* t = DtoDType(type); |
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 // defaults |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
412 LLConstant* name = getNullPtr(getVoidPtrType()); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
413 LLGlobalVariable* members = NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
414 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
415 // find tag |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
416 unsigned tag; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
417 if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
418 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
419 tag = llvm::dwarf::DW_TAG_structure_type; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
420 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
421 LLGlobalVariable* len = dwarfMemberType(loc, Type::tsize_t, compileUnit, "length", 0); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
422 assert(len); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
423 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
|
424 assert(ptr); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
425 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
426 const LLArrayType* at = LLArrayType::get(DBG_TYPE, 2); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
427 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
428 std::vector<LLConstant*> elems; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
429 elems.push_back(DBG_CAST(len)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
430 elems.push_back(DBG_CAST(ptr)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
431 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
432 // elems[0]->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
433 // elems[1]->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
434 // at->dump(); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
435 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
436 LLConstant* ca = LLConstantArray::get(at, elems); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
437 members = new LLGlobalVariable(ca->getType(), true, LLGlobalValue::InternalLinkage, ca, ".array", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
438 members->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
439 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
440 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
441 { |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
442 assert(0 && "unsupported compositetype for debug info"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
443 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
444 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
445 std::vector<LLConstant*> vals; |
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 // tag |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
448 vals.push_back(llvm::ConstantExpr::getAdd( |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
449 DtoConstUint(tag), |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
450 DtoConstUint(llvm::LLVMDebugVersion))); |
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 // context |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
453 vals.push_back(DBG_CAST(compileUnit)); |
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 // name |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
456 vals.push_back(name); |
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 // compile unit where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
459 vals.push_back(DBG_NULL); |
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 // line number where defined |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
462 vals.push_back(DtoConstInt(0)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
463 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
464 // size in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
465 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false)); |
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 // alignment in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
468 vals.push_back(LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false)); |
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 // offset in bits |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
471 vals.push_back(LLConstantInt::get(LLType::Int64Ty, 0, false)); |
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 // FIXME: dont know what this is |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
474 vals.push_back(DtoConstUint(0)); |
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 // FIXME: ditto |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
477 vals.push_back(DBG_NULL); |
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 // members array |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
480 if (members) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
481 vals.push_back(DBG_CAST(members)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
482 else |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
483 vals.push_back(DBG_NULL); |
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 LLConstant* c = llvm::ConstantStruct::get(getDwarfCompositeTypeType(), vals); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
486 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, LLGlobalValue::InternalLinkage, c, "llvm.dbg.compositetype", gIR->module); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
487 gv->setSection("llvm.metadata"); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
488 return gv; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
489 } |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
490 |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
491 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
492 |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
493 LLGlobalVariable* DtoDwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
494 { |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
495 assert(vd->isDataseg()); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
496 llvm::GlobalVariable* compileUnit = DtoDwarfCompileUnit(gIR->dmodule); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
497 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
498 std::vector<LLConstant*> vals; |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
499 vals.push_back(llvm::ConstantExpr::getAdd( |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
500 DtoConstUint(DW_TAG_variable), |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
501 DtoConstUint(llvm::LLVMDebugVersion))); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
502 vals.push_back(DBG_CAST(GetDwarfAnchor(DW_TAG_variable))); |
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 vals.push_back(DBG_CAST(compileUnit)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
505 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
506 vals.push_back(DtoConstStringPtr(vd->mangle(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
507 vals.push_back(DtoConstStringPtr(vd->toPrettyChars(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
508 vals.push_back(DtoConstStringPtr(vd->toChars(), "llvm.metadata")); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
509 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
510 vals.push_back(DBG_CAST(DtoDwarfCompileUnit(vd->getModule()))); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
511 vals.push_back(DtoConstUint(vd->loc.linnum)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
512 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
513 LLGlobalVariable* TY = dwarfTypeDescription(vd->loc, vd->type, compileUnit, NULL); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
514 vals.push_back(TY ? DBG_CAST(TY) : DBG_NULL); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
515 vals.push_back(DtoConstBool(vd->protection == PROTprivate)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
516 vals.push_back(DtoConstBool(vd->getModule() == gIR->dmodule)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
517 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
518 vals.push_back(DBG_CAST(ll)); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
519 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
520 LLConstant* c = llvm::ConstantStruct::get(getDwarfGlobalVariableType(), vals); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
521 llvm::GlobalVariable* gv = new llvm::GlobalVariable(c->getType(), true, llvm::GlobalValue::InternalLinkage, c, "llvm.dbg.global_variable", gIR->module); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
522 gv->setSection("llvm.metadata"); |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
523 return gv; |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
524 } |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
525 |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
526 ////////////////////////////////////////////////////////////////////////////////////////////////// |
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
527 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
528 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
|
529 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
530 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
|
531 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
|
532 tag = DW_TAG_arg_variable; |
247
56199753e637
[svn r264] Fixed debug info for global variables.
lindquist
parents:
246
diff
changeset
|
533 else if (vd->isDataseg()) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
534 assert(0 && "a static variable"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
535 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
536 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
|
537 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
538 std::vector<LLConstant*> vals; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
539 // tag |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
540 vals.push_back(llvm::ConstantExpr::getAdd( |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
541 DtoConstUint(tag), |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
542 DtoConstUint(llvm::LLVMDebugVersion))); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
543 // context |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
544 vals.push_back(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
|
545 // name |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
546 vals.push_back(DtoConstStringPtr(vd->toChars(), "llvm.metadata")); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
547 // compile unit where defined |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
548 vals.push_back(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
|
549 // 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
|
550 vals.push_back(DtoConstUint(vd->loc.linnum)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
551 // type descriptor |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
552 vals.push_back(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
|
553 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
554 LLConstant* c = llvm::ConstantStruct::get(getDwarfVariableType(), vals); |
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 LLGlobalVariable* gv = new LLGlobalVariable(c->getType(), true, LLGlobalValue::InternalLinkage, c, "llvm.dbg.variable", gIR->module); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
556 gv->setSection("llvm.metadata"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
557 return gv; |
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
561 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
562 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
|
563 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
217
diff
changeset
|
564 LLSmallVector<LLValue*,2> args; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
565 args.push_back(DtoBitCast(var, DBG_TYPE)); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
566 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
|
567 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
|
568 } |
245
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 ////////////////////////////////////////////////////////////////////////////////////////////////// |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
571 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
572 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
|
573 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
574 Type* t = type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
575 if (t->ty == Tvoid) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
576 return NULL; |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
577 else if (t->isintegral() || t->isfloating()) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
578 return dwarfBasicType(type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
579 else if (t->ty == Tpointer) |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
580 return dwarfDerivedType(loc, type, cu); |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
581 else if (t->ty == Tarray) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
582 return dwarfCompositeType(loc, type, cu); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
583 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
584 if (global.params.warnings) |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
585 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
|
586 return NULL; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
587 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
588 |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
589 ////////////////////////////////////////////////////////////////////////////////////////////////// |
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
590 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
591 void DtoDwarfLocalVariable(LLValue* ll, VarDeclaration* vd) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
592 { |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
593 // get compile units |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
594 LLGlobalVariable* thisCU = DtoDwarfCompileUnit(gIR->dmodule); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
595 LLGlobalVariable* varCU = thisCU; |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
596 if (vd->getModule() != gIR->dmodule) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
597 varCU = DtoDwarfCompileUnit(vd->getModule()); |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
598 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
599 // get type description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
600 Type* t = vd->type->toBasetype(); |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
601 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
|
602 if (TD == NULL) |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
603 return; // unsupported |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
604 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
605 // get variable description |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
606 LLGlobalVariable* VD; |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
607 VD = dwarfVariable(vd, TD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
608 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
609 // declare |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
245
diff
changeset
|
610 dwarfDeclare(ll, VD); |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
611 } |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
612 |
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 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
615 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
616 |
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 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
619 |
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 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
622 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
623 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
624 |
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
625 |