1 | /** @file
|
---|
2 | * IPRT - Core Dumper.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2010-2022 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_coredumper_h
|
---|
37 | #define IPRT_INCLUDED_coredumper_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/cdefs.h>
|
---|
43 | #include <iprt/types.h>
|
---|
44 |
|
---|
45 | RT_C_DECLS_BEGIN
|
---|
46 |
|
---|
47 | /** @defgroup grp_rt_coredumper RTCoreDumper - Core Dumper.
|
---|
48 | * @ingroup grp_rt
|
---|
49 | * @{
|
---|
50 | */
|
---|
51 |
|
---|
52 | /** @name RTCoreDumperSetup flags
|
---|
53 | * @{ */
|
---|
54 | /** Override system core dumper. Registers handlers for
|
---|
55 | * SIGSEGV/SIGTRAP/SIGBUS. */
|
---|
56 | #define RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP RT_BIT(0)
|
---|
57 | /** Allow taking live process dumps (without killing process). Registers handler
|
---|
58 | * for SIGUSR2. */
|
---|
59 | #define RTCOREDUMPER_FLAGS_LIVE_CORE RT_BIT(1)
|
---|
60 | /** @} */
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Take a core dump of the current process without terminating it.
|
---|
64 | *
|
---|
65 | * @returns IPRT status code.
|
---|
66 | * @param pszOutputFile Name of the core file. If NULL use the
|
---|
67 | * default naming scheme.
|
---|
68 | * @param fLiveCore When true, the process is not killed after
|
---|
69 | * taking a core. Otherwise it will be killed. This
|
---|
70 | * works in conjuction with the flags set during
|
---|
71 | * RTCoreDumperSetup().
|
---|
72 | */
|
---|
73 | RTDECL(int) RTCoreDumperTakeDump(const char *pszOutputFile, bool fLiveCore);
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Sets up and enables the core dumper.
|
---|
77 | *
|
---|
78 | * Installs signal / unhandled exception handlers for catching fatal errors
|
---|
79 | * that should result in a core dump. If you wish to install your own handlers
|
---|
80 | * you should do that after calling this function and make sure you pass on
|
---|
81 | * events you don't handle.
|
---|
82 | *
|
---|
83 | * This can be called multiple times to change the settings without needing to
|
---|
84 | * call RTCoreDumperDisable in between.
|
---|
85 | *
|
---|
86 | * @param pszOutputDir The directory to store the cores in. If NULL
|
---|
87 | * the current directory will be used.
|
---|
88 | * @param fFlags Setup flags, 0 in NOT a valid flag, it must be
|
---|
89 | * one or more of RTCOREDUMPER_FLAGS_*.
|
---|
90 | */
|
---|
91 | RTDECL(int) RTCoreDumperSetup(const char *pszOutputDir, uint32_t fFlags);
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Disables the core dumper, i.e. undoes what RTCoreDumperSetup did.
|
---|
95 | *
|
---|
96 | * @returns IPRT status code.
|
---|
97 | */
|
---|
98 | RTDECL(int) RTCoreDumperDisable(void);
|
---|
99 |
|
---|
100 | /** @} */
|
---|
101 |
|
---|
102 | RT_C_DECLS_END
|
---|
103 |
|
---|
104 | #endif /* !IPRT_INCLUDED_coredumper_h */
|
---|
105 |
|
---|