コード例 #1
0
ファイル: Matcher.cpp プロジェクト: sdasgup3/llvm-slicer
bool cmpDISP(const DISubprogram & SP1, const DISubprogram & SP2) 
{ 
  int cmp = SP1.getDirectory().compare(SP2.getDirectory());
  if (cmp == 0) {
    cmp = SP1.getFilename().compare(SP2.getFilename());
    if (cmp == 0) {
      cmp = SP1.getLineNumber() - SP2.getLineNumber();
    }
  }
  return cmp >= 0 ? false : true;
}
コード例 #2
0
/// addSourceLine - Add location information to specified debug information
/// entry.
void CompileUnit::addSourceLine(DIE *Die, DISubprogram SP) {
  // Verify subprogram.
  if (!SP.Verify())
    return;
  // If the line number is 0, don't add it.
  if (SP.getLineNumber() == 0)
    return;

  unsigned Line = SP.getLineNumber();
  if (!SP.getContext().Verify())
    return;
  unsigned FileID = DD->GetOrCreateSourceID(SP.getFilename(), SP.getDirectory());
  assert(FileID && "Invalid file id");
  addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID);
  addUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
}
コード例 #3
0
ファイル: DebugDatabase.cpp プロジェクト: eddiehung/dox-legup
void DebugDatabase::addFunction(MDNode *subprogram, GenerateRTL *hw) {
    string name;
    DISubprogram s;

    assert(subprogram || hw);

    if (subprogram) {
        s = DISubprogram(subprogram);
        name = s.getName().str();
    }

    if (hw) {
        //        dbgs() << "Adding function " <<
        //        hw->getFunction()->getName().str() << "\n";
        if (hwToFunctionIds.find(hw) != hwToFunctionIds.end()) {
            // This function has already been added
            // This can happen since we add functions with metadata first, then
            // add all functions with hardware next.  Those with metadata will
            // have
            // already been added
            //            dbgs() << "exiting\n";
            return;
        } else {
            //            dbgs() << "not exiting\n";
        }

        if (subprogram) {
            assert(name == hw->getFunction()->getName().str());
        } else {
            name = hw->getFunction()->getName().str();
        }
    }

    std::string query = "INSERT INTO Function (designId, name, inlined, "
                        "hasMetadata, startLineNumber) ";
    query += "VALUES (" + std::to_string(designId);
    query += "," + addQuotesToStr(name);
    query += "," + std::to_string(hw ? false : true);
    query += "," + std::to_string(subprogram ? true : false);
    query += "," + (subprogram ? std::to_string(s.getLineNumber()) : "NULL");
    query += ");";
    runQuery(query);

    int functionId = mysql_insert_id(connection);

    if (subprogram) {
        subprogramsToFunctionIds[subprogram] = functionId;
    }

    if (hw) {
        hwToFunctionIds[hw] = functionId;
    }
}
コード例 #4
0
ファイル: DebugLoc.cpp プロジェクト: ADonut/LLVM-GPGPU
DebugLoc DebugLoc::getFnDebugLoc(const LLVMContext &Ctx) {
  const MDNode *Scope = getScopeNode(Ctx);
  DISubprogram SP = getDISubprogram(Scope);
  if (SP.isSubprogram()) {
    // Check for number of operands since the compatibility is
    // cheap here.  FIXME: Name the magic constant.
    if (SP->getNumOperands() > 19)
      return DebugLoc::get(SP.getScopeLineNumber(), 0, SP);
    else
      return DebugLoc::get(SP.getLineNumber(), 0, SP);
  }

  return DebugLoc();
}