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


C++ DWARFCompileUnit类代码示例

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


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

示例1: GetCompileUnitContainingDIEOffset

DWARFDIE
DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset) {
  DWARFCompileUnit *cu = GetCompileUnitContainingDIEOffset(die_offset);
  if (cu)
    return cu->GetDIE(die_offset);
  return DWARFDIE();
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:7,代码来源:DWARFDebugInfo.cpp

示例2: GetDWARF

DWARFDIE
DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const
{
    if (IsValid())
    {
        SymbolFileDWARF *dwarf= GetDWARF();
        DWARFCompileUnit *cu = GetCU();
        DWARFDebugInfoEntry* function_die = nullptr;
        DWARFDebugInfoEntry* block_die = nullptr;
        if (m_die->LookupAddress (file_addr,
                                  dwarf,
                                  cu,
                                  &function_die,
                                  &block_die))
        {
            if (block_die && block_die != function_die)
            {
                if (cu->ContainsDIEOffset(block_die->GetOffset()))
                    return DWARFDIE(cu, block_die);
                else
                    return DWARFDIE(dwarf->DebugInfo()->GetCompileUnitContainingDIE(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die);
            }
        }
    }
    return DWARFDIE();
}
开发者ID:k06a,项目名称:lldb,代码行数:26,代码来源:DWARFDIE.cpp

示例3: if

static dw_offset_t
DWARFDebugInfo_ParseCallback
(
    SymbolFileDWARF* dwarf2Data,
    DWARFCompileUnitSP& cu_sp,
    DWARFDebugInfoEntry* die,
    const dw_offset_t next_offset,
    const uint32_t curr_depth,
    void* userData
)
{
    DWARFDebugInfo* debug_info = (DWARFDebugInfo*)userData;
    DWARFCompileUnit* cu = cu_sp.get();
    if (die)
    {
        cu->AddDIE(*die);
    }
    else if (cu)
    {
        debug_info->AddCompileUnit(cu_sp);
    }

    // Just return the current offset to parse the next CU or DIE entry
    return next_offset;
}
开发者ID:filcab,项目名称:lldb,代码行数:25,代码来源:DWARFDebugInfo.cpp

示例4: getCompileUnitForAddress

DIInliningInfo
DWARFContext::getInliningInfoForAddress(uint64_t Address,
                                        DILineInfoSpecifier Spec) {
  DIInliningInfo InliningInfo;

  DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
  if (!CU)
    return InliningInfo;

  const DWARFLineTable *LineTable = nullptr;
  SmallVector<DWARFDie, 4> InlinedChain;
  CU->getInlinedChainForAddress(Address, InlinedChain);
  if (InlinedChain.size() == 0) {
    // If there is no DIE for address (e.g. it is in unavailable .dwo file),
    // try to at least get file/line info from symbol table.
    if (Spec.FLIKind != FileLineInfoKind::None) {
      DILineInfo Frame;
      LineTable = getLineTableForUnit(CU);
      if (LineTable &&
          LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),
                                               Spec.FLIKind, Frame))
        InliningInfo.addFrame(Frame);
    }
    return InliningInfo;
  }

  uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
  for (uint32_t i = 0, n = InlinedChain.size(); i != n; i++) {
    DWARFDie &FunctionDIE = InlinedChain[i];
    DILineInfo Frame;
    // Get function name if necessary.
    if (const char *Name = FunctionDIE.getSubroutineName(Spec.FNKind))
      Frame.FunctionName = Name;
    if (Spec.FLIKind != FileLineInfoKind::None) {
      if (i == 0) {
        // For the topmost frame, initialize the line table of this
        // compile unit and fetch file/line info from it.
        LineTable = getLineTableForUnit(CU);
        // For the topmost routine, get file/line info from line table.
        if (LineTable)
          LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),
                                               Spec.FLIKind, Frame);
      } else {
        // Otherwise, use call file, call line and call column from
        // previous DIE in inlined chain.
        if (LineTable)
          LineTable->getFileNameByIndex(CallFile, CU->getCompilationDir(),
                                        Spec.FLIKind, Frame.FileName);
        Frame.Line = CallLine;
        Frame.Column = CallColumn;
      }
      // Get call file/line/column of a current DIE.
      if (i + 1 < n) {
        FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn);
      }
    }
    InliningInfo.addFrame(Frame);
  }
  return InliningInfo;
}
开发者ID:dberlin,项目名称:llvm-gvn-rewrite,代码行数:60,代码来源:DWARFContext.cpp

示例5: 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

示例6: GetCompileUnit

//----------------------------------------------------------------------
// GetDIE()
//
// Get the DIE (Debug Information Entry) with the specified offset.
//----------------------------------------------------------------------
DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
  DWARFCompileUnit *cu = GetCompileUnit(die_ref);
  if (cu)
    return cu->GetDIE(die_ref.die_offset);
  return DWARFDIE(); // Not found
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:12,代码来源:DWARFDebugInfo.cpp

示例7: 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

示例8: 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

示例9: DWARFDebugAranges

DWARFDebugAranges &
DWARFDebugInfo::GetCompileUnitAranges ()
{
    if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
    {
        Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));

        m_cu_aranges_ap.reset (new DWARFDebugAranges());
        const DWARFDataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();
        if (debug_aranges_data.GetByteSize() > 0)
        {
            if (log)
                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" from .debug_aranges",
                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
            m_cu_aranges_ap->Extract (debug_aranges_data);
            
        }

        // Make a list of all CUs represented by the arange data in the file.
        std::set<dw_offset_t> cus_with_data;
        for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++)
        {
            dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
            if (offset != DW_INVALID_OFFSET)
                cus_with_data.insert (offset);
        }

        // Manually build arange data for everything that wasn't in the .debug_aranges table.
        bool printed = false;
        const size_t num_compile_units = GetNumCompileUnits();
        const bool clear_dies_if_already_not_parsed = true;
        for (size_t idx = 0; idx < num_compile_units; ++idx)
        {
            DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);

            dw_offset_t offset = cu->GetOffset();
            if (cus_with_data.find(offset) == cus_with_data.end())
            {
                if (log)
                {
                    if (!printed)
                        log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
                                     m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
                    printed = true;
                }
                cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
            }
        }

        const bool minimize = true;
        m_cu_aranges_ap->Sort (minimize);
    }
    return *m_cu_aranges_ap.get();
}
开发者ID:AAZemlyanukhin,项目名称:freebsd,代码行数:54,代码来源:DWARFDebugInfo.cpp

示例10: clear

bool DWARFDebugAranges::generate(DWARFContext *ctx) {
  clear();
  if (ctx) {
    const uint32_t num_compile_units = ctx->getNumCompileUnits();
    for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
      DWARFCompileUnit *cu = ctx->getCompileUnitAtIndex(cu_idx);
      if (cu)
        cu->buildAddressRangeTable(this, true);
    }
  }
  return !isEmpty();
}
开发者ID:2014-class,项目名称:freerouter,代码行数:12,代码来源:DWARFDebugAranges.cpp

示例11: getDebugAbbrev

void DWARFContext::dump(raw_ostream &OS) {
  OS << ".debug_abbrev contents:\n";
  getDebugAbbrev()->dump(OS);

  OS << "\n.debug_info contents:\n";
  for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i)
    getCompileUnitAtIndex(i)->dump(OS);

  OS << "\n.debug_aranges contents:\n";
  DataExtractor arangesData(getARangeSection(), isLittleEndian(), 0);
  uint32_t offset = 0;
  DWARFDebugArangeSet set;
  while (set.extract(arangesData, &offset))
    set.dump(OS);

  uint8_t savedAddressByteSize = 0;
  OS << "\n.debug_lines contents:\n";
  for (unsigned i = 0, e = getNumCompileUnits(); i != e; ++i) {
    DWARFCompileUnit *cu = getCompileUnitAtIndex(i);
    savedAddressByteSize = cu->getAddressByteSize();
    unsigned stmtOffset =
      cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_stmt_list,
                                                           -1U);
    if (stmtOffset != -1U) {
      DataExtractor lineData(getLineSection(), isLittleEndian(),
                             savedAddressByteSize);
      DWARFDebugLine::DumpingState state(OS);
      DWARFDebugLine::parseStatementTable(lineData, &stmtOffset, state);
    }
  }

  OS << "\n.debug_str contents:\n";
  DataExtractor strData(getStringSection(), isLittleEndian(), 0);
  offset = 0;
  uint32_t lastOffset = 0;
  while (const char *s = strData.getCStr(&offset)) {
    OS << format("0x%8.8x: \"%s\"\n", lastOffset, s);
    lastOffset = offset;
  }

  OS << "\n.debug_ranges contents:\n";
  // In fact, different compile units may have different address byte
  // sizes, but for simplicity we just use the address byte size of the last
  // compile unit (there is no easy and fast way to associate address range
  // list and the compile unit it describes).
  DataExtractor rangesData(getRangeSection(), isLittleEndian(),
                           savedAddressByteSize);
  offset = 0;
  DWARFDebugRangeList rangeList;
  while (rangeList.extract(rangesData, &offset))
    rangeList.dump(OS);
}
开发者ID:guoqingzhang,项目名称:llvm-coffee,代码行数:52,代码来源:DWARFContext.cpp

