coredumper.h revision 470deca4c684fee094576ae4feae40f9b4c9f1c1
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @file
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * IPRT - Core Dumper.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/*
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Copyright (C) 2010 Oracle Corporation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * available from http://www.virtualbox.org. This file is free software;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * General Public License (GPL) as published by the Free Software
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * The contents of this file may alternatively be used under the terms
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * of the Common Development and Distribution License Version 1.0
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VirtualBox OSE distribution, in which case the provisions of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * CDDL are applicable instead of those of the GPL.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * You may elect to license modified versions of this file under the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * terms and conditions of either the GPL or the CDDL or both.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#ifndef ___iprt_coredumper_h
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#define ___iprt_coredumper_h
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#include <iprt/cdefs.h>
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#include <iprt/types.h>
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_C_DECLS_BEGIN
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @defgroup grp_rt_coredumper RTCoreDumper - Core Dumper.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @ingroup grp_rt
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @{
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @name RTCoreDumperSetup flags
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @{ */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Override system core dumper. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#define RTCOREDUMPER_FLAGS_REPLACE_SYSTEM_DUMP RT_BIT(0)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Allow taking live process dumps (without killing process). */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#define RTCOREDUMPER_FLAGS_LIVE_CORE RT_BIT(1)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @} */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Take a core dump of the current process without terminating it.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @returns IPRT status code.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param pszOutputFile Name of the core file. If NULL use the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * default naming scheme.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param fLiveCore When true, the process is not killed after
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * taking a core. Otherwise it will be killed. This
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * works in conjuction with the flags set during
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * RTCoreDumperSetup().
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(int) RTCoreDumperTakeDump(const char *pszOutputFile, bool fLiveCore);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/**
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Sets up and enables the core dumper.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Installs signal / unhandled exception handlers for catching fatal errors
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * that should result in a core dump. If you wish to install your own handlers
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * you should do that after calling this function and make sure you pass on
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * events you don't handle.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * This can be called multiple times to change the settings without needing to
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * call RTCoreDumperDisable in between.
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync *
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync * @param pszOutputDir The directory to store the cores in. If NULL
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * the current directory will be used.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param pszBaseName Base file name, no directory. If NULL the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * dumper will generate an appropriate name.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @param fFlags Setup flags, see RTCOREDUMPER_FLAGS_*.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(int) RTCoreDumperSetup(const char *pszOutputDir, uint32_t fFlags);
7bf07b1592dfaab1a4fb6d497fd0ff1302fb7585vboxsync
3dd53c06fd54914761cf550503f02fce1ed5a815vboxsync/**
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync * Disables the core dumper, i.e. undoes what RTCoreDumperSetup did.
3dd53c06fd54914761cf550503f02fce1ed5a815vboxsync *
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync * @returns IPRT status code.
b8c2e8ba48bd659fa09a06770a7cedfae977d73bvboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(int) RTCoreDumperDisable(void);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @} */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_C_DECLS_END
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync#endif
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync