Ejemplo n.º 1
0
bool
CrashInfo::GatherCrashInfo(const char* pszExePath, MINIDUMP_TYPE minidumpType)
{
    // Get the process info
    if (!GetStatus(m_pid, &m_ppid, &m_tgid, &m_name))
    {
        return false;
    }
    // Get the info about the threads (registers, etc.)
    for (ThreadInfo* thread : m_threads)
    {
        if (!thread->Initialize())
        {
            return false;
        }
    }
    // Get the auxv data
    if (!GetAuxvEntries())
    {
        return false;
    }
    // Get shared module debug info
    if (!GetDSOInfo())
    {
        return false;
    }
    // Gather all the module memory mappings (from /dev/$pid/maps)
    if (!EnumerateModuleMappings())
    {
        return false;
    }
    // Gather all the useful memory regions from the DAC
    if (!EnumerateMemoryRegionsWithDAC(pszExePath, minidumpType))
    {
        return false;
    }
    // Add the thread's stack and some code memory to core
    for (ThreadInfo* thread : m_threads)
    {
        uint64_t start;
        size_t size;

        // Add the thread's stack and some of the code 
        thread->GetThreadStack(*this, &start, &size); 
        InsertMemoryRegion(start, size);

        thread->GetThreadCode(&start, &size);
        InsertMemoryRegion(start, size);
    }
    // Join all adjacent memory regions
    CombineMemoryRegions();
    return true;
}
Ejemplo n.º 2
0
bool
CrashInfo::GatherCrashInfo(const char* programPath, MINIDUMP_TYPE minidumpType)
{
    // Get the process info
    if (!GetStatus(m_pid, &m_ppid, &m_tgid, &m_name))
    {
        return false;
    }
    // Get the info about the threads (registers, etc.)
    for (ThreadInfo* thread : m_threads)
    {
        if (!thread->Initialize(m_sos ? m_dataTarget : nullptr))
        {
            return false;
        }
    }
    // Get the auxv data
    if (!GetAuxvEntries())
    {
        return false;
    }
    // Gather all the module memory mappings (from /dev/$pid/maps)
    if (!EnumerateModuleMappings())
    {
        return false;
    }
    // Get shared module debug info
    if (!GetDSOInfo())
    {
        return false;
    }
    // If full memory dump, include everything regardless of permissions
    if (minidumpType & MiniDumpWithFullMemory)
    {
       for (const MemoryRegion& region : m_moduleMappings)
       {
            if (ValidRegion(region))
            {
                InsertMemoryRegion(region);
            }
        }
        for (const MemoryRegion& region : m_otherMappings)
        {
            if (ValidRegion(region))
            {
                InsertMemoryRegion(region);
            }
        }
    }
    else
    {
        // Add all the heap (read/write) memory regions but not the modules' r/w data segments
        if (minidumpType & MiniDumpWithPrivateReadWriteMemory)
        {
            for (const MemoryRegion& region : m_otherMappings)
            {
                if (region.Permissions() == (PF_R | PF_W))
                {
                    if (ValidRegion(region))
                    {
                        InsertMemoryRegion(region);
                    }
                }
            }
        }
        // Gather all the useful memory regions from the DAC
        if (!EnumerateMemoryRegionsWithDAC(programPath, minidumpType))
        {
            return false;
        }
        // Add the thread's stack and some code memory to core
        for (ThreadInfo* thread : m_threads)
        {
            uint64_t start;
            size_t size;

            // Add the thread's stack and some of the code 
            thread->GetThreadStack(*this, &start, &size);
            InsertMemoryRegion(start, size);

            thread->GetThreadCode(&start, &size);
            InsertMemoryRegion(start, size);
        }
    }
    // Join all adjacent memory regions
    CombineMemoryRegions();
    return true;
}