VirtualBox

source: vbox/trunk/src/VBox/Runtime/r3/solaris/coredumper-solaris.h@ 103795

Last change on this file since 103795 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.8 KB
Line 
1/* $Id: coredumper-solaris.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Custom Core Dumper, Solaris.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h
38#define IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/types.h>
44
45#ifdef RT_OS_SOLARIS
46# if defined(RT_ARCH_X86) && _FILE_OFFSET_BITS==64
47/*
48 * Solaris' procfs cannot be used with large file environment in 32-bit.
49 */
50# undef _FILE_OFFSET_BITS
51# define _FILE_OFFSET_BITS 32
52# include <procfs.h>
53# include <sys/procfs.h>
54# include <sys/old_procfs.h>
55# undef _FILE_OFFSET_BITS
56# define _FILE_OFFSET_BITS 64
57#else
58# include <procfs.h>
59# include <sys/procfs.h>
60# include <sys/old_procfs.h>
61#endif
62# include <limits.h>
63# include <thread.h>
64# include <sys/auxv.h>
65# include <sys/lwp.h>
66# include <sys/zone.h>
67# include <sys/utsname.h>
68
69#ifdef RT_ARCH_AMD64
70# define _ELF64
71# undef _ELF32_COMPAT
72#endif
73# include <sys/corectl.h>
74#endif
75
76
77#ifdef RT_OS_SOLARIS
78/**
79 * Memory mapping descriptor employed by the solaris core dumper.
80 */
81typedef struct RTSOLCOREMAPINFO
82{
83 prmap_t pMap; /**< Proc description of this mapping */
84 int fError; /**< Any error reading this mapping (errno) */
85 struct RTSOLCOREMAPINFO *pNext; /**< Pointer to the next mapping */
86} RTSOLCOREMAPINFO;
87/** Pointer to a solaris memory mapping descriptor. */
88typedef RTSOLCOREMAPINFO *PRTSOLCOREMAPINFO;
89
90/**
91 * Whether this is an old or new style solaris core.
92 */
93typedef enum RTSOLCORETYPE
94{
95 enmOldEra = 0x01d, /**< old */
96 enmNewEra = 0x5c1f1 /**< sci-fi */
97} RTSOLCORETYPE;
98
99/**
100 * Per-Thread information employed by the solaris core dumper.
101 */
102typedef struct RTSOLCORETHREADINFO
103{
104 lwpsinfo_t Info; /**< Proc description of this thread */
105 lwpstatus_t *pStatus; /**< Proc description of this thread's status (can be NULL, zombie lwp) */
106 struct RTSOLCORETHREADINFO *pNext; /**< Pointer to the next thread */
107} RTSOLCORETHREADINFO;
108typedef RTSOLCORETHREADINFO *PRTSOLCORETHREADINFO;
109#endif
110
111
112/**
113 * Current (also the core target) process information.
114 */
115typedef struct RTSOLCOREPROCESS
116{
117 RTPROCESS Process; /**< The pid of the process */
118 char szExecPath[PATH_MAX]; /**< Path of the executable */
119 char *pszExecName; /**< Name of the executable file */
120#ifdef RT_OS_SOLARIS
121 void *pvProcInfo; /**< Process info. */
122 size_t cbProcInfo; /**< Size of the process info. */
123 prpsinfo_t ProcInfoOld; /**< Process info. Older version (for GDB compat.) */
124 pstatus_t ProcStatus; /**< Process status info. */
125 thread_t hCurThread; /**< The current thread */
126 ucontext_t *pCurThreadCtx; /**< Context info. of current thread before starting to dump */
127 int fdAs; /**< proc/pid/as file handle */
128 auxv_t *pAuxVecs; /**< Aux vector of process */
129 int cAuxVecs; /**< Number of aux vector entries */
130 PRTSOLCOREMAPINFO pMapInfoHead; /**< Pointer to the head of list of mappings */
131 uint32_t cMappings; /**< Number of mappings (count of pMapInfoHead list) */
132 PRTSOLCORETHREADINFO pThreadInfoHead; /**< Pointer to the head of list of threads */
133 uint64_t cThreads; /**< Number of threads (count of pThreadInfoHead list) */
134 char szPlatform[SYS_NMLN]; /**< Platform name */
135 char szZoneName[ZONENAME_MAX]; /**< Zone name */
136 struct utsname UtsName; /**< UTS name */
137 void *pvCred; /**< Process credential info. */
138 size_t cbCred; /**< Size of process credential info. */
139 void *pvLdt; /**< Process LDT info. */
140 size_t cbLdt; /**< Size of the LDT info. */
141 prpriv_t *pPriv; /**< Process privilege info. */
142 size_t cbPriv; /**< Size of process privilege info. */
143 const priv_impl_info_t *pcPrivImpl; /**< Process privilege implementation info. (opaque handle) */
144 core_content_t CoreContent; /**< What information goes in the core */
145#else
146# error Port Me!
147#endif
148
149} RTSOLCOREPROCESS;
150typedef RTSOLCOREPROCESS *PRTSOLCOREPROCESS;
151
152typedef int (*PFNRTCOREREADER)(int fdFile, void *pv, size_t cb);
153typedef int (*PFNRTCOREWRITER)(int fdhFile, const void *pcv, size_t cb);
154
155/**
156 * The solaris core file object.
157 */
158typedef struct RTSOLCORE
159{
160 char szCorePath[PATH_MAX]; /**< Path of the core file */
161 RTSOLCOREPROCESS SolProc; /**< Current process information */
162 void *pvCore; /**< Pointer to memory area during dumping */
163 size_t cbCore; /**< Size of memory area during dumping */
164 void *pvFree; /**< Pointer to base of free range in preallocated memory area */
165 bool fIsValid; /**< Whether core information has been fully collected */
166 PFNRTCOREREADER pfnReader; /**< Reader function */
167 PFNRTCOREWRITER pfnWriter; /**< Writer function */
168 int fdCoreFile; /**< Core file (used only while writing the core) */
169 RTFOFF offWrite; /**< Segment/section offset (used only while writing the core) */
170} RTSOLCORE;
171typedef RTSOLCORE *PRTSOLCORE;
172
173typedef int (*PFNRTSOLCOREACCUMULATOR)(PRTSOLCORE pSolCore);
174typedef int (*PFNRTSOLCORETHREADWORKER)(PRTSOLCORE pSolCore, void *pvThreadInfo);
175
176#endif /* !IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h */
177
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette