~ubuntu-branches/ubuntu/natty/virtualbox-ose/natty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/r3/solaris/coredumper-solaris.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-10-15 02:12:28 UTC
  • mfrom: (0.3.10 upstream) (0.4.19 sid)
  • Revision ID: james.westby@ubuntu.com-20101015021228-5e6vbxgtes8mg189
Tags: 3.2.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - VirtualBox should go in Accessories, not in System tools.
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add ubuntu-01-fix-build-gcc45.patch to fix FTBFS due to uninitalized
  variables. Thanks to Lubomir Rintel <lkundrak@v3.sk> for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: coredumper-solaris.h $ */
 
2
/** @file
 
3
 * IPRT Testcase - Core dump, header.
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 2010 Oracle Corporation
 
8
 *
 
9
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
10
 * available from http://www.virtualbox.org. This file is free software;
 
11
 * you can redistribute it and/or modify it under the terms of the GNU
 
12
 * General Public License (GPL) as published by the Free Software
 
13
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
14
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
15
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
16
 *
 
17
 * The contents of this file may alternatively be used under the terms
 
18
 * of the Common Development and Distribution License Version 1.0
 
19
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 
20
 * VirtualBox OSE distribution, in which case the provisions of the
 
21
 * CDDL are applicable instead of those of the GPL.
 
22
 *
 
23
 * You may elect to license modified versions of this file under the
 
24
 * terms and conditions of either the GPL or the CDDL or both.
 
25
 */
 
26
 
 
27
#include <iprt/process.h>
 
28
#include <iprt/file.h>
 
29
 
 
30
#ifdef RT_OS_SOLARIS
 
31
# if defined(RT_ARCH_X86) && _FILE_OFFSET_BITS==64
 
32
/*
 
33
 * Solaris' procfs cannot be used with large file environment in 32-bit.
 
34
 */
 
35
# undef _FILE_OFFSET_BITS
 
36
# define _FILE_OFFSET_BITS 32
 
37
# include <procfs.h>
 
38
# include <sys/procfs.h>
 
39
# include <sys/old_procfs.h>
 
40
# undef _FILE_OFFSET_BITS
 
41
# define _FILE_OFFSET_BITS 64
 
42
#else
 
43
# include <procfs.h>
 
44
# include <sys/procfs.h>
 
45
# include <sys/old_procfs.h>
 
46
#endif
 
47
# include <limits.h>
 
48
# include <thread.h>
 
49
# include <sys/auxv.h>
 
50
# include <sys/lwp.h>
 
51
# include <sys/zone.h>
 
52
# include <sys/utsname.h>
 
53
 
 
54
#ifdef RT_ARCH_AMD64
 
55
# define _ELF64
 
56
# undef _ELF32_COMPAT
 
57
#endif
 
58
# include <sys/corectl.h>
 
59
#endif
 
60
 
 
61
 
 
62
#ifdef RT_OS_SOLARIS
 
63
/**
 
64
 * VBOXSOLMAPINFO: Memory mapping description.
 
65
 */
 
66
typedef struct VBOXSOLMAPINFO
 
67
{
 
68
    prmap_t                         pMap;                       /* Proc description of this mapping */
 
69
    int                             fError;                     /* Any error reading this mapping (errno) */
 
70
    struct VBOXSOLMAPINFO          *pNext;                      /* Pointer to the next mapping */
 
71
} VBOXSOLMAPINFO;
 
72
typedef VBOXSOLMAPINFO *PVBOXSOLMAPINFO;
 
73
 
 
74
/**
 
75
 * VBOXSOLCORETYPE: Whether this is an old or new style core.
 
76
 */
 
77
typedef enum VBOXSOLCORETYPE
 
78
{
 
79
    enmOldEra       = 0x01d,        /* old */
 
80
    enmNewEra       = 0x5c1f1       /* sci-fi */
 
81
} VBOXSOLCORETYPE;
 
82
 
 
83
/**
 
84
 * VBOXSOLTHREADINFO: Per-Thread information.
 
85
 */
 
86
typedef struct VBOXSOLTHREADINFO
 
87
{
 
88
    lwpsinfo_t                      Info;                       /* Proc description of this thread */
 
89
    lwpstatus_t                    *pStatus;                    /* Proc description of this thread's status (can be NULL, zombie lwp) */
 
90
    struct VBOXSOLTHREADINFO       *pNext;                      /* Pointer to the next thread */
 
91
} VBOXSOLTHREADINFO;
 
