bool cmpDICU(const DICompileUnit & CU1, const DICompileUnit & CU2) { int cmp = CU1.getDirectory().compare(CU2.getDirectory()); if (cmp == 0) cmp = CU1.getFilename().compare(CU2.getFilename()); return cmp >= 0 ? false : true; }
static bool getLocationInfo(const Value *V, std::string &DisplayName, std::string &Type, unsigned &LineNo, std::string &File, std::string &Dir) { DICompileUnit Unit; DIType TypeD; if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) { Value *DIGV = findDbgGlobalDeclare(GV); if (!DIGV) return false; DIGlobalVariable Var(cast<MDNode>(DIGV)); StringRef D = Var.getDisplayName(); if (!D.empty()) DisplayName = D; LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){ Value *DIF = findDbgSubprogramDeclare(F); if (!DIF) return false; DISubprogram Var(cast<MDNode>(DIF)); StringRef D = Var.getDisplayName(); if (!D.empty()) DisplayName = D; LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); } else { const DbgDeclareInst *DDI = findDbgDeclare(V); if (!DDI) return false; DIVariable Var(cast<MDNode>(DDI->getVariable())); StringRef D = Var.getName(); if (!D.empty()) DisplayName = D; LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); } StringRef T = TypeD.getName(); if (!T.empty()) Type = T; StringRef F = Unit.getFilename(); if (!F.empty()) File = F; StringRef D = Unit.getDirectory(); if (!D.empty()) Dir = D; return true; }
bool getLocationInfo(const Value *V, std::string &DisplayName, std::string &Type, unsigned &LineNo, std::string &File, std::string &Dir) { DICompileUnit Unit; DIType TypeD; if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) { Value *DIGV = findDbgGlobalDeclare(GV); if (!DIGV) return false; DIGlobalVariable Var(cast<MDNode>(DIGV)); if (const char *D = Var.getDisplayName()) DisplayName = D; LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); } else { const DbgDeclareInst *DDI = findDbgDeclare(V); if (!DDI) return false; DIVariable Var(cast<MDNode>(DDI->getVariable())); if (const char *D = Var.getName()) DisplayName = D; LineNo = Var.getLineNumber(); Unit = Var.getCompileUnit(); TypeD = Var.getType(); } if (const char *T = TypeD.getName()) Type = T; if (const char *F = Unit.getFilename()) File = F; if (const char *D = Unit.getDirectory()) Dir = D; return true; }
void DIEItem::ShowCompileUnit(DetailsView* detailsView, DICompileUnit cu) { detailsView->Add(_("CompileUnit"), toWxStr(cu.getDirectory()) + _("/") + toWxStr(cu.getFilename())); }