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


C++ MatchResults::push_back方法代码示例

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


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

示例1: if

static void
range_info_callback (task_t task, void *baton, unsigned type, uint64_t ptr_addr, uint64_t ptr_size)
{
    const uint64_t end_addr = ptr_addr + ptr_size;
    
    range_contains_data_callback_info_t *info = (range_contains_data_callback_info_t *)baton;
    switch (info->type)
    {
    case eDataTypeAddress:
        // Check if the current malloc block contains an address specified by "info->addr"
        if (ptr_addr <= info->addr && info->addr < end_addr)
        {
            ++info->match_count;
            malloc_match match = { (void *)ptr_addr, ptr_size, info->addr - ptr_addr, type };
            g_matches.push_back(match, info->unique);
        }
        break;
    
    case eDataTypeContainsData:
        // Check if the current malloc block contains data specified in "info->data"
        {
            const uint32_t size = info->data.size;
            if (size < ptr_size) // Make sure this block can contain this data
            {
                uint8_t *ptr_data = NULL;
                if (task_peek (task, ptr_addr, ptr_size, (void **)&ptr_data) == KERN_SUCCESS)
                {
                    const void *buffer = info->data.buffer;
                    assert (ptr_data);
                    const uint32_t align = info->data.align;
                    for (uint64_t addr = ptr_addr; 
                         addr < end_addr && ((end_addr - addr) >= size);
                         addr += align, ptr_data += align)
                    {
                        if (memcmp (buffer, ptr_data, size) == 0)
                        {
                            ++info->match_count;
                            malloc_match match = { (void *)ptr_addr, ptr_size, addr - ptr_addr, type };
                            g_matches.push_back(match, info->unique);
                        }
                    }
                }
                else
                {
                    printf ("0x%llx: error: couldn't read %llu bytes\n", ptr_addr, ptr_size);
                }   
            }
        }
        break;
    
    case eDataTypeObjC:
        // Check if the current malloc block contains an objective C object
        // of any sort where the first pointer in the object is an OBJC class
        // pointer (an isa)
        {
            malloc_block_contents *block_contents = NULL;
            if (task_peek (task, ptr_addr, sizeof(void *), (void **)&block_contents) == KERN_SUCCESS)
            {
                // We assume that g_objc_classes is up to date
                // that the class list was verified to have some classes in it
                // before calling this function
                const uint32_t objc_class_idx = g_objc_classes.FindClassIndex (block_contents->isa);
                if (objc_class_idx != UINT32_MAX)
                {
                    bool match = false;
                    if (info->objc.match_isa == 0)
                    {
                        // Match any objective C object
                        match = true;
                    }
                    else 
                    {
                        // Only match exact isa values in the current class or
                        // optionally in the super classes
                        if (info->objc.match_isa == block_contents->isa)
                            match = true;
                        else if (info->objc.match_superclasses)
                        {
                            Class super = class_getSuperclass(block_contents->isa);
                            while (super)
                            {
                                match = super == info->objc.match_isa;
                                if (match)
                                    break;
                                super = class_getSuperclass(super);
                            }
                        }
                    }
                    if (match)
                    {
                        //printf (" success\n");
                        ++info->match_count;
                        malloc_match match = { (void *)ptr_addr, ptr_size, 0, type };
                        g_matches.push_back(match, info->unique);
                    }
                    else
                    {
                        //printf (" error: wrong class: %s\n", dl_info.dli_sname);                        
                    }
                }
//.........这里部分代码省略.........
开发者ID:32bitmicro,项目名称:riscv-lldb,代码行数:101,代码来源:heap_find.cpp


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