示例12: Clear

//----------------------------------------------------------------------
// Generate
//----------------------------------------------------------------------
bool DWARFDebugAranges::Generate(SymbolFileDWARF *dwarf2Data) {
  Clear();
  DWARFDebugInfo *debug_info = dwarf2Data->DebugInfo();
  if (debug_info) {
    uint32_t cu_idx = 0;
    const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
    for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
      DWARFCompileUnit *cu = debug_info->GetCompileUnitAtIndex(cu_idx);
      if (cu)
        cu->BuildAddressRangeTable(dwarf2Data, this);
    }
  }
  return !IsEmpty();
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:17,代码来源:DWARFDebugAranges.cpp

示例13: getCompileUnitForAddress

DILineInfo DWARFContext::getLineInfoForAddress(uint64_t Address,
                                               DILineInfoSpecifier Spec) {
  DILineInfo Result;

  DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
  if (!CU)
    return Result;
  getFunctionNameForAddress(CU, Address, Spec.FNKind, Result.FunctionName);
  if (Spec.FLIKind != FileLineInfoKind::None) {
    if (const DWARFLineTable *LineTable = getLineTableForUnit(CU))
      LineTable->getFileLineInfoForAddress(Address, CU->getCompilationDir(),
                                           Spec.FLIKind, Result);
  }
  return Result;
}
开发者ID:Dagrol,项目名称:llvm,代码行数:15,代码来源:DWARFContext.cpp

示例14: dumpInfo

//----------------------------------------------------------------------
// Dump
//
// Dump the contents of this DWARFDebugInfo object as has been parsed
// and/or modified after it has been parsed.
//----------------------------------------------------------------------
void DWARFDebugInfo::Dump(Stream *s, const uint32_t die_offset,
                          const uint32_t recurse_depth) {
  DumpInfo dumpInfo(s, die_offset, recurse_depth);

  s->PutCString("Dumping .debug_info section from internal representation\n");

  CompileUnitColl::const_iterator pos;
  uint32_t curr_depth = 0;
  ParseCompileUnitHeadersIfNeeded();
  for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) {
    DWARFCompileUnit *cu = pos->get();
    DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo);

    const DWARFDIE die = cu->DIE();
    if (die)
      die.Dump(s, recurse_depth);
  }
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:24,代码来源:DWARFDebugInfo.cpp

示例15: log

DWARFDebugAranges &
DWARFDebugInfo::GetCompileUnitAranges ()
{
    if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
    {
        LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));

        m_cu_aranges_ap.reset (new DWARFDebugAranges());
        const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();
        if (debug_aranges_data.GetByteSize() > 0)
        {
            if (log)
                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" from .debug_aranges", 
                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString());
            m_cu_aranges_ap->Extract (debug_aranges_data);
            
        }
        else
        {
            if (log)
                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" by parsing", 
                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString());
            const uint32_t num_compile_units = GetNumCompileUnits();
            uint32_t idx;
            const bool clear_dies_if_already_not_parsed = true;
            for (idx = 0; idx < num_compile_units; ++idx)
            {
                DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
                if (cu)
                    cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
            }
        }

        const bool minimize = true;
        m_cu_aranges_ap->Sort (minimize);
    }
    return *m_cu_aranges_ap.get();
}
开发者ID:filcab,项目名称:lldb,代码行数:40,代码来源:DWARFDebugInfo.cpp


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