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


C++ TargetInfo::ReadMemoryPtr方法代码示例

本文整理汇总了C++中TargetInfo::ReadMemoryPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetInfo::ReadMemoryPtr方法的具体用法?C++ TargetInfo::ReadMemoryPtr怎么用?C++ TargetInfo::ReadMemoryPtr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TargetInfo的用法示例。


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

示例1: DumpCCS

void DumpCCS(const TargetInfo& ti, target_ptr_t ccs, uint32_t starting_depth)
{
    // Traverse and print the passed Cost Center Stack
    for (unsigned int depth=starting_depth; depth<64; depth++) 
    {
        Indent(depth);

        // Get CC pointer from CCS
        const target_ptr_t cc = ti.ReadMemoryPtr(ccs + OFFSET_ConstCentreStack_cc);
        if (cc == 0)
        {
            std::printf("(Can't read CC pointer)\n");
            break;
        }

        // Retrieve symbol information from CC
        const target_ptr_t label_ptr  = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_label);
        const target_ptr_t module_ptr = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_module);
        const target_ptr_t srcloc_ptr = ti.ReadMemoryPtr(cc + OFFSET_ConstCentre_srcloc);
        char label[256], module[256], srcloc[256];
        if (ti.ReadMemoryString(label_ptr, label, sizeof(label)) == false)
            std::strcpy(label, "(can't read label)");
        if (ti.ReadMemoryString(module_ptr, module, sizeof(module)) == false)
            std::strcpy(module, "(can't read module)");
        if (ti.ReadMemoryString(srcloc_ptr, srcloc, sizeof(srcloc)) == false)
            std::strcpy(srcloc, "(can't read srcloc)");
        std::printf("CCS:0x%x <%s> from %s (%s)\n", ccs, label, module, srcloc);

        // Walk the CC stack
        ccs = ti.ReadMemoryPtr(ccs + OFFSET_ConstCentreStack_prevStack);
        if (ccs == 0)
            break;
    }
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:34,代码来源:ghd.cpp

示例2: DumpSTG

void DumpSTG(
    const TargetInfo& ti,
    SymbolManager *symbol,
    target_ptr_t sp,
    uint32_t starting_depth)
{
    // TODO: See GHC's 'Printer.c' on how we could print more information about what's on
    //       the stack

    // Traverse and print the passed STG stack
    for (unsigned int depth=starting_depth; depth<128; depth++) 
    {
        // Top closure
        const target_ptr_t info = ti.ReadMemoryPtr(sp);
        const uint32_t sym_id = symbol->AddressToSymbolID(info);

        Indent(depth);

        // Let our wrapper collect the required information
        uint32_t closure_type, closure_size;
        target_ptr_t fun_ref;
        if (GetClosureTypeAndSize(ti.m_task_port, sp, &closure_type, &closure_size, &fun_ref) != 0)
        {
            std::printf("0x%x (Can't read stack frame)\n", sp);
            break;
        }

        // Referenced closure
        char ref_buf[256] = { 0 };
        if (fun_ref != 0)
        {
            std::snprintf(
                ref_buf,
                sizeof(ref_buf),
                ", <%s>",
                symbol->SymbolIDToName(symbol->AddressToSymbolID(ti.ReadMemoryPtr(fun_ref))));
        }

        std::printf("0x%x <%s> (%s, %ib%s)\n",
            sp,
            symbol->SymbolIDToName(sym_id),
            ClosureTypeToString(closure_type),
            closure_size,
            ref_buf);

        if (closure_type == wrapper_STOP_FRAME)
            break;

        // TODO: Handle underflow frames
        if (closure_type == wrapper_UNDERFLOW_FRAME)
            break;

        sp += closure_size;
    }
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:55,代码来源:ghd.cpp

示例3: CCSPtrFromTopOfStack

target_ptr_t CCSPtrFromTopOfStack(const TargetInfo& ti, target_ptr_t sp_reg)
{
    return ti.ReadMemoryPtr
        (sp_reg + OFFSET_StgClosure_header + OFFSET_StgHeader_prof + OFFSET_StgProfHeader_ccs);
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:5,代码来源:ghd.cpp

示例4: CCSPtrFromBaseReg

// Get a Cost Center Stack pointer from either the base register or the STG stack pointer
target_ptr_t CCSPtrFromBaseReg(const TargetInfo& ti, target_ptr_t base_reg)
{
    return ti.ReadMemoryPtr(base_reg + OFFSET_StgRegTable_rCCCS);
}
开发者ID:blitzcode,项目名称:ghc-stack,代码行数:5,代码来源:ghd.cpp


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