Beispiel #1
0
bool
SymbolContext::DumpStopContext (
    Stream *s,
    ExecutionContextScope *exe_scope,
    const Address &addr,
    bool show_fullpaths,
    bool show_module,
    bool show_inlined_frames,
    bool show_function_arguments,
    bool show_function_name
) 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 != nullptr)
    {
        SymbolContext inline_parent_sc;
        Address inline_parent_addr;
        if (show_function_name == false)
        {
            s->Printf("<");
            dumped_something = true;
        }
        else
        {
            ConstString name;
            if (show_function_arguments == false)
                name = function->GetNameNoArguments();
            if (!name)
                name = function->GetName();
            if (name)
                name.Dump(s);
        }
        
        if (addr.IsValid())
        {
            const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
            if (show_function_name == false)
            {
                // Print +offset even if offset is 0
                dumped_something = true;
                s->Printf("+%" PRIu64 ">", function_offset);
            }
            else 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(function->GetLanguage()).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();
                const bool show_function_name = true;
                return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name);
            }
        }
        else
        {
            if (line_entry.IsValid())
            {
                dumped_something = true;
                s->PutCString(" at ");
                if (line_entry.DumpStopContext(s, show_fullpaths))
                    dumped_something = true;
            }
        }
    }
    else if (symbol != nullptr)
    {
        if (show_function_name == false)
        {
            s->Printf("<");
            dumped_something = true;
        }
        else if (symbol->GetName())
        {
            dumped_something = true;
            if (symbol->GetType() == eSymbolTypeTrampoline)
                s->PutCString("symbol stub for: ");
            symbol->GetName().Dump(s);
        }

        if (addr.IsValid() && symbol->ValueIsAddress())
        {
            const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRef().GetOffset();
            if (show_function_name == false)
            {
                // Print +offset even if offset is 0
                dumped_something = true;
                s->Printf("+%" PRIu64 ">", symbol_offset);
            }
            else 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;
}