Jim Laskey | 6af5681 | 2006-01-04 13:36:38 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/MachineDebugInfo.cpp -----------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by James M. Laskey and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jim Laskey | 6af5681 | 2006-01-04 13:36:38 +0000 | [diff] [blame] | 9 | |
| 10 | #include "llvm/CodeGen/MachineDebugInfo.h" |
| 11 | |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 12 | #include "llvm/Constants.h" |
| 13 | #include "llvm/DerivedTypes.h" |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 14 | #include "llvm/GlobalVariable.h" |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 15 | #include "llvm/Intrinsics.h" |
| 16 | #include "llvm/Instructions.h" |
| 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/Support/Dwarf.h" |
| 19 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 20 | #include <iostream> |
| 21 | |
Jim Laskey | 6af5681 | 2006-01-04 13:36:38 +0000 | [diff] [blame] | 22 | using namespace llvm; |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 23 | using namespace llvm::dwarf; |
Jim Laskey | 6af5681 | 2006-01-04 13:36:38 +0000 | [diff] [blame] | 24 | |
| 25 | // Handle the Pass registration stuff necessary to use TargetData's. |
| 26 | namespace { |
Jim Laskey | b2efb85 | 2006-01-04 22:28:25 +0000 | [diff] [blame] | 27 | RegisterPass<MachineDebugInfo> X("machinedebuginfo", "Debug Information"); |
| 28 | } |
Jim Laskey | 063e765 | 2006-01-17 17:31:53 +0000 | [diff] [blame] | 29 | |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 30 | //===----------------------------------------------------------------------===// |
| 31 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 32 | /// getGlobalVariablesUsing - Return all of the GlobalVariables which have the |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 33 | /// specified value in their initializer somewhere. |
| 34 | static void |
| 35 | getGlobalVariablesUsing(Value *V, std::vector<GlobalVariable*> &Result) { |
| 36 | // Scan though value users. |
| 37 | for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) { |
| 38 | if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*I)) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 39 | // If the user is a GlobalVariable then add to result. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 40 | Result.push_back(GV); |
| 41 | } else if (Constant *C = dyn_cast<Constant>(*I)) { |
| 42 | // If the user is a constant variable then scan its users |
| 43 | getGlobalVariablesUsing(C, Result); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 48 | /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the |
| 49 | /// named GlobalVariable. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 50 | static std::vector<GlobalVariable*> |
| 51 | getGlobalVariablesUsing(Module &M, const std::string &RootName) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 52 | std::vector<GlobalVariable*> Result; // GlobalVariables matching criteria. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 53 | |
| 54 | std::vector<const Type*> FieldTypes; |
| 55 | FieldTypes.push_back(Type::UIntTy); |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 56 | FieldTypes.push_back(Type::UIntTy); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 57 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 58 | // Get the GlobalVariable root. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 59 | GlobalVariable *UseRoot = M.getGlobalVariable(RootName, |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 60 | StructType::get(FieldTypes)); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 61 | |
| 62 | // If present and linkonce then scan for users. |
| 63 | if (UseRoot && UseRoot->hasLinkOnceLinkage()) { |
| 64 | getGlobalVariablesUsing(UseRoot, Result); |
| 65 | } |
| 66 | |
| 67 | return Result; |
| 68 | } |
| 69 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 70 | /// isStringValue - Return true if the given value can be coerced to a string. |
| 71 | /// |
| 72 | static bool isStringValue(Value *V) { |
| 73 | if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) { |
| 74 | if (GV->hasInitializer() && isa<ConstantArray>(GV->getInitializer())) { |
| 75 | ConstantArray *Init = cast<ConstantArray>(GV->getInitializer()); |
| 76 | return Init->isString(); |
| 77 | } |
| 78 | } else if (Constant *C = dyn_cast<Constant>(V)) { |
| 79 | if (GlobalValue *GV = dyn_cast<GlobalValue>(C)) |
| 80 | return isStringValue(GV); |
| 81 | else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { |
| 82 | if (CE->getOpcode() == Instruction::GetElementPtr) { |
| 83 | if (CE->getNumOperands() == 3 && |
| 84 | cast<Constant>(CE->getOperand(1))->isNullValue() && |
| 85 | isa<ConstantInt>(CE->getOperand(2))) { |
| 86 | return isStringValue(CE->getOperand(0)); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | return false; |
| 92 | } |
| 93 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 94 | /// getGlobalVariable - Return either a direct or cast Global value. |
Jim Laskey | d8f77ba | 2006-01-27 15:20:54 +0000 | [diff] [blame] | 95 | /// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 96 | static GlobalVariable *getGlobalVariable(Value *V) { |
Jim Laskey | d8f77ba | 2006-01-27 15:20:54 +0000 | [diff] [blame] | 97 | if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) { |
| 98 | return GV; |
| 99 | } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 100 | if (CE->getOpcode() == Instruction::Cast) { |
| 101 | return dyn_cast<GlobalVariable>(CE->getOperand(0)); |
| 102 | } |
Jim Laskey | d8f77ba | 2006-01-27 15:20:54 +0000 | [diff] [blame] | 103 | } |
| 104 | return NULL; |
| 105 | } |
| 106 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 107 | /// isGlobalVariable - Return true if the given value can be coerced to a |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 108 | /// GlobalVariable. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 109 | static bool isGlobalVariable(Value *V) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 110 | if (isa<GlobalVariable>(V) || isa<ConstantPointerNull>(V)) { |
| 111 | return true; |
| 112 | } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) { |
| 113 | if (CE->getOpcode() == Instruction::Cast) { |
| 114 | return isa<GlobalVariable>(CE->getOperand(0)); |
| 115 | } |
| 116 | } |
| 117 | return false; |
| 118 | } |
| 119 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 120 | /// getUIntOperand - Return ith operand if it is an unsigned integer. |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 121 | /// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 122 | static ConstantUInt *getUIntOperand(GlobalVariable *GV, unsigned i) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 123 | // Make sure the GlobalVariable has an initializer. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 124 | if (!GV->hasInitializer()) return NULL; |
Jim Laskey | b2efb85 | 2006-01-04 22:28:25 +0000 | [diff] [blame] | 125 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 126 | // Get the initializer constant. |
| 127 | ConstantStruct *CI = dyn_cast<ConstantStruct>(GV->getInitializer()); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 128 | if (!CI) return NULL; |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 129 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 130 | // Check if there is at least i + 1 operands. |
| 131 | unsigned N = CI->getNumOperands(); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 132 | if (i >= N) return NULL; |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 133 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 134 | // Check constant. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 135 | return dyn_cast<ConstantUInt>(CI->getOperand(i)); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 136 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 137 | //===----------------------------------------------------------------------===// |
| 138 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 139 | /// ApplyToFields - Target the visitor to each field of the debug information |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 140 | /// descriptor. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 141 | void DIVisitor::ApplyToFields(DebugInfoDesc *DD) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 142 | DD->ApplyToFields(this); |
| 143 | } |
| 144 | |
| 145 | //===----------------------------------------------------------------------===// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 146 | /// DICountVisitor - This DIVisitor counts all the fields in the supplied debug |
| 147 | /// the supplied DebugInfoDesc. |
| 148 | class DICountVisitor : public DIVisitor { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 149 | private: |
| 150 | unsigned Count; // Running count of fields. |
| 151 | |
| 152 | public: |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 153 | DICountVisitor() : DIVisitor(), Count(0) {} |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 154 | |
| 155 | // Accessors. |
| 156 | unsigned getCount() const { return Count; } |
| 157 | |
| 158 | /// Apply - Count each of the fields. |
| 159 | /// |
| 160 | virtual void Apply(int &Field) { ++Count; } |
| 161 | virtual void Apply(unsigned &Field) { ++Count; } |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 162 | virtual void Apply(int64_t &Field) { ++Count; } |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 163 | virtual void Apply(uint64_t &Field) { ++Count; } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 164 | virtual void Apply(bool &Field) { ++Count; } |
| 165 | virtual void Apply(std::string &Field) { ++Count; } |
| 166 | virtual void Apply(DebugInfoDesc *&Field) { ++Count; } |
| 167 | virtual void Apply(GlobalVariable *&Field) { ++Count; } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 168 | virtual void Apply(std::vector<DebugInfoDesc *> &Field) { |
| 169 | ++Count; |
| 170 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | //===----------------------------------------------------------------------===// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 174 | /// DIDeserializeVisitor - This DIVisitor deserializes all the fields in the |
| 175 | /// supplied DebugInfoDesc. |
| 176 | class DIDeserializeVisitor : public DIVisitor { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 177 | private: |
| 178 | DIDeserializer &DR; // Active deserializer. |
| 179 | unsigned I; // Current operand index. |
| 180 | ConstantStruct *CI; // GlobalVariable constant initializer. |
| 181 | |
| 182 | public: |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 183 | DIDeserializeVisitor(DIDeserializer &D, GlobalVariable *GV) |
| 184 | : DIVisitor() |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 185 | , DR(D) |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 186 | , I(0) |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 187 | , CI(cast<ConstantStruct>(GV->getInitializer())) |
| 188 | {} |
| 189 | |
| 190 | /// Apply - Set the value of each of the fields. |
| 191 | /// |
| 192 | virtual void Apply(int &Field) { |
| 193 | Constant *C = CI->getOperand(I++); |
| 194 | Field = cast<ConstantSInt>(C)->getValue(); |
| 195 | } |
| 196 | virtual void Apply(unsigned &Field) { |
| 197 | Constant *C = CI->getOperand(I++); |
| 198 | Field = cast<ConstantUInt>(C)->getValue(); |
| 199 | } |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 200 | virtual void Apply(int64_t &Field) { |
| 201 | Constant *C = CI->getOperand(I++); |
| 202 | Field = cast<ConstantSInt>(C)->getValue(); |
| 203 | } |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 204 | virtual void Apply(uint64_t &Field) { |
| 205 | Constant *C = CI->getOperand(I++); |
| 206 | Field = cast<ConstantUInt>(C)->getValue(); |
| 207 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 208 | virtual void Apply(bool &Field) { |
| 209 | Constant *C = CI->getOperand(I++); |
| 210 | Field = cast<ConstantBool>(C)->getValue(); |
| 211 | } |
| 212 | virtual void Apply(std::string &Field) { |
| 213 | Constant *C = CI->getOperand(I++); |
Jim Laskey | 21b6c9d | 2006-03-08 18:11:07 +0000 | [diff] [blame] | 214 | Field = C->getStringValue(); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 215 | } |
| 216 | virtual void Apply(DebugInfoDesc *&Field) { |
| 217 | Constant *C = CI->getOperand(I++); |
| 218 | Field = DR.Deserialize(C); |
| 219 | } |
| 220 | virtual void Apply(GlobalVariable *&Field) { |
| 221 | Constant *C = CI->getOperand(I++); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 222 | Field = getGlobalVariable(C); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 223 | } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 224 | virtual void Apply(std::vector<DebugInfoDesc *> &Field) { |
| 225 | Constant *C = CI->getOperand(I++); |
| 226 | GlobalVariable *GV = getGlobalVariable(C); |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 227 | Field.resize(0); |
Jim Laskey | 2b0e309 | 2006-03-08 02:07:02 +0000 | [diff] [blame] | 228 | // Have to be able to deal with the empty array case (zero initializer) |
| 229 | if (!GV->hasInitializer()) return; |
| 230 | if (ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer())) { |
| 231 | for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) { |
| 232 | GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i)); |
| 233 | DebugInfoDesc *DE = DR.Deserialize(GVE); |
| 234 | Field.push_back(DE); |
| 235 | } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 236 | } |
| 237 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | //===----------------------------------------------------------------------===// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 241 | /// DISerializeVisitor - This DIVisitor serializes all the fields in |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 242 | /// the supplied DebugInfoDesc. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 243 | class DISerializeVisitor : public DIVisitor { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 244 | private: |
| 245 | DISerializer &SR; // Active serializer. |
| 246 | std::vector<Constant*> &Elements; // Element accumulator. |
| 247 | |
| 248 | public: |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 249 | DISerializeVisitor(DISerializer &S, std::vector<Constant*> &E) |
| 250 | : DIVisitor() |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 251 | , SR(S) |
| 252 | , Elements(E) |
| 253 | {} |
| 254 | |
| 255 | /// Apply - Set the value of each of the fields. |
| 256 | /// |
| 257 | virtual void Apply(int &Field) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 258 | Elements.push_back(ConstantSInt::get(Type::IntTy, Field)); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 259 | } |
| 260 | virtual void Apply(unsigned &Field) { |
| 261 | Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); |
| 262 | } |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 263 | virtual void Apply(int64_t &Field) { |
| 264 | Elements.push_back(ConstantSInt::get(Type::IntTy, Field)); |
| 265 | } |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 266 | virtual void Apply(uint64_t &Field) { |
| 267 | Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); |
| 268 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 269 | virtual void Apply(bool &Field) { |
| 270 | Elements.push_back(ConstantBool::get(Field)); |
| 271 | } |
| 272 | virtual void Apply(std::string &Field) { |
| 273 | Elements.push_back(SR.getString(Field)); |
| 274 | } |
| 275 | virtual void Apply(DebugInfoDesc *&Field) { |
| 276 | GlobalVariable *GV = NULL; |
| 277 | |
| 278 | // If non-NULL the convert to global. |
| 279 | if (Field) GV = SR.Serialize(Field); |
| 280 | |
| 281 | // FIXME - At some point should use specific type. |
| 282 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
| 283 | |
| 284 | if (GV) { |
| 285 | // Set to pointer to global. |
| 286 | Elements.push_back(ConstantExpr::getCast(GV, EmptyTy)); |
| 287 | } else { |
| 288 | // Use NULL. |
| 289 | Elements.push_back(ConstantPointerNull::get(EmptyTy)); |
| 290 | } |
| 291 | } |
| 292 | virtual void Apply(GlobalVariable *&Field) { |
| 293 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 294 | if (Field) { |
| 295 | Elements.push_back(ConstantExpr::getCast(Field, EmptyTy)); |
| 296 | } else { |
| 297 | Elements.push_back(ConstantPointerNull::get(EmptyTy)); |
| 298 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 299 | } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 300 | virtual void Apply(std::vector<DebugInfoDesc *> &Field) { |
| 301 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
| 302 | unsigned N = Field.size(); |
| 303 | ArrayType *AT = ArrayType::get(EmptyTy, N); |
| 304 | std::vector<Constant *> ArrayElements; |
| 305 | |
| 306 | for (unsigned i = 0, N = Field.size(); i < N; ++i) { |
| 307 | GlobalVariable *GVE = SR.Serialize(Field[i]); |
| 308 | Constant *CE = ConstantExpr::getCast(GVE, EmptyTy); |
| 309 | ArrayElements.push_back(cast<Constant>(CE)); |
| 310 | } |
| 311 | |
| 312 | Constant *CA = ConstantArray::get(AT, ArrayElements); |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 313 | GlobalVariable *CAGV = new GlobalVariable(AT, true, |
| 314 | GlobalValue::InternalLinkage, |
| 315 | CA, "llvm.dbg.array", |
| 316 | SR.getModule()); |
Jim Laskey | 7809811 | 2006-03-07 22:00:35 +0000 | [diff] [blame] | 317 | CAGV->setSection("llvm.metadata"); |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 318 | Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy); |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 319 | Elements.push_back(CAE); |
| 320 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | //===----------------------------------------------------------------------===// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 324 | /// DIGetTypesVisitor - This DIVisitor gathers all the field types in |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 325 | /// the supplied DebugInfoDesc. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 326 | class DIGetTypesVisitor : public DIVisitor { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 327 | private: |
| 328 | DISerializer &SR; // Active serializer. |
| 329 | std::vector<const Type*> &Fields; // Type accumulator. |
| 330 | |
| 331 | public: |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 332 | DIGetTypesVisitor(DISerializer &S, std::vector<const Type*> &F) |
| 333 | : DIVisitor() |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 334 | , SR(S) |
| 335 | , Fields(F) |
| 336 | {} |
| 337 | |
| 338 | /// Apply - Set the value of each of the fields. |
| 339 | /// |
| 340 | virtual void Apply(int &Field) { |
| 341 | Fields.push_back(Type::IntTy); |
| 342 | } |
| 343 | virtual void Apply(unsigned &Field) { |
| 344 | Fields.push_back(Type::UIntTy); |
| 345 | } |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 346 | virtual void Apply(int64_t &Field) { |
| 347 | Fields.push_back(Type::IntTy); |
| 348 | } |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 349 | virtual void Apply(uint64_t &Field) { |
| 350 | Fields.push_back(Type::UIntTy); |
| 351 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 352 | virtual void Apply(bool &Field) { |
| 353 | Fields.push_back(Type::BoolTy); |
| 354 | } |
| 355 | virtual void Apply(std::string &Field) { |
| 356 | Fields.push_back(SR.getStrPtrType()); |
| 357 | } |
| 358 | virtual void Apply(DebugInfoDesc *&Field) { |
| 359 | // FIXME - At some point should use specific type. |
| 360 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
| 361 | Fields.push_back(EmptyTy); |
| 362 | } |
| 363 | virtual void Apply(GlobalVariable *&Field) { |
| 364 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
| 365 | Fields.push_back(EmptyTy); |
| 366 | } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 367 | virtual void Apply(std::vector<DebugInfoDesc *> &Field) { |
| 368 | const PointerType *EmptyTy = SR.getEmptyStructPtrType(); |
| 369 | Fields.push_back(EmptyTy); |
| 370 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | //===----------------------------------------------------------------------===// |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 374 | /// DIVerifyVisitor - This DIVisitor verifies all the field types against |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 375 | /// a constant initializer. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 376 | class DIVerifyVisitor : public DIVisitor { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 377 | private: |
| 378 | DIVerifier &VR; // Active verifier. |
| 379 | bool IsValid; // Validity status. |
| 380 | unsigned I; // Current operand index. |
| 381 | ConstantStruct *CI; // GlobalVariable constant initializer. |
| 382 | |
| 383 | public: |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 384 | DIVerifyVisitor(DIVerifier &V, GlobalVariable *GV) |
| 385 | : DIVisitor() |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 386 | , VR(V) |
| 387 | , IsValid(true) |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 388 | , I(0) |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 389 | , CI(cast<ConstantStruct>(GV->getInitializer())) |
| 390 | { |
| 391 | } |
| 392 | |
| 393 | // Accessors. |
| 394 | bool isValid() const { return IsValid; } |
| 395 | |
| 396 | /// Apply - Set the value of each of the fields. |
| 397 | /// |
| 398 | virtual void Apply(int &Field) { |
| 399 | Constant *C = CI->getOperand(I++); |
| 400 | IsValid = IsValid && isa<ConstantInt>(C); |
| 401 | } |
| 402 | virtual void Apply(unsigned &Field) { |
| 403 | Constant *C = CI->getOperand(I++); |
| 404 | IsValid = IsValid && isa<ConstantInt>(C); |
| 405 | } |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 406 | virtual void Apply(int64_t &Field) { |
| 407 | Constant *C = CI->getOperand(I++); |
| 408 | IsValid = IsValid && isa<ConstantInt>(C); |
| 409 | } |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 410 | virtual void Apply(uint64_t &Field) { |
| 411 | Constant *C = CI->getOperand(I++); |
| 412 | IsValid = IsValid && isa<ConstantInt>(C); |
| 413 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 414 | virtual void Apply(bool &Field) { |
| 415 | Constant *C = CI->getOperand(I++); |
| 416 | IsValid = IsValid && isa<ConstantBool>(C); |
| 417 | } |
| 418 | virtual void Apply(std::string &Field) { |
| 419 | Constant *C = CI->getOperand(I++); |
| 420 | IsValid = IsValid && isStringValue(C); |
| 421 | } |
| 422 | virtual void Apply(DebugInfoDesc *&Field) { |
| 423 | // FIXME - Prepare the correct descriptor. |
| 424 | Constant *C = CI->getOperand(I++); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 425 | IsValid = IsValid && isGlobalVariable(C); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 426 | } |
| 427 | virtual void Apply(GlobalVariable *&Field) { |
| 428 | Constant *C = CI->getOperand(I++); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 429 | IsValid = IsValid && isGlobalVariable(C); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 430 | } |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 431 | virtual void Apply(std::vector<DebugInfoDesc *> &Field) { |
| 432 | Constant *C = CI->getOperand(I++); |
| 433 | IsValid = IsValid && isGlobalVariable(C); |
| 434 | if (!IsValid) return; |
| 435 | |
| 436 | GlobalVariable *GV = getGlobalVariable(C); |
| 437 | IsValid = IsValid && GV && GV->hasInitializer(); |
| 438 | if (!IsValid) return; |
| 439 | |
| 440 | ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer()); |
| 441 | IsValid = IsValid && CA; |
| 442 | if (!IsValid) return; |
| 443 | |
| 444 | for (unsigned i = 0, N = CA->getNumOperands(); IsValid && i < N; ++i) { |
| 445 | IsValid = IsValid && isGlobalVariable(CA->getOperand(i)); |
| 446 | if (!IsValid) return; |
| 447 | |
| 448 | GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i)); |
| 449 | VR.Verify(GVE); |
| 450 | } |
| 451 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 452 | }; |
| 453 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 454 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 455 | //===----------------------------------------------------------------------===// |
| 456 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 457 | /// TagFromGlobal - Returns the Tag number from a debug info descriptor |
| 458 | /// GlobalVariable. |
| 459 | unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { |
| 460 | ConstantUInt *C = getUIntOperand(GV, 0); |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 461 | return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /// DescFactory - Create an instance of debug info descriptor based on Tag. |
| 465 | /// Return NULL if not a recognized Tag. |
| 466 | DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) { |
| 467 | switch (Tag) { |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 468 | case DW_TAG_anchor: return new AnchorDesc(); |
| 469 | case DW_TAG_compile_unit: return new CompileUnitDesc(); |
| 470 | case DW_TAG_variable: return new GlobalVariableDesc(); |
| 471 | case DW_TAG_subprogram: return new SubprogramDesc(); |
| 472 | case DW_TAG_base_type: return new BasicTypeDesc(); |
| 473 | case DW_TAG_typedef: |
| 474 | case DW_TAG_pointer_type: |
| 475 | case DW_TAG_reference_type: |
| 476 | case DW_TAG_const_type: |
| 477 | case DW_TAG_volatile_type: |
| 478 | case DW_TAG_restrict_type: return new DerivedTypeDesc(Tag); |
| 479 | case DW_TAG_array_type: |
| 480 | case DW_TAG_structure_type: |
| 481 | case DW_TAG_union_type: |
| 482 | case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag); |
| 483 | case DW_TAG_subrange_type: return new SubrangeDesc(); |
Jim Laskey | f01e547 | 2006-03-03 15:06:57 +0000 | [diff] [blame] | 484 | case DW_TAG_member: return new DerivedTypeDesc(DW_TAG_member); |
Jim Laskey | 6a3eb01 | 2006-03-01 23:52:37 +0000 | [diff] [blame] | 485 | case DW_TAG_enumerator: return new EnumeratorDesc(); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 486 | default: break; |
| 487 | } |
| 488 | return NULL; |
| 489 | } |
| 490 | |
| 491 | /// getLinkage - get linkage appropriate for this type of descriptor. |
| 492 | /// |
| 493 | GlobalValue::LinkageTypes DebugInfoDesc::getLinkage() const { |
| 494 | return GlobalValue::InternalLinkage; |
| 495 | } |
| 496 | |
| 497 | /// ApplyToFields - Target the vistor to the fields of the descriptor. |
| 498 | /// |
| 499 | void DebugInfoDesc::ApplyToFields(DIVisitor *Visitor) { |
| 500 | Visitor->Apply(Tag); |
| 501 | } |
| 502 | |
| 503 | //===----------------------------------------------------------------------===// |
| 504 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 505 | AnchorDesc::AnchorDesc() |
| 506 | : DebugInfoDesc(DW_TAG_anchor) |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 507 | , AnchorTag(0) |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 508 | {} |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 509 | AnchorDesc::AnchorDesc(AnchoredDesc *D) |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 510 | : DebugInfoDesc(DW_TAG_anchor) |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 511 | , AnchorTag(D->getTag()) |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 512 | {} |
| 513 | |
| 514 | // Implement isa/cast/dyncast. |
| 515 | bool AnchorDesc::classof(const DebugInfoDesc *D) { |
| 516 | return D->getTag() == DW_TAG_anchor; |
| 517 | } |
| 518 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 519 | /// getLinkage - get linkage appropriate for this type of descriptor. |
| 520 | /// |
| 521 | GlobalValue::LinkageTypes AnchorDesc::getLinkage() const { |
| 522 | return GlobalValue::LinkOnceLinkage; |
| 523 | } |
| 524 | |
| 525 | /// ApplyToFields - Target the visitor to the fields of the TransUnitDesc. |
| 526 | /// |
| 527 | void AnchorDesc::ApplyToFields(DIVisitor *Visitor) { |
| 528 | DebugInfoDesc::ApplyToFields(Visitor); |
| 529 | |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 530 | Visitor->Apply(AnchorTag); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 531 | } |
| 532 | |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 533 | /// getDescString - Return a string used to compose global names and labels. A |
| 534 | /// A global variable name needs to be defined for each debug descriptor that is |
Jim Laskey | 21b6c9d | 2006-03-08 18:11:07 +0000 | [diff] [blame] | 535 | /// anchored. NOTE: that each global variable named here also needs to be added |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 536 | /// to the list of names left external in the internalizer. |
| 537 | /// ExternalNames.insert("llvm.dbg.compile_units"); |
| 538 | /// ExternalNames.insert("llvm.dbg.global_variables"); |
| 539 | /// ExternalNames.insert("llvm.dbg.subprograms"); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 540 | const char *AnchorDesc::getDescString() const { |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 541 | switch (AnchorTag) { |
| 542 | case DW_TAG_compile_unit: return CompileUnitDesc::AnchorString; |
| 543 | case DW_TAG_variable: return GlobalVariableDesc::AnchorString; |
| 544 | case DW_TAG_subprogram: return SubprogramDesc::AnchorString; |
| 545 | default: break; |
| 546 | } |
| 547 | |
| 548 | assert(0 && "Tag does not have a case for anchor string"); |
| 549 | return ""; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /// getTypeString - Return a string used to label this descriptors type. |
| 553 | /// |
| 554 | const char *AnchorDesc::getTypeString() const { |
| 555 | return "llvm.dbg.anchor.type"; |
| 556 | } |
| 557 | |
| 558 | #ifndef NDEBUG |
| 559 | void AnchorDesc::dump() { |
| 560 | std::cerr << getDescString() << " " |
| 561 | << "Tag(" << getTag() << "), " |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 562 | << "AnchorTag(" << AnchorTag << ")\n"; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 563 | } |
| 564 | #endif |
| 565 | |
| 566 | //===----------------------------------------------------------------------===// |
| 567 | |
| 568 | AnchoredDesc::AnchoredDesc(unsigned T) |
| 569 | : DebugInfoDesc(T) |
| 570 | , Anchor(NULL) |
| 571 | {} |
| 572 | |
| 573 | /// ApplyToFields - Target the visitor to the fields of the AnchoredDesc. |
| 574 | /// |
| 575 | void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) { |
| 576 | DebugInfoDesc::ApplyToFields(Visitor); |
| 577 | |
| 578 | Visitor->Apply((DebugInfoDesc *&)Anchor); |
| 579 | } |
| 580 | |
| 581 | //===----------------------------------------------------------------------===// |
| 582 | |
| 583 | CompileUnitDesc::CompileUnitDesc() |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 584 | : AnchoredDesc(DW_TAG_compile_unit) |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 585 | , DebugVersion(LLVMDebugVersion) |
| 586 | , Language(0) |
| 587 | , FileName("") |
| 588 | , Directory("") |
| 589 | , Producer("") |
| 590 | {} |
| 591 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 592 | // Implement isa/cast/dyncast. |
| 593 | bool CompileUnitDesc::classof(const DebugInfoDesc *D) { |
| 594 | return D->getTag() == DW_TAG_compile_unit; |
| 595 | } |
| 596 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 597 | /// DebugVersionFromGlobal - Returns the version number from a compile unit |
| 598 | /// GlobalVariable. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 599 | unsigned CompileUnitDesc::DebugVersionFromGlobal(GlobalVariable *GV) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 600 | ConstantUInt *C = getUIntOperand(GV, 2); |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 601 | return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 602 | } |
| 603 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 604 | /// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc. |
| 605 | /// |
| 606 | void CompileUnitDesc::ApplyToFields(DIVisitor *Visitor) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 607 | AnchoredDesc::ApplyToFields(Visitor); |
| 608 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 609 | Visitor->Apply(DebugVersion); |
| 610 | Visitor->Apply(Language); |
| 611 | Visitor->Apply(FileName); |
| 612 | Visitor->Apply(Directory); |
| 613 | Visitor->Apply(Producer); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 614 | } |
| 615 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 616 | /// getDescString - Return a string used to compose global names and labels. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 617 | /// |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 618 | const char *CompileUnitDesc::getDescString() const { |
| 619 | return "llvm.dbg.compile_unit"; |
| 620 | } |
| 621 | |
| 622 | /// getTypeString - Return a string used to label this descriptors type. |
| 623 | /// |
| 624 | const char *CompileUnitDesc::getTypeString() const { |
| 625 | return "llvm.dbg.compile_unit.type"; |
| 626 | } |
| 627 | |
| 628 | /// getAnchorString - Return a string used to label this descriptor's anchor. |
| 629 | /// |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 630 | const char *CompileUnitDesc::AnchorString = "llvm.dbg.compile_units"; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 631 | const char *CompileUnitDesc::getAnchorString() const { |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 632 | return AnchorString; |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 633 | } |
| 634 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 635 | #ifndef NDEBUG |
| 636 | void CompileUnitDesc::dump() { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 637 | std::cerr << getDescString() << " " |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 638 | << "Tag(" << getTag() << "), " |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 639 | << "Anchor(" << getAnchor() << "), " |
| 640 | << "DebugVersion(" << DebugVersion << "), " |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 641 | << "Language(" << Language << "), " |
| 642 | << "FileName(\"" << FileName << "\"), " |
| 643 | << "Directory(\"" << Directory << "\"), " |
| 644 | << "Producer(\"" << Producer << "\")\n"; |
| 645 | } |
| 646 | #endif |
| 647 | |
| 648 | //===----------------------------------------------------------------------===// |
| 649 | |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 650 | TypeDesc::TypeDesc(unsigned T) |
| 651 | : DebugInfoDesc(T) |
| 652 | , Context(NULL) |
| 653 | , Name("") |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 654 | , File(NULL) |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 655 | , Size(0) |
Jim Laskey | f01e547 | 2006-03-03 15:06:57 +0000 | [diff] [blame] | 656 | , Offset(0) |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 657 | {} |
| 658 | |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 659 | /// ApplyToFields - Target the visitor to the fields of the TypeDesc. |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 660 | /// |
| 661 | void TypeDesc::ApplyToFields(DIVisitor *Visitor) { |
| 662 | DebugInfoDesc::ApplyToFields(Visitor); |
| 663 | |
| 664 | Visitor->Apply(Context); |
| 665 | Visitor->Apply(Name); |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 666 | Visitor->Apply((DebugInfoDesc *&)File); |
| 667 | Visitor->Apply(Line); |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 668 | Visitor->Apply(Size); |
Jim Laskey | f01e547 | 2006-03-03 15:06:57 +0000 | [diff] [blame] | 669 | Visitor->Apply(Offset); |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | /// getDescString - Return a string used to compose global names and labels. |
| 673 | /// |
| 674 | const char *TypeDesc::getDescString() const { |
| 675 | return "llvm.dbg.type"; |
| 676 | } |
| 677 | |
| 678 | /// getTypeString - Return a string used to label this descriptor's type. |
| 679 | /// |
| 680 | const char *TypeDesc::getTypeString() const { |
| 681 | return "llvm.dbg.type.type"; |
| 682 | } |
| 683 | |
| 684 | #ifndef NDEBUG |
| 685 | void TypeDesc::dump() { |
| 686 | std::cerr << getDescString() << " " |
| 687 | << "Tag(" << getTag() << "), " |
| 688 | << "Context(" << Context << "), " |
| 689 | << "Name(\"" << Name << "\"), " |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 690 | << "File(" << File << "), " |
| 691 | << "Line(" << Line << "), " |
Jim Laskey | f01e547 | 2006-03-03 15:06:57 +0000 | [diff] [blame] | 692 | << "Size(" << Size << "), " |
| 693 | << "Offset(" << Offset << ")\n"; |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 694 | } |
| 695 | #endif |
| 696 | |
| 697 | //===----------------------------------------------------------------------===// |
| 698 | |
| 699 | BasicTypeDesc::BasicTypeDesc() |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 700 | : TypeDesc(DW_TAG_base_type) |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 701 | , Encoding(0) |
| 702 | {} |
| 703 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 704 | // Implement isa/cast/dyncast. |
| 705 | bool BasicTypeDesc::classof(const DebugInfoDesc *D) { |
| 706 | return D->getTag() == DW_TAG_base_type; |
| 707 | } |
| 708 | |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 709 | /// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc. |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 710 | /// |
| 711 | void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) { |
| 712 | TypeDesc::ApplyToFields(Visitor); |
| 713 | |
| 714 | Visitor->Apply(Encoding); |
| 715 | } |
| 716 | |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 717 | /// getDescString - Return a string used to compose global names and labels. |
| 718 | /// |
| 719 | const char *BasicTypeDesc::getDescString() const { |
| 720 | return "llvm.dbg.basictype"; |
| 721 | } |
| 722 | |
| 723 | /// getTypeString - Return a string used to label this descriptor's type. |
| 724 | /// |
| 725 | const char *BasicTypeDesc::getTypeString() const { |
| 726 | return "llvm.dbg.basictype.type"; |
| 727 | } |
| 728 | |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 729 | #ifndef NDEBUG |
| 730 | void BasicTypeDesc::dump() { |
| 731 | std::cerr << getDescString() << " " |
| 732 | << "Tag(" << getTag() << "), " |
| 733 | << "Context(" << getContext() << "), " |
| 734 | << "Name(\"" << getName() << "\"), " |
| 735 | << "Size(" << getSize() << "), " |
| 736 | << "Encoding(" << Encoding << ")\n"; |
| 737 | } |
| 738 | #endif |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 739 | |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 740 | //===----------------------------------------------------------------------===// |
| 741 | |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 742 | DerivedTypeDesc::DerivedTypeDesc(unsigned T) |
| 743 | : TypeDesc(T) |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 744 | , FromType(NULL) |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 745 | {} |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 746 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 747 | // Implement isa/cast/dyncast. |
| 748 | bool DerivedTypeDesc::classof(const DebugInfoDesc *D) { |
| 749 | unsigned T = D->getTag(); |
| 750 | switch (T) { |
| 751 | case DW_TAG_typedef: |
| 752 | case DW_TAG_pointer_type: |
| 753 | case DW_TAG_reference_type: |
| 754 | case DW_TAG_const_type: |
| 755 | case DW_TAG_volatile_type: |
| 756 | case DW_TAG_restrict_type: |
Jim Laskey | f01e547 | 2006-03-03 15:06:57 +0000 | [diff] [blame] | 757 | case DW_TAG_member: |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 758 | return true; |
| 759 | default: break; |
| 760 | } |
| 761 | return false; |
| 762 | } |
| 763 | |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 764 | /// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc. |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 765 | /// |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 766 | void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) { |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 767 | TypeDesc::ApplyToFields(Visitor); |
| 768 | |
| 769 | Visitor->Apply((DebugInfoDesc *&)FromType); |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 772 | /// getDescString - Return a string used to compose global names and labels. |
| 773 | /// |
| 774 | const char *DerivedTypeDesc::getDescString() const { |
| 775 | return "llvm.dbg.derivedtype"; |
| 776 | } |
| 777 | |
| 778 | /// getTypeString - Return a string used to label this descriptor's type. |
| 779 | /// |
| 780 | const char *DerivedTypeDesc::getTypeString() const { |
| 781 | return "llvm.dbg.derivedtype.type"; |
| 782 | } |
| 783 | |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 784 | #ifndef NDEBUG |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 785 | void DerivedTypeDesc::dump() { |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 786 | std::cerr << getDescString() << " " |
| 787 | << "Tag(" << getTag() << "), " |
| 788 | << "Context(" << getContext() << "), " |
| 789 | << "Name(\"" << getName() << "\"), " |
| 790 | << "Size(" << getSize() << "), " |
Jim Laskey | 6990600 | 2006-02-24 16:46:40 +0000 | [diff] [blame] | 791 | << "File(" << getFile() << "), " |
| 792 | << "Line(" << getLine() << "), " |
| 793 | << "FromType(" << FromType << ")\n"; |
Jim Laskey | 434b40b | 2006-02-23 22:37:30 +0000 | [diff] [blame] | 794 | } |
| 795 | #endif |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 796 | |
| 797 | //===----------------------------------------------------------------------===// |
| 798 | |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 799 | CompositeTypeDesc::CompositeTypeDesc(unsigned T) |
| 800 | : DerivedTypeDesc(T) |
| 801 | , Elements() |
| 802 | {} |
| 803 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 804 | // Implement isa/cast/dyncast. |
| 805 | bool CompositeTypeDesc::classof(const DebugInfoDesc *D) { |
| 806 | unsigned T = D->getTag(); |
| 807 | switch (T) { |
| 808 | case DW_TAG_array_type: |
| 809 | case DW_TAG_structure_type: |
| 810 | case DW_TAG_union_type: |
| 811 | case DW_TAG_enumeration_type: |
| 812 | return true; |
| 813 | default: break; |
| 814 | } |
| 815 | return false; |
| 816 | } |
| 817 | |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 818 | /// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc. |
| 819 | /// |
| 820 | void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) { |
| 821 | DerivedTypeDesc::ApplyToFields(Visitor); |
| 822 | |
| 823 | Visitor->Apply(Elements); |
| 824 | } |
| 825 | |
| 826 | /// getDescString - Return a string used to compose global names and labels. |
| 827 | /// |
| 828 | const char *CompositeTypeDesc::getDescString() const { |
| 829 | return "llvm.dbg.compositetype"; |
| 830 | } |
| 831 | |
| 832 | /// getTypeString - Return a string used to label this descriptor's type. |
| 833 | /// |
| 834 | const char *CompositeTypeDesc::getTypeString() const { |
| 835 | return "llvm.dbg.compositetype.type"; |
| 836 | } |
| 837 | |
| 838 | #ifndef NDEBUG |
| 839 | void CompositeTypeDesc::dump() { |
| 840 | std::cerr << getDescString() << " " |
| 841 | << "Tag(" << getTag() << "), " |
| 842 | << "Context(" << getContext() << "), " |
| 843 | << "Name(\"" << getName() << "\"), " |
| 844 | << "Size(" << getSize() << "), " |
| 845 | << "File(" << getFile() << "), " |
| 846 | << "Line(" << getLine() << "), " |
| 847 | << "FromType(" << getFromType() << "), " |
| 848 | << "Elements.size(" << Elements.size() << ")\n"; |
| 849 | } |
| 850 | #endif |
| 851 | |
| 852 | //===----------------------------------------------------------------------===// |
| 853 | |
| 854 | SubrangeDesc::SubrangeDesc() |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 855 | : DebugInfoDesc(DW_TAG_subrange_type) |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 856 | , Lo(0) |
| 857 | , Hi(0) |
| 858 | {} |
| 859 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 860 | // Implement isa/cast/dyncast. |
| 861 | bool SubrangeDesc::classof(const DebugInfoDesc *D) { |
| 862 | return D->getTag() == DW_TAG_subrange_type; |
| 863 | } |
| 864 | |
Jim Laskey | f8913f1 | 2006-03-01 17:53:02 +0000 | [diff] [blame] | 865 | /// ApplyToFields - Target the visitor to the fields of the SubrangeDesc. |
| 866 | /// |
| 867 | void SubrangeDesc::ApplyToFields(DIVisitor *Visitor) { |
| 868 | DebugInfoDesc::ApplyToFields(Visitor); |
| 869 | |
| 870 | Visitor->Apply(Lo); |
| 871 | Visitor->Apply(Hi); |
| 872 | } |
| 873 | |
| 874 | /// getDescString - Return a string used to compose global names and labels. |
| 875 | /// |
| 876 | const char *SubrangeDesc::getDescString() const { |
| 877 | return "llvm.dbg.subrange"; |
| 878 | } |
| 879 | |
| 880 | /// getTypeString - Return a string used to label this descriptor's type. |
| 881 | /// |
| 882 | const char *SubrangeDesc::getTypeString() const { |
| 883 | return "llvm.dbg.subrange.type"; |
| 884 | } |
| 885 | |
| 886 | #ifndef NDEBUG |
| 887 | void SubrangeDesc::dump() { |
| 888 | std::cerr << getDescString() << " " |
| 889 | << "Tag(" << getTag() << "), " |
| 890 | << "Lo(" << Lo << "), " |
| 891 | << "Hi(" << Hi << ")\n"; |
| 892 | } |
| 893 | #endif |
| 894 | |
| 895 | //===----------------------------------------------------------------------===// |
| 896 | |
Jim Laskey | 6a3eb01 | 2006-03-01 23:52:37 +0000 | [diff] [blame] | 897 | EnumeratorDesc::EnumeratorDesc() |
| 898 | : DebugInfoDesc(DW_TAG_enumerator) |
| 899 | , Name("") |
| 900 | , Value(0) |
| 901 | {} |
| 902 | |
| 903 | // Implement isa/cast/dyncast. |
| 904 | bool EnumeratorDesc::classof(const DebugInfoDesc *D) { |
| 905 | return D->getTag() == DW_TAG_enumerator; |
| 906 | } |
| 907 | |
| 908 | /// ApplyToFields - Target the visitor to the fields of the EnumeratorDesc. |
| 909 | /// |
| 910 | void EnumeratorDesc::ApplyToFields(DIVisitor *Visitor) { |
| 911 | DebugInfoDesc::ApplyToFields(Visitor); |
| 912 | |
| 913 | Visitor->Apply(Name); |
| 914 | Visitor->Apply(Value); |
| 915 | } |
| 916 | |
| 917 | /// getDescString - Return a string used to compose global names and labels. |
| 918 | /// |
| 919 | const char *EnumeratorDesc::getDescString() const { |
| 920 | return "llvm.dbg.enumerator"; |
| 921 | } |
| 922 | |
| 923 | /// getTypeString - Return a string used to label this descriptor's type. |
| 924 | /// |
| 925 | const char *EnumeratorDesc::getTypeString() const { |
| 926 | return "llvm.dbg.enumerator.type"; |
| 927 | } |
| 928 | |
| 929 | #ifndef NDEBUG |
| 930 | void EnumeratorDesc::dump() { |
| 931 | std::cerr << getDescString() << " " |
| 932 | << "Tag(" << getTag() << "), " |
| 933 | << "Name(" << Name << "), " |
| 934 | << "Value(" << Value << ")\n"; |
| 935 | } |
| 936 | #endif |
| 937 | |
| 938 | //===----------------------------------------------------------------------===// |
| 939 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 940 | GlobalDesc::GlobalDesc(unsigned T) |
| 941 | : AnchoredDesc(T) |
| 942 | , Context(0) |
| 943 | , Name("") |
| 944 | , TyDesc(NULL) |
| 945 | , IsStatic(false) |
| 946 | , IsDefinition(false) |
| 947 | {} |
| 948 | |
| 949 | /// ApplyToFields - Target the visitor to the fields of the global. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 950 | /// |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 951 | void GlobalDesc::ApplyToFields(DIVisitor *Visitor) { |
| 952 | AnchoredDesc::ApplyToFields(Visitor); |
| 953 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 954 | Visitor->Apply(Context); |
| 955 | Visitor->Apply(Name); |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 956 | Visitor->Apply((DebugInfoDesc *&)TyDesc); |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 957 | Visitor->Apply(IsStatic); |
| 958 | Visitor->Apply(IsDefinition); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | //===----------------------------------------------------------------------===// |
| 962 | |
| 963 | GlobalVariableDesc::GlobalVariableDesc() |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 964 | : GlobalDesc(DW_TAG_variable) |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 965 | , Global(NULL) |
| 966 | {} |
| 967 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 968 | // Implement isa/cast/dyncast. |
| 969 | bool GlobalVariableDesc::classof(const DebugInfoDesc *D) { |
| 970 | return D->getTag() == DW_TAG_variable; |
| 971 | } |
| 972 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 973 | /// ApplyToFields - Target the visitor to the fields of the GlobalVariableDesc. |
| 974 | /// |
| 975 | void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) { |
| 976 | GlobalDesc::ApplyToFields(Visitor); |
| 977 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 978 | Visitor->Apply(Global); |
Jim Laskey | 0420f2a | 2006-02-22 19:02:11 +0000 | [diff] [blame] | 979 | Visitor->Apply(Line); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 980 | } |
| 981 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 982 | /// getDescString - Return a string used to compose global names and labels. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 983 | /// |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 984 | const char *GlobalVariableDesc::getDescString() const { |
| 985 | return "llvm.dbg.global_variable"; |
| 986 | } |
| 987 | |
| 988 | /// getTypeString - Return a string used to label this descriptors type. |
| 989 | /// |
| 990 | const char *GlobalVariableDesc::getTypeString() const { |
| 991 | return "llvm.dbg.global_variable.type"; |
| 992 | } |
| 993 | |
| 994 | /// getAnchorString - Return a string used to label this descriptor's anchor. |
| 995 | /// |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 996 | const char *GlobalVariableDesc::AnchorString = "llvm.dbg.global_variables"; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 997 | const char *GlobalVariableDesc::getAnchorString() const { |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 998 | return AnchorString; |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1001 | #ifndef NDEBUG |
| 1002 | void GlobalVariableDesc::dump() { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1003 | std::cerr << getDescString() << " " |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1004 | << "Tag(" << getTag() << "), " |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1005 | << "Anchor(" << getAnchor() << "), " |
| 1006 | << "Name(\"" << getName() << "\"), " |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 1007 | << "Type(\"" << getTypeDesc() << "\"), " |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1008 | << "IsStatic(" << (isStatic() ? "true" : "false") << "), " |
| 1009 | << "IsDefinition(" << (isDefinition() ? "true" : "false") << "), " |
Jim Laskey | 0420f2a | 2006-02-22 19:02:11 +0000 | [diff] [blame] | 1010 | << "Global(" << Global << "), " |
| 1011 | << "Line(" << Line << ")\n"; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1012 | } |
| 1013 | #endif |
| 1014 | |
| 1015 | //===----------------------------------------------------------------------===// |
| 1016 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1017 | SubprogramDesc::SubprogramDesc() |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1018 | : GlobalDesc(DW_TAG_subprogram) |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1019 | {} |
| 1020 | |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1021 | // Implement isa/cast/dyncast. |
| 1022 | bool SubprogramDesc::classof(const DebugInfoDesc *D) { |
| 1023 | return D->getTag() == DW_TAG_subprogram; |
| 1024 | } |
| 1025 | |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1026 | /// ApplyToFields - Target the visitor to the fields of the |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1027 | /// SubprogramDesc. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1028 | void SubprogramDesc::ApplyToFields(DIVisitor *Visitor) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1029 | GlobalDesc::ApplyToFields(Visitor); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1032 | /// getDescString - Return a string used to compose global names and labels. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1033 | /// |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1034 | const char *SubprogramDesc::getDescString() const { |
| 1035 | return "llvm.dbg.subprogram"; |
| 1036 | } |
| 1037 | |
| 1038 | /// getTypeString - Return a string used to label this descriptors type. |
| 1039 | /// |
| 1040 | const char *SubprogramDesc::getTypeString() const { |
| 1041 | return "llvm.dbg.subprogram.type"; |
| 1042 | } |
| 1043 | |
| 1044 | /// getAnchorString - Return a string used to label this descriptor's anchor. |
| 1045 | /// |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 1046 | const char *SubprogramDesc::AnchorString = "llvm.dbg.subprograms"; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1047 | const char *SubprogramDesc::getAnchorString() const { |
Jim Laskey | e8c3e3b | 2006-03-07 20:53:47 +0000 | [diff] [blame] | 1048 | return AnchorString; |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1051 | #ifndef NDEBUG |
| 1052 | void SubprogramDesc::dump() { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1053 | std::cerr << getDescString() << " " |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1054 | << "Tag(" << getTag() << "), " |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1055 | << "Anchor(" << getAnchor() << "), " |
| 1056 | << "Name(\"" << getName() << "\"), " |
Jim Laskey | f4afdd9 | 2006-02-23 16:58:18 +0000 | [diff] [blame] | 1057 | << "Type(\"" << getTypeDesc() << "\"), " |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1058 | << "IsStatic(" << (isStatic() ? "true" : "false") << "), " |
| 1059 | << "IsDefinition(" << (isDefinition() ? "true" : "false") << ")\n"; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1060 | } |
| 1061 | #endif |
| 1062 | |
Jim Laskey | 45ccae5 | 2006-02-28 20:15:07 +0000 | [diff] [blame] | 1063 | //===----------------------------------------------------------------------===// |
| 1064 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1065 | DebugInfoDesc *DIDeserializer::Deserialize(Value *V) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1066 | return Deserialize(getGlobalVariable(V)); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1067 | } |
| 1068 | DebugInfoDesc *DIDeserializer::Deserialize(GlobalVariable *GV) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1069 | // Handle NULL. |
| 1070 | if (!GV) return NULL; |
| 1071 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1072 | // Check to see if it has been already deserialized. |
| 1073 | DebugInfoDesc *&Slot = GlobalDescs[GV]; |
| 1074 | if (Slot) return Slot; |
| 1075 | |
| 1076 | // Get the Tag from the global. |
| 1077 | unsigned Tag = DebugInfoDesc::TagFromGlobal(GV); |
| 1078 | |
| 1079 | // Get the debug version if a compile unit. |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1080 | if (Tag == DW_TAG_compile_unit) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1081 | DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV); |
| 1082 | } |
| 1083 | |
| 1084 | // Create an empty instance of the correct sort. |
| 1085 | Slot = DebugInfoDesc::DescFactory(Tag); |
| 1086 | assert(Slot && "Unknown Tag"); |
| 1087 | |
| 1088 | // Deserialize the fields. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1089 | DIDeserializeVisitor DRAM(*this, GV); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1090 | DRAM.ApplyToFields(Slot); |
| 1091 | |
| 1092 | return Slot; |
| 1093 | } |
| 1094 | |
| 1095 | //===----------------------------------------------------------------------===// |
| 1096 | |
| 1097 | /// getStrPtrType - Return a "sbyte *" type. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1098 | /// |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1099 | const PointerType *DISerializer::getStrPtrType() { |
| 1100 | // If not already defined. |
| 1101 | if (!StrPtrTy) { |
| 1102 | // Construct the pointer to signed bytes. |
| 1103 | StrPtrTy = PointerType::get(Type::SByteTy); |
| 1104 | } |
| 1105 | |
| 1106 | return StrPtrTy; |
| 1107 | } |
| 1108 | |
| 1109 | /// getEmptyStructPtrType - Return a "{ }*" type. |
| 1110 | /// |
| 1111 | const PointerType *DISerializer::getEmptyStructPtrType() { |
| 1112 | // If not already defined. |
| 1113 | if (!EmptyStructPtrTy) { |
| 1114 | // Construct the empty structure type. |
| 1115 | const StructType *EmptyStructTy = |
| 1116 | StructType::get(std::vector<const Type*>()); |
| 1117 | // Construct the pointer to empty structure type. |
| 1118 | EmptyStructPtrTy = PointerType::get(EmptyStructTy); |
| 1119 | } |
| 1120 | |
| 1121 | return EmptyStructPtrTy; |
| 1122 | } |
| 1123 | |
| 1124 | /// getTagType - Return the type describing the specified descriptor (via tag.) |
| 1125 | /// |
| 1126 | const StructType *DISerializer::getTagType(DebugInfoDesc *DD) { |
| 1127 | // Attempt to get the previously defined type. |
| 1128 | StructType *&Ty = TagTypes[DD->getTag()]; |
| 1129 | |
| 1130 | // If not already defined. |
| 1131 | if (!Ty) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1132 | // Set up fields vector. |
| 1133 | std::vector<const Type*> Fields; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1134 | // Get types of fields. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1135 | DIGetTypesVisitor GTAM(*this, Fields); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1136 | GTAM.ApplyToFields(DD); |
| 1137 | |
| 1138 | // Construct structured type. |
| 1139 | Ty = StructType::get(Fields); |
| 1140 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1141 | // Register type name with module. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1142 | M->addTypeName(DD->getTypeString(), Ty); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | return Ty; |
| 1146 | } |
| 1147 | |
| 1148 | /// getString - Construct the string as constant string global. |
| 1149 | /// |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1150 | Constant *DISerializer::getString(const std::string &String) { |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1151 | // Check string cache for previous edition. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1152 | Constant *&Slot = StringCache[String]; |
| 1153 | // return Constant if previously defined. |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1154 | if (Slot) return Slot; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1155 | // Construct string as an llvm constant. |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1156 | Constant *ConstStr = ConstantArray::get(String); |
| 1157 | // Otherwise create and return a new string global. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1158 | GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, |
| 1159 | GlobalVariable::InternalLinkage, |
| 1160 | ConstStr, "str", M); |
Jim Laskey | 7809811 | 2006-03-07 22:00:35 +0000 | [diff] [blame] | 1161 | StrGV->setSection("llvm.metadata"); |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1162 | // Convert to generic string pointer. |
| 1163 | Slot = ConstantExpr::getCast(StrGV, getStrPtrType()); |
| 1164 | return Slot; |
| 1165 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | /// Serialize - Recursively cast the specified descriptor into a GlobalVariable |
| 1169 | /// so that it can be serialized to a .bc or .ll file. |
| 1170 | GlobalVariable *DISerializer::Serialize(DebugInfoDesc *DD) { |
| 1171 | // Check if the DebugInfoDesc is already in the map. |
| 1172 | GlobalVariable *&Slot = DescGlobals[DD]; |
| 1173 | |
| 1174 | // See if DebugInfoDesc exists, if so return prior GlobalVariable. |
| 1175 | if (Slot) return Slot; |
| 1176 | |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1177 | // Get the type associated with the Tag. |
| 1178 | const StructType *Ty = getTagType(DD); |
| 1179 | |
| 1180 | // Create the GlobalVariable early to prevent infinite recursion. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1181 | GlobalVariable *GV = new GlobalVariable(Ty, true, DD->getLinkage(), |
| 1182 | NULL, DD->getDescString(), M); |
Jim Laskey | 7809811 | 2006-03-07 22:00:35 +0000 | [diff] [blame] | 1183 | GV->setSection("llvm.metadata"); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1184 | |
| 1185 | // Insert new GlobalVariable in DescGlobals map. |
| 1186 | Slot = GV; |
| 1187 | |
| 1188 | // Set up elements vector |
| 1189 | std::vector<Constant*> Elements; |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1190 | // Add fields. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1191 | DISerializeVisitor SRAM(*this, Elements); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1192 | SRAM.ApplyToFields(DD); |
| 1193 | |
| 1194 | // Set the globals initializer. |
| 1195 | GV->setInitializer(ConstantStruct::get(Ty, Elements)); |
| 1196 | |
| 1197 | return GV; |
| 1198 | } |
| 1199 | |
| 1200 | //===----------------------------------------------------------------------===// |
| 1201 | |
| 1202 | /// markVisited - Return true if the GlobalVariable hase been "seen" before. |
| 1203 | /// Mark visited otherwise. |
| 1204 | bool DIVerifier::markVisited(GlobalVariable *GV) { |
| 1205 | // Check if the GlobalVariable is already in the Visited set. |
| 1206 | std::set<GlobalVariable *>::iterator VI = Visited.lower_bound(GV); |
| 1207 | |
| 1208 | // See if GlobalVariable exists. |
| 1209 | bool Exists = VI != Visited.end() && *VI == GV; |
| 1210 | |
| 1211 | // Insert in set. |
| 1212 | if (!Exists) Visited.insert(VI, GV); |
| 1213 | |
| 1214 | return Exists; |
| 1215 | } |
| 1216 | |
| 1217 | /// Verify - Return true if the GlobalVariable appears to be a valid |
| 1218 | /// serialization of a DebugInfoDesc. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1219 | bool DIVerifier::Verify(Value *V) { |
| 1220 | return Verify(getGlobalVariable(V)); |
| 1221 | } |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1222 | bool DIVerifier::Verify(GlobalVariable *GV) { |
| 1223 | // Check if seen before. |
| 1224 | if (markVisited(GV)) return true; |
| 1225 | |
| 1226 | // Get the Tag |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1227 | unsigned Tag = DebugInfoDesc::TagFromGlobal(GV); |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1228 | if (Tag == DW_TAG_invalid) return false; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1229 | |
| 1230 | // If a compile unit we need the debug version. |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1231 | if (Tag == DW_TAG_compile_unit) { |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1232 | DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV); |
Jim Laskey | 9c4447a | 2006-03-01 20:39:36 +0000 | [diff] [blame] | 1233 | if (DebugVersion == DW_TAG_invalid) return false; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | // Construct an empty DebugInfoDesc. |
| 1237 | DebugInfoDesc *DD = DebugInfoDesc::DescFactory(Tag); |
| 1238 | if (!DD) return false; |
| 1239 | |
| 1240 | // Get the initializer constant. |
| 1241 | ConstantStruct *CI = cast<ConstantStruct>(GV->getInitializer()); |
| 1242 | |
| 1243 | // Get the operand count. |
| 1244 | unsigned N = CI->getNumOperands(); |
| 1245 | |
| 1246 | // Get the field count. |
| 1247 | unsigned &Slot = Counts[Tag]; |
| 1248 | if (!Slot) { |
| 1249 | // Check the operand count to the field count |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1250 | DICountVisitor CTAM; |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1251 | CTAM.ApplyToFields(DD); |
| 1252 | Slot = CTAM.getCount(); |
| 1253 | } |
| 1254 | |
| 1255 | // Field count must equal operand count. |
| 1256 | if (Slot != N) { |
| 1257 | delete DD; |
| 1258 | return false; |
| 1259 | } |
| 1260 | |
| 1261 | // Check each field for valid type. |
Jim Laskey | c2f0c8d | 2006-02-06 19:12:02 +0000 | [diff] [blame] | 1262 | DIVerifyVisitor VRAM(*this, GV); |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1263 | VRAM.ApplyToFields(DD); |
| 1264 | |
| 1265 | // Release empty DebugInfoDesc. |
| 1266 | delete DD; |
| 1267 | |
| 1268 | // Return result of field tests. |
| 1269 | return VRAM.isValid(); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | //===----------------------------------------------------------------------===// |
| 1273 | |
| 1274 | |
| 1275 | MachineDebugInfo::MachineDebugInfo() |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1276 | : DR() |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1277 | , CompileUnits() |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1278 | , Directories() |
| 1279 | , SourceFiles() |
| 1280 | , Lines() |
| 1281 | { |
| 1282 | |
| 1283 | } |
| 1284 | MachineDebugInfo::~MachineDebugInfo() { |
| 1285 | |
| 1286 | } |
| 1287 | |
Jim Laskey | b2efb85 | 2006-01-04 22:28:25 +0000 | [diff] [blame] | 1288 | /// doInitialization - Initialize the debug state for a new module. |
| 1289 | /// |
| 1290 | bool MachineDebugInfo::doInitialization() { |
| 1291 | return false; |
Jim Laskey | 6af5681 | 2006-01-04 13:36:38 +0000 | [diff] [blame] | 1292 | } |
| 1293 | |
Jim Laskey | b2efb85 | 2006-01-04 22:28:25 +0000 | [diff] [blame] | 1294 | /// doFinalization - Tear down the debug state after completion of a module. |
| 1295 | /// |
| 1296 | bool MachineDebugInfo::doFinalization() { |
| 1297 | return false; |
| 1298 | } |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1299 | |
Jim Laskey | d96185a | 2006-02-13 12:50:39 +0000 | [diff] [blame] | 1300 | /// getDescFor - Convert a Value to a debug information descriptor. |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1301 | /// |
Jim Laskey | d96185a | 2006-02-13 12:50:39 +0000 | [diff] [blame] | 1302 | // FIXME - use new Value type when available. |
| 1303 | DebugInfoDesc *MachineDebugInfo::getDescFor(Value *V) { |
Jim Laskey | ce72b17 | 2006-02-11 01:01:30 +0000 | [diff] [blame] | 1304 | return DR.Deserialize(V); |
| 1305 | } |
| 1306 | |
| 1307 | /// Verify - Verify that a Value is debug information descriptor. |
| 1308 | /// |
| 1309 | bool MachineDebugInfo::Verify(Value *V) { |
| 1310 | DIVerifier VR; |
| 1311 | return VR.Verify(V); |
| 1312 | } |
| 1313 | |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1314 | /// AnalyzeModule - Scan the module for global debug information. |
| 1315 | /// |
| 1316 | void MachineDebugInfo::AnalyzeModule(Module &M) { |
| 1317 | SetupCompileUnits(M); |
| 1318 | } |
| 1319 | |
| 1320 | /// SetupCompileUnits - Set up the unique vector of compile units. |
| 1321 | /// |
| 1322 | void MachineDebugInfo::SetupCompileUnits(Module &M) { |
Jim Laskey | 0420f2a | 2006-02-22 19:02:11 +0000 | [diff] [blame] | 1323 | std::vector<CompileUnitDesc *>CU = getAnchoredDescriptors<CompileUnitDesc>(M); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1324 | |
Jim Laskey | 0420f2a | 2006-02-22 19:02:11 +0000 | [diff] [blame] | 1325 | for (unsigned i = 0, N = CU.size(); i < N; i++) { |
| 1326 | CompileUnits.insert(CU[i]); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1327 | } |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1328 | } |
| 1329 | |
Jim Laskey | 6e87c0e | 2006-01-26 21:22:49 +0000 | [diff] [blame] | 1330 | /// getCompileUnits - Return a vector of debug compile units. |
| 1331 | /// |
Jim Laskey | 86cbdba | 2006-02-06 15:33:21 +0000 | [diff] [blame] | 1332 | const UniqueVector<CompileUnitDesc *> MachineDebugInfo::getCompileUnits()const{ |
Jim Laskey | 6e87c0e | 2006-01-26 21:22:49 +0000 | [diff] [blame] | 1333 | return CompileUnits; |
| 1334 | } |
| 1335 | |
Jim Laskey | 0420f2a | 2006-02-22 19:02:11 +0000 | [diff] [blame] | 1336 | /// getGlobalVariablesUsing - Return all of the GlobalVariables that use the |
| 1337 | /// named GlobalVariable. |
| 1338 | std::vector<GlobalVariable*> |
| 1339 | MachineDebugInfo::getGlobalVariablesUsing(Module &M, |
| 1340 | const std::string &RootName) { |
| 1341 | return ::getGlobalVariablesUsing(M, RootName); |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 1342 | } |