VirtualBox

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

Last change on this file since 93943 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.5 KB
Line 
1/* $Id: coredumper-solaris.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * IPRT - Custom Core Dumper, Solaris.
4 */
5
6/*
7 * Copyright (C) 2010-2022 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#ifndef IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h
28#define IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34
35#ifdef RT_OS_SOLARIS
36# if defined(RT_ARCH_X86) && _FILE_OFFSET_BITS==64
37/*
38 * Solaris' procfs cannot be used with large file environment in 32-bit.
39 */
40# undef _FILE_OFFSET_BITS
41# define _FILE_OFFSET_BITS 32
42# include <procfs.h>
43# include <sys/procfs.h>
44# include <sys/old_procfs.h>
45# undef _FILE_OFFSET_BITS
46# define _FILE_OFFSET_BITS 64
47#else
48# include <procfs.h>
49# include <sys/procfs.h>
50# include <sys/old_procfs.h>
51#endif
52# include <limits.h>
53# include <thread.h>
54# include <sys/auxv.h>
55# include <sys/lwp.h>
56# include <sys/zone.h>
57# include <sys/utsname.h>
58
59#ifdef RT_ARCH_AMD64
60# define _ELF64
61# undef _ELF32_COMPAT
62#endif
63# include <sys/corectl.h>
64#endif
65
66
67#ifdef RT_OS_SOLARIS
68/**
69 * Memory mapping descriptor employed by the solaris core dumper.
70 */
71typedef struct RTSOLCOREMAPINFO
72{
73 prmap_t pMap; /**< Proc description of this mapping */
74 int fError; /**< Any error reading this mapping (errno) */
75 struct RTSOLCOREMAPINFO *pNext; /**< Pointer to the next mapping */
76} RTSOLCOREMAPINFO;
77/** Pointer to a solaris memory mapping descriptor. */
78typedef RTSOLCOREMAPINFO *PRTSOLCOREMAPINFO;
79
80/**
81 * Whether this is an old or new style solaris core.
82 */
83typedef enum RTSOLCORETYPE
84{
85 enmOldEra = 0x01d, /**< old */
86 enmNewEra = 0x5c1f1 /**< sci-fi */
87} RTSOLCORETYPE;
88
89/**
90 * Per-Thread information employed by the solaris core dumper.
91 */
92typedef struct RTSOLCORETHREADINFO
93{
94 lwpsinfo_t Info; /**< Proc description of this thread */
95 lwpstatus_t *pStatus; /**< Proc description of this thread's status (can be NULL, zombie lwp) */
96 struct RTSOLCORETHREADINFO *pNext; /**< Pointer to the next thread */
97} RTSOLCORETHREADINFO;
98typedef RTSOLCORETHREADINFO *PRTSOLCORETHREADINFO;
99#endif
100
101
102/**
103 * Current (also the core target) process information.
104 */
105typedef struct RTSOLCOREPROCESS
106{
107 RTPROCESS Process; /**< The pid of the process */
108 char szExecPath[PATH_MAX]; /**< Path of the executable */
109 char *pszExecName; /**< Name of the executable file */
110#ifdef RT_OS_SOLARIS
111 void *pvProcInfo; /**< Process info. */
112 size_t cbProcInfo; /**< Size of the process info. */
113 prpsinfo_t ProcInfoOld; /**< Process info. Older version (for GDB compat.) */
114 pstatus_t ProcStatus; /**< Process status info. */
115 thread_t hCurThread; /**< The current thread */
116 ucontext_t *pCurThreadCtx; /**< Context info. of current thread before starting to dump */
117 int fdAs; /**< proc/pid/as file handle */
118 auxv_t *pAuxVecs; /**< Aux vector of process */
119 int cAuxVecs; /**< Number of aux vector entries */
120 PRTSOLCOREMAPINFO pMapInfoHead; /**< Pointer to the head of list of mappings */
121 uint32_t cMappings; /**< Number of mappings (count of pMapInfoHead list) */
122 PRTSOLCORETHREADINFO pThreadInfoHead; /**< Pointer to the head of list of threads */
123 uint64_t cThreads; /**< Number of threads (count of pThreadInfoHead list) */
124 char szPlatform[SYS_NMLN]; /**< Platform name */
125 char szZoneName[ZONENAME_MAX]; /**< Zone name */
126 struct utsname UtsName; /**< UTS name */
127 void *pvCred; /**< Process credential info. */
128 size_t cbCred; /**< Size of process credential info. */
129 void *pvLdt; /**< Process LDT info. */
130 size_t cbLdt; /**< Size of the LDT info. */
131 prpriv_t *pPriv; /**< Process privilege info. */
132 size_t cbPriv; /**< Size of process privilege info. */
133 const priv_impl_info_t *pcPrivImpl; /**< Process privilege implementation info. (opaque handle) */
134 core_content_t CoreContent; /**< What information goes in the core */
135#else
136# error Port Me!
137#endif
138
139} RTSOLCOREPROCESS;
140typedef RTSOLCOREPROCESS *PRTSOLCOREPROCESS;
141
142typedef int (*PFNRTCOREREADER)(int fdFile, void *pv, size_t cb);
143typedef int (*PFNRTCOREWRITER)(int fdhFile, const void *pcv, size_t cb);
144
145/**
146 * The solaris core file object.
147 */
148typedef struct RTSOLCORE
149{
150 char szCorePath[PATH_MAX]; /**< Path of the core file */
151 RTSOLCOREPROCESS SolProc; /**< Current process information */
152 void *pvCore; /**< Pointer to memory area during dumping */
153 size_t cbCore; /**< Size of memory area during dumping */
154 void *pvFree; /**< Pointer to base of free range in preallocated memory area */
155 bool fIsValid; /**< Whether core information has been fully collected */
156 PFNRTCOREREADER pfnReader; /**< Reader function */
157 PFNRTCOREWRITER pfnWriter; /**< Writer function */
158 int fdCoreFile; /**< Core file (used only while writing the core) */
159 RTFOFF offWrite; /**< Segment/section offset (used only while writing the core) */
160} RTSOLCORE;
161typedef RTSOLCORE *PRTSOLCORE;
162
163typedef int (*PFNRTSOLCOREACCUMULATOR)(PRTSOLCORE pSolCore);
164typedef int (*PFNRTSOLCORETHREADWORKER)(PRTSOLCORE pSolCore, void *pvThreadInfo);
165
166#endif /* !IPRT_INCLUDED_SRC_r3_solaris_coredumper_solaris_h */
167
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