Program Listing for File crash-dump.h

Return to documentation for file (include\crash-dump\crash-dump.h)

/******************************************************************************
© Intel Corporation.
This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.
This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.
******************************************************************************/
#pragma once

#include "igpa-config.h"

#ifdef _WIN32
#include <Windows.h>
#endif  // _WIN32

namespace gpa {
namespace crashdump {

class CrashDump
{
public:
    ~CrashDump();

    enum class DUMP_MODE {
        DUMP_DISABLED = 0,
        DUMP_NORMAL = 1,
        DUMP_LARGE = 2,
    };

    static CrashDump& Get();

    CrashDump& operator=(const CrashDump&) = delete;
    CrashDump(const CrashDump&) = delete;

    void HandleException();

    void SetPath(STD_STRING path);
    STD_STRING GetPath() const;
    void SetMode(DUMP_MODE mode = DUMP_MODE::DUMP_NORMAL);
    DUMP_MODE GetMode() const;

    void* GetUnhandledHandler();
    void SetOldUnhandledHandler(void* handler);

private:
    CrashDump();

    void LoadLibraries();
    void UnloadLibraries();
    STD_STRING GetDumpName() const;

    void* mLibrary;
    void* mMinDumpWriteDumpFn;
    void* mOldExceptionFilter;
    STD_STRING mPath;
    DUMP_MODE mMode;
    bool mBroken;

#ifdef _WIN32
    void MakeMiniDump(EXCEPTION_POINTERS* e);
    static LONG CALLBACK UnhandledHandler(EXCEPTION_POINTERS* e);
#endif  // _WIN32
};

}  // namespace crashdump
}  // namespace gpa