当前位置: 首页>>代码示例>>C++>>正文


C++ DILineInfoSpecifier类代码示例

本文整理汇总了C++中DILineInfoSpecifier的典型用法代码示例。如果您正苦于以下问题:C++ DILineInfoSpecifier类的具体用法?C++ DILineInfoSpecifier怎么用?C++ DILineInfoSpecifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DILineInfoSpecifier类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getCompileUnitForAddress

DILineInfo DWARFContext::getLineInfoForAddress(uint64_t Address,
    DILineInfoSpecifier Specifier) {
  DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
  if (!CU)
    return DILineInfo();
  std::string FileName = "<invalid>";
  std::string FunctionName = "<invalid>";
  uint32_t Line = 0;
  uint32_t Column = 0;
  if (Specifier.needs(DILineInfoSpecifier::FunctionName)) {
    // The address may correspond to instruction in some inlined function,
    // so we have to build the chain of inlined functions and take the
    // name of the topmost function in it.
    const DWARFDebugInfoEntryMinimal::InlinedChain &InlinedChain =
        CU->getInlinedChainForAddress(Address);
    if (InlinedChain.size() > 0) {
      const DWARFDebugInfoEntryMinimal &TopFunctionDIE = InlinedChain[0];
      if (const char *Name = TopFunctionDIE.getSubroutineName(CU))
        FunctionName = Name;
    }
  }
  if (Specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
    const DWARFLineTable *LineTable = getLineTableForCompileUnit(CU);
    const bool NeedsAbsoluteFilePath =
        Specifier.needs(DILineInfoSpecifier::AbsoluteFilePath);
    getFileLineInfoForCompileUnit(CU, LineTable, Address,
                                  NeedsAbsoluteFilePath,
                                  FileName, Line, Column);
  }
  return DILineInfo(StringRef(FileName), StringRef(FunctionName),
                    Line, Column);
}
开发者ID:Hoernchen,项目名称:llvm,代码行数:32,代码来源:DWARFContext.cpp

示例2: getDebugAranges

DILineInfo DWARFContext::getLineInfoForAddress(uint64_t address,
    DILineInfoSpecifier specifier) {
  // First, get the offset of the compile unit.
  uint32_t cuOffset = getDebugAranges()->findAddress(address);
  // Retrieve the compile unit.
  DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset);
  if (!cu)
    return DILineInfo();
  SmallString<16> fileName("<invalid>");
  SmallString<16> functionName("<invalid>");
  uint32_t line = 0;
  uint32_t column = 0;
  if (specifier.needs(DILineInfoSpecifier::FunctionName)) {
    const DWARFDebugInfoEntryMinimal *function_die =
        cu->getFunctionDIEForAddress(address);
    if (function_die) {
      if (const char *name = function_die->getSubprogramName(cu))
        functionName = name;
    }
  }
  if (specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
    // Get the line table for this compile unit.
    const DWARFDebugLine::LineTable *lineTable = getLineTableForCompileUnit(cu);
    if (lineTable) {
      // Get the index of the row we're looking for in the line table.
      uint32_t rowIndex = lineTable->lookupAddress(address);
      if (rowIndex != -1U) {
        const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex];
        // Take file/line info from the line table.
        const DWARFDebugLine::FileNameEntry &fileNameEntry =
            lineTable->Prologue.FileNames[row.File - 1];
        fileName = fileNameEntry.Name;
        if (specifier.needs(DILineInfoSpecifier::AbsoluteFilePath) &&
            sys::path::is_relative(fileName.str())) {
          // Append include directory of file (if it is present in line table)
          // and compilation directory of compile unit to make path absolute.
          const char *includeDir = 0;
          if (uint64_t includeDirIndex = fileNameEntry.DirIdx) {
            includeDir = lineTable->Prologue
                         .IncludeDirectories[includeDirIndex - 1];
          }
          SmallString<16> absFileName;
          if (includeDir == 0 || sys::path::is_relative(includeDir)) {
            if (const char *compilationDir = cu->getCompilationDir())
              sys::path::append(absFileName, compilationDir);
          }
          if (includeDir) {
            sys::path::append(absFileName, includeDir);
          }
          sys::path::append(absFileName, fileName.str());
          fileName = absFileName;
        }
        line = row.Line;
        column = row.Column;
      }
    }
  }
  return DILineInfo(fileName, functionName, line, column);
}
开发者ID:JeeLiu,项目名称:myDocument,代码行数:59,代码来源:DWARFContext.cpp

示例3: getCompileUnitForAddress

DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
    DILineInfoSpecifier Specifier) {
  DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
  if (!CU)
    return DIInliningInfo();

  const DWARFDebugInfoEntryInlinedChain &InlinedChain =
      CU->getInlinedChainForAddress(Address);
  if (InlinedChain.DIEs.size() == 0)
    return DIInliningInfo();

  DIInliningInfo InliningInfo;
  uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
  const DWARFLineTable *LineTable = 0;
  for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
    const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
    std::string FileName = "<invalid>";
    std::string FunctionName = "<invalid>";
    uint32_t Line = 0;
    uint32_t Column = 0;
    // Get function name if necessary.
    if (Specifier.needs(DILineInfoSpecifier::FunctionName)) {
      if (const char *Name = FunctionDIE.getSubroutineName(InlinedChain.U))
        FunctionName = Name;
    }
    if (Specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
      const bool NeedsAbsoluteFilePath =
          Specifier.needs(DILineInfoSpecifier::AbsoluteFilePath);
      if (i == 0) {
        // For the topmost frame, initialize the line table of this
        // compile unit and fetch file/line info from it.
        LineTable = getLineTableForCompileUnit(CU);
        // For the topmost routine, get file/line info from line table.
        getFileLineInfoForCompileUnit(CU, LineTable, Address,
                                      NeedsAbsoluteFilePath,
                                      FileName, Line, Column);
      } else {
        // Otherwise, use call file, call line and call column from
        // previous DIE in inlined chain.
        getFileNameForCompileUnit(CU, LineTable, CallFile,
                                  NeedsAbsoluteFilePath, FileName);
        Line = CallLine;
        Column = CallColumn;
      }
      // Get call file/line/column of a current DIE.
      if (i + 1 < n) {
        FunctionDIE.getCallerFrame(InlinedChain.U, CallFile, CallLine,
                                   CallColumn);
      }
    }
    DILineInfo Frame(StringRef(FileName), StringRef(FunctionName),
                     Line, Column);
    InliningInfo.addFrame(Frame);
  }
  return InliningInfo;
}
开发者ID:QuentinFiard,项目名称:llvm,代码行数:56,代码来源:DWARFContext.cpp

示例4: getCompileUnitForAddress

DILineInfoTable DWARFContext::getLineInfoForAddressRange(uint64_t Address,
    uint64_t Size,
    DILineInfoSpecifier Specifier) {
  DILineInfoTable  Lines;
  DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
  if (!CU)
    return Lines;

  std::string FunctionName = "<invalid>";
  if (Specifier.needs(DILineInfoSpecifier::FunctionName)) {
    getFunctionNameForAddress(CU, Address, FunctionName);
  }

  // If the Specifier says we don't need FileLineInfo, just
  // return the top-most function at the starting address.
  if (!Specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
    DILineInfo Result;
    Result.FunctionName = FunctionName;
    Lines.push_back(std::make_pair(Address, Result));
    return Lines;
  }

  const DWARFLineTable *LineTable = getLineTableForCompileUnit(CU);
  const bool NeedsAbsoluteFilePath =
      Specifier.needs(DILineInfoSpecifier::AbsoluteFilePath);

  // Get the index of row we're looking for in the line table.
  std::vector<uint32_t> RowVector;
  if (!LineTable->lookupAddressRange(Address, Size, RowVector))
    return Lines;

  for (uint32_t RowIndex : RowVector) {
    // Take file number and line/column from the row.
    const DWARFDebugLine::Row &Row = LineTable->Rows[RowIndex];
    DILineInfo Result;
    getFileNameForCompileUnit(CU, LineTable, Row.File, NeedsAbsoluteFilePath,
                              Result.FileName);
    Result.FunctionName = FunctionName;
    Result.Line = Row.Line;
    Result.Column = Row.Column;
    Lines.push_back(std::make_pair(Row.Address, Result));
  }

  return Lines;
}
开发者ID:christinaa,项目名称:LLVM-VideoCore4,代码行数:45,代码来源:DWARFContext.cpp

示例5: getDebugAranges

DILineInfo DWARFContext::getLineInfoForAddress(uint64_t address,
    DILineInfoSpecifier specifier) {
  // First, get the offset of the compile unit.
  uint32_t cuOffset = getDebugAranges()->findAddress(address);
  // Retrieve the compile unit.
  DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset);
  if (!cu)
    return DILineInfo();
  const char *fileName = "<invalid>";
  const char *functionName = "<invalid>";
  uint32_t line = 0;
  uint32_t column = 0;
  if (specifier.needs(DILineInfoSpecifier::FunctionName)) {
    const DWARFDebugInfoEntryMinimal *function_die =
        cu->getFunctionDIEForAddress(address);
    if (function_die)
      functionName = function_die->getSubprogramName(cu);
  }
  if (specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
    // Get the line table for this compile unit.
    const DWARFDebugLine::LineTable *lineTable = getLineTableForCompileUnit(cu);
    if (lineTable) {
      // Get the index of the row we're looking for in the line table.
      uint64_t hiPC = cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(
          cu, DW_AT_high_pc, -1ULL);
      uint32_t rowIndex = lineTable->lookupAddress(address, hiPC);
      if (rowIndex != -1U) {
        const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex];
        // Take file/line info from the line table.
        fileName = lineTable->Prologue.FileNames[row.File - 1].Name.c_str();
        line = row.Line;
        column = row.Column;
      }
    }
  }
  return DILineInfo(fileName, functionName, line, column);
}
开发者ID:FrOSt-Foundation,项目名称:llvm-dcpu16,代码行数:37,代码来源:DWARFContext.cpp


注:本文中的DILineInfoSpecifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。