coredumper-solaris.h revision 5330cda3253fc3d94ed03a7609774e8c85a4c56d
38856343f90103280eb83b5e697f9f618b407d83vboxsync/* $Id$ */
38856343f90103280eb83b5e697f9f618b407d83vboxsync/** @file
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * IPRT Testcase - Core dump, header.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync/*
38856343f90103280eb83b5e697f9f618b407d83vboxsync * Copyright (C) 2010 Oracle Corporation
38856343f90103280eb83b5e697f9f618b407d83vboxsync *
38856343f90103280eb83b5e697f9f618b407d83vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
38856343f90103280eb83b5e697f9f618b407d83vboxsync * available from http://www.virtualbox.org. This file is free software;
38856343f90103280eb83b5e697f9f618b407d83vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c97989161fbe75bc14cea477a5443bbf474dd3advboxsync * General Public License (GPL) as published by the Free Software
38856343f90103280eb83b5e697f9f618b407d83vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
38856343f90103280eb83b5e697f9f618b407d83vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
38856343f90103280eb83b5e697f9f618b407d83vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
38856343f90103280eb83b5e697f9f618b407d83vboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * The contents of this file may alternatively be used under the terms
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * of the Common Development and Distribution License Version 1.0
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution, in which case the provisions of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * CDDL are applicable instead of those of the GPL.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * You may elect to license modified versions of this file under the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * terms and conditions of either the GPL or the CDDL or both.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync */
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync#include <iprt/process.h>
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync#include <iprt/file.h>
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync#ifdef RT_OS_SOLARIS
38856343f90103280eb83b5e697f9f618b407d83vboxsync# if defined(RT_ARCH_X86) && _FILE_OFFSET_BITS==64
38856343f90103280eb83b5e697f9f618b407d83vboxsync/*
38856343f90103280eb83b5e697f9f618b407d83vboxsync * Solaris' procfs cannot be used with large file environment in 32-bit.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsync# undef _FILE_OFFSET_BITS
38856343f90103280eb83b5e697f9f618b407d83vboxsync# define _FILE_OFFSET_BITS 32
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/old_procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# undef _FILE_OFFSET_BITS
a4d7fc6f54717c342281099fe14f5666be9b7921vboxsync# define _FILE_OFFSET_BITS 64
38856343f90103280eb83b5e697f9f618b407d83vboxsync#else
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/old_procfs.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync#endif
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <limits.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <thread.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/auxv.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/lwp.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/zone.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/utsname.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync
e227a95dad8aed081c9325091111832ed02ab41avboxsync#ifdef RT_ARCH_AMD64
38856343f90103280eb83b5e697f9f618b407d83vboxsync# define _ELF64
38856343f90103280eb83b5e697f9f618b407d83vboxsync# undef _ELF32_COMPAT
38856343f90103280eb83b5e697f9f618b407d83vboxsync#endif
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/machelf.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync# include <sys/corectl.h>
38856343f90103280eb83b5e697f9f618b407d83vboxsync#endif
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync/**
38856343f90103280eb83b5e697f9f618b407d83vboxsync * ELFNOTEHDR: ELF NOTE header.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef struct ELFNOTEHDR
38856343f90103280eb83b5e697f9f618b407d83vboxsync{
38856343f90103280eb83b5e697f9f618b407d83vboxsync Nhdr Hdr; /* Header of NOTE section */
38856343f90103280eb83b5e697f9f618b407d83vboxsync char achName[8]; /* Name of NOTE section */
38856343f90103280eb83b5e697f9f618b407d83vboxsync} ELFNOTEHDR;
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef ELFNOTEHDR *PELFNOTEHDR;
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync#ifdef RT_OS_SOLARIS
38856343f90103280eb83b5e697f9f618b407d83vboxsync/**
38856343f90103280eb83b5e697f9f618b407d83vboxsync * VBOXSOLMAPINFO: Memory mapping description.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef struct VBOXSOLMAPINFO
38856343f90103280eb83b5e697f9f618b407d83vboxsync{
38856343f90103280eb83b5e697f9f618b407d83vboxsync prmap_t pMap; /* Proc description of this mapping */
38856343f90103280eb83b5e697f9f618b407d83vboxsync int fError; /* Any error reading this mapping (errno) */
38856343f90103280eb83b5e697f9f618b407d83vboxsync struct VBOXSOLMAPINFO *pNext; /* Pointer to the next mapping */
428abad07de993cca3284d577dc65f3b1acd17d5vboxsync} VBOXSOLMAPINFO;
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef VBOXSOLMAPINFO *PVBOXSOLMAPINFO;
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync/**
38856343f90103280eb83b5e697f9f618b407d83vboxsync * VBOXSOLCORETYPE: Whether this is an old or new style core.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef enum VBOXSOLCORETYPE
38856343f90103280eb83b5e697f9f618b407d83vboxsync{
38856343f90103280eb83b5e697f9f618b407d83vboxsync enmOldEra = 0x01d, /* old */
38856343f90103280eb83b5e697f9f618b407d83vboxsync enmNewEra = 0x5c151 /* sci-fi */
38856343f90103280eb83b5e697f9f618b407d83vboxsync} VBOXSOLCORETYPE;
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync/**
38856343f90103280eb83b5e697f9f618b407d83vboxsync * VBOXSOLTHREADINFO: Per-Thread information.
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsynctypedef struct VBOXSOLTHREADINFO
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync{
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync lwpsinfo_t Info; /* Proc description of this thread */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync lwpstatus_t *pStatus; /* Proc description of this thread's status (can be NULL, zombie lwp) */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync struct VBOXSOLTHREADINFO *pNext; /* Pointer to the next thread */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync} VBOXSOLTHREADINFO;
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsynctypedef VBOXSOLTHREADINFO *PVBOXSOLTHREADINFO;
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync#endif
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync/**
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync * VBOXPROCESS: Current (also the core target) process information.
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef struct VBOXPROCESS
38856343f90103280eb83b5e697f9f618b407d83vboxsync{
38856343f90103280eb83b5e697f9f618b407d83vboxsync RTPROCESS Process; /* The pid of the process */
38856343f90103280eb83b5e697f9f618b407d83vboxsync char szExecPath[PATH_MAX]; /* Path of the executable */
38856343f90103280eb83b5e697f9f618b407d83vboxsync char *pszExecName; /* Name of the executable file */
38856343f90103280eb83b5e697f9f618b407d83vboxsync#ifdef RT_OS_SOLARIS
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync psinfo_t ProcInfo; /* Process info. */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync prpsinfo_t ProcInfoOld; /* Process info. Older version (for GDB compat.) */
38856343f90103280eb83b5e697f9f618b407d83vboxsync pstatus_t ProcStatus; /* Process status info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync thread_t hCurThread; /* The current thread */
b0553043536ae0bdf9921b91597f9dc6c316b1b4vboxsync ucontext_t *pCurThreadCtx; /* Context info. of current thread before starting to dump */
38856343f90103280eb83b5e697f9f618b407d83vboxsync RTFILE hAs; /* proc/<pid/as file handle */
38856343f90103280eb83b5e697f9f618b407d83vboxsync auxv_t *pAuxVecs; /* Aux vector of process */
38856343f90103280eb83b5e697f9f618b407d83vboxsync int cAuxVecs; /* Number of aux vector entries */
38856343f90103280eb83b5e697f9f618b407d83vboxsync PVBOXSOLMAPINFO pMapInfoHead; /* Pointer to the head of list of mappings */
38856343f90103280eb83b5e697f9f618b407d83vboxsync uint32_t cMappings; /* Number of mappings (count of pMapInfoHead list) */
38856343f90103280eb83b5e697f9f618b407d83vboxsync PVBOXSOLTHREADINFO pThreadInfoHead; /* Pointer to the head of list of threads */
38856343f90103280eb83b5e697f9f618b407d83vboxsync uint64_t cThreads; /* Number of threads (count of pThreadInfoHead list) */
38856343f90103280eb83b5e697f9f618b407d83vboxsync char szPlatform[SYS_NMLN]; /* Platform name */
38856343f90103280eb83b5e697f9f618b407d83vboxsync char szZoneName[ZONENAME_MAX]; /* Zone name */
38856343f90103280eb83b5e697f9f618b407d83vboxsync struct utsname UtsName; /* UTS name */
38856343f90103280eb83b5e697f9f618b407d83vboxsync void *pvCred; /* Process credential info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync size_t cbCred; /* Size of process credential info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync void *pvLdt; /* Process LDT info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync size_t cbLdt; /* Size of the LDT info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync prpriv_t *pPriv; /* Process privilege info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync size_t cbPriv; /* Size of process privilege info. */
38856343f90103280eb83b5e697f9f618b407d83vboxsync const priv_impl_info_t *pcPrivImpl; /* Process privilege implementation info. (opaque handle) */
38856343f90103280eb83b5e697f9f618b407d83vboxsync core_content_t CoreContent; /* What information goes in the core */
38856343f90103280eb83b5e697f9f618b407d83vboxsync#else
38856343f90103280eb83b5e697f9f618b407d83vboxsync# error Port Me!
38856343f90103280eb83b5e697f9f618b407d83vboxsync#endif
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync} VBOXPROCESS;
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef VBOXPROCESS *PVBOXPROCESS;
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef int (*PFNCOREREADER)(RTFILE hFile, void *pv, size_t cb);
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef int (*PFNCOREWRITER)(RTFILE hFile, const void *pcv, size_t cb);
38856343f90103280eb83b5e697f9f618b407d83vboxsync
38856343f90103280eb83b5e697f9f618b407d83vboxsync/**
38856343f90103280eb83b5e697f9f618b407d83vboxsync * VBOXCORE: Core file object.
38856343f90103280eb83b5e697f9f618b407d83vboxsync */
38856343f90103280eb83b5e697f9f618b407d83vboxsynctypedef struct VBOXCORE
38856343f90103280eb83b5e697f9f618b407d83vboxsync{
38856343f90103280eb83b5e697f9f618b407d83vboxsync char szCorePath[PATH_MAX]; /* Path of the core file */
VBOXPROCESS VBoxProc; /* Current process information */
void *pvCore; /* Pointer to memory area during dumping */
size_t cbCore; /* Size of memory area during dumping */
void *pvFree; /* Pointer to base of free range in preallocated memory area */
bool fIsValid; /* Whether core information has been fully collected */
PFNCOREREADER pfnReader; /* Reader function */
PFNCOREWRITER pfnWriter; /* Writer function */
RTFILE hCoreFile; /* Core file (used only while writing the core) */
RTFOFF offWrite; /* Segment/section offset (used only while writing the core) */
} VBOXCORE;
typedef VBOXCORE *PVBOXCORE;
typedef int (*PFNCOREACCUMULATOR)(PVBOXCORE pVBoxCore);