Beispiel #1
0
bool
UnwindPlan::PlanValidAtAddress (Address addr)
{
    // If this UnwindPlan has no rows, it is an invalid UnwindPlan.
    if (GetRowCount() == 0)
    {
        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
        if (log)
        {
            StreamString s;
            if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
            {
                log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s' at address %s",
                             m_source_name.GetCString(), s.GetData());
            }
            else
            {
                log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
                             m_source_name.GetCString());
            }
        }
        return false;
    }

    // If the 0th Row of unwind instructions is missing, or if it doesn't provide
    // a register to use to find the Canonical Frame Address, this is not a valid UnwindPlan.
    if (GetRowAtIndex(0).get() == nullptr ||
            GetRowAtIndex(0)->GetCFAValue().GetValueType() == Row::CFAValue::unspecified)
    {
        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
        if (log)
        {
            StreamString s;
            if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
            {
                log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s' at address %s",
                             m_source_name.GetCString(), s.GetData());
            }
            else
            {
                log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s'",
                             m_source_name.GetCString());
            }
        }
        return false;
    }

    if (!m_plan_valid_address_range.GetBaseAddress().IsValid() || m_plan_valid_address_range.GetByteSize() == 0)
        return true;

    if (!addr.IsValid())
        return true;

    if (m_plan_valid_address_range.ContainsFileAddress (addr))
        return true;

    return false;
}
Beispiel #2
0
void
SymbolContext::DumpStopContext
(
    Stream *s,
    ExecutionContextScope *exe_scope,
    const Address &addr,
    bool show_module
) const
{
    if (show_module && module_sp)
    {
        *s << module_sp->GetFileSpec().GetFilename() << '`';
    }

    if (function != NULL)
    {
        if (function->GetMangled().GetName())
            function->GetMangled().GetName().Dump(s);

        const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
        if (function_offset)
            s->Printf(" + %llu", function_offset);

        if (block != NULL)
        {
            s->IndentMore();
            block->DumpStopContext(s, this);
            s->IndentLess();
        }
        else
        {
            if (line_entry.IsValid())
            {
                s->PutCString(" at ");
                if (line_entry.DumpStopContext(s))
                    return;
            }
        }
    }
    else if (symbol != NULL)
    {
        symbol->GetMangled().GetName().Dump(s);

        if (symbol->GetAddressRangePtr())
        {
            const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset();
            if (symbol_offset)
                s->Printf(" + %llu", symbol_offset);
        }
    }
    else
    {
        addr.Dump(s, exe_scope, Address::DumpStyleModuleWithFileAddress);
    }
}
Beispiel #3
0
bool
CompactUnwindInfo::GetUnwindPlan (Target &target, Address addr, UnwindPlan& unwind_plan)
{
    if (!IsValid (target.GetProcessSP()))
    {
        return false;
    }
    FunctionInfo function_info;
    if (GetCompactUnwindInfoForFunction (target, addr, function_info))
    {
        // shortcut return for functions that have no compact unwind
        if (function_info.encoding == 0)
            return false;

        ArchSpec arch;
        if (m_objfile.GetArchitecture (arch))
        {

            Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
            if (log && log->GetVerbose())
            {
                StreamString strm;
                addr.Dump (&strm, NULL, Address::DumpStyle::DumpStyleResolvedDescriptionNoFunctionArguments, Address::DumpStyle::DumpStyleFileAddress, arch.GetAddressByteSize()); 
                log->Printf ("Got compact unwind encoding 0x%x for function %s", function_info.encoding, strm.GetData());
            }

            if (function_info.valid_range_offset_start != 0 && function_info.valid_range_offset_end != 0)
            {
                SectionList *sl = m_objfile.GetSectionList ();
                if (sl)
                {
                    addr_t func_range_start_file_addr = 
                              function_info.valid_range_offset_start + m_objfile.GetHeaderAddress().GetFileAddress();
                    AddressRange func_range (func_range_start_file_addr,
                                      function_info.valid_range_offset_end - function_info.valid_range_offset_start,
                                      sl);
                    unwind_plan.SetPlanValidAddressRange (func_range);
                }
            }

            if (arch.GetTriple().getArch() == llvm::Triple::x86_64)
            {
                return CreateUnwindPlan_x86_64 (target, function_info, unwind_plan, addr);
            }
            if (arch.GetTriple().getArch() == llvm::Triple::x86)
            {
                return CreateUnwindPlan_i386 (target, function_info, unwind_plan, addr);
            }
        }
    }
    return false;
}
bool
SymbolContext::DumpStopContext
(
    Stream *s,
    ExecutionContextScope *exe_scope,
    const Address &addr,
    bool show_fullpaths,
    bool show_module,
    bool show_inlined_frames
) const
{
    bool dumped_something = false;
    if (show_module && module_sp)
    {
        if (show_fullpaths)
            *s << module_sp->GetFileSpec();
        else
            *s << module_sp->GetFileSpec().GetFilename();
        s->PutChar('`');
        dumped_something = true;
    }

    if (function != NULL)
    {
        SymbolContext inline_parent_sc;
        Address inline_parent_addr;
        if (function->GetMangled().GetName())
        {
            dumped_something = true;
            function->GetMangled().GetName().Dump(s);
        }
        
        if (addr.IsValid())
        {
            const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
            if (function_offset)
            {
                dumped_something = true;
                s->Printf(" + %" PRIu64, function_offset);
            }
        }

        if (GetParentOfInlinedScope (addr, inline_parent_sc, inline_parent_addr))
        {
            dumped_something = true;
            Block *inlined_block = block->GetContainingInlinedBlock();
            const InlineFunctionInfo* inlined_block_info = inlined_block->GetInlinedFunctionInfo();
            s->Printf (" [inlined] %s", inlined_block_info->GetName().GetCString());
            
            lldb_private::AddressRange block_range;
            if (inlined_block->GetRangeContainingAddress(addr, block_range))
            {
                const addr_t inlined_function_offset = addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
                if (inlined_function_offset)
                {
                    s->Printf(" + %" PRIu64, inlined_function_offset);
                }
            }
            const Declaration &call_site = inlined_block_info->GetCallSite();
            if (call_site.IsValid())
            {
                s->PutCString(" at ");
                call_site.DumpStopContext (s, show_fullpaths);
            }
            if (show_inlined_frames)
            {
                s->EOL();
                s->Indent();
                return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames);
            }
        }
        else
        {
            if (line_entry.IsValid())
            {
                dumped_something = true;
                s->PutCString(" at ");
                if (line_entry.DumpStopContext(s, show_fullpaths))
                    dumped_something = true;
            }
        }
    }
    else if (symbol != NULL)
    {
        if (symbol->GetMangled().GetName())
        {
            dumped_something = true;
            if (symbol->GetType() == eSymbolTypeTrampoline)
                s->PutCString("symbol stub for: ");
            symbol->GetMangled().GetName().Dump(s);
        }

        if (addr.IsValid() && symbol->ValueIsAddress())
        {
            const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddress().GetOffset();
            if (symbol_offset)
            {
                dumped_something = true;
                s->Printf(" + %" PRIu64, symbol_offset);
            }
        }
    }
    else if (addr.IsValid())
    {
        addr.Dump(s, exe_scope, Address::DumpStyleModuleWithFileAddress);
        dumped_something = true;
    }
    return dumped_something;
}