92
typedef VBOXSOLTHREADINFO *PVBOXSOLTHREADINFO;
 
93
#endif
 
94
 
 
95
 
 
96
/**
 
97
 * VBOXPROCESS: Current (also the core target) process information.
 
98
 */
 
99
typedef struct VBOXPROCESS
 
100
{
 
101
    RTPROCESS                       Process;                    /* The pid of the process */
 
102
    char                            szExecPath[PATH_MAX];       /* Path of the executable */
 
103
    char                           *pszExecName;                /* Name of the executable file */
 
104
#ifdef RT_OS_SOLARIS
 
105
    psinfo_t                        ProcInfo;                   /* Process info. */
 
106
    prpsinfo_t                      ProcInfoOld;                /* Process info. Older version (for GDB compat.) */
 
107
    pstatus_t                       ProcStatus;                 /* Process status info. */
 
108
    thread_t                        hCurThread;                 /* The current thread */
 
109
    ucontext_t                     *pCurThreadCtx;              /* Context info. of current thread before starting to dump */
 
110
    RTFILE                          hAs;                        /* proc/<pid/as file handle */
 
111
    auxv_t                         *pAuxVecs;                   /* Aux vector of process */
 
112
    int                             cAuxVecs;                   /* Number of aux vector entries */
 
113
    PVBOXSOLMAPINFO                 pMapInfoHead;               /* Pointer to the head of list of mappings */
 
114
    uint32_t                        cMappings;                  /* Number of mappings (count of pMapInfoHead list) */
 
115
    PVBOXSOLTHREADINFO              pThreadInfoHead;            /* Pointer to the head of list of threads */
 
116
    uint64_t                        cThreads;                   /* Number of threads (count of pThreadInfoHead list) */
 
117
    char                            szPlatform[SYS_NMLN];       /* Platform name  */
 
118
    char                            szZoneName[ZONENAME_MAX];   /* Zone name */
 
119
    struct utsname                  UtsName;                    /* UTS name */
 
120
    void                           *pvCred;                     /* Process credential info. */
 
121
    size_t                          cbCred;                     /* Size of process credential info. */
 
122
    void                           *pvLdt;                      /* Process LDT info. */
 
123
    size_t                          cbLdt;                      /* Size of the LDT info. */
 
124
    prpriv_t                       *pPriv;                      /* Process privilege info. */
 
125
    size_t                          cbPriv;                     /* Size of process privilege info. */
 
126
    const priv_impl_info_t         *pcPrivImpl;                 /* Process privilege implementation info. (opaque handle) */
 
127
    core_content_t                  CoreContent;                /* What information goes in the core */
 
128
#else
 
129
# error Port Me!
 
130
#endif
 
131
 
 
132
} VBOXPROCESS;
 
133
typedef VBOXPROCESS *PVBOXPROCESS;
 
134
 
 
135
typedef int (*PFNCOREREADER)(RTFILE hFile, void *pv, size_t cb);
 
136
typedef int (*PFNCOREWRITER)(RTFILE hFile, const void *pcv, size_t cb);
 
137
 
 
138
/**
 
139
 * VBOXCORE: Core file object.
 
140
 */
 
141
typedef struct VBOXCORE
 
142
{
 
143
    char                            szCorePath[PATH_MAX];       /* Path of the core file */
 
144
    VBOXPROCESS                     VBoxProc;                   /* Current process information */
 
145
    void                           *pvCore;                     /* Pointer to memory area during dumping */
 
146
    size_t                          cbCore;                     /* Size of memory area during dumping */
 
147
    void                           *pvFree;                     /* Pointer to base of free range in preallocated memory area */
 
148
    bool                            fIsValid;                   /* Whether core information has been fully collected */
 
149
    PFNCOREREADER                   pfnReader;                  /* Reader function */
 
150
    PFNCOREWRITER                   pfnWriter;                  /* Writer function */
 
151
    RTFILE                          hCoreFile;                  /* Core file (used only while writing the core) */
 
152
    RTFOFF                          offWrite;                   /* Segment/section offset (used only while writing the core) */
 
153
} VBOXCORE;
 
154
typedef VBOXCORE *PVBOXCORE;
 
155
 
 
156
typedef int (*PFNCOREACCUMULATOR)(PVBOXCORE pVBoxCore);
 
157
typedef int (*PFNCORETHREADWORKER)(PVBOXCORE pVBoxCore, void *pvThreadInfo);
 
158