dump_without_crashing.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_
  5. #define BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_
  6. #include "base/base_export.h"
  7. #include "base/compiler_specific.h"
  8. #include "build/build_config.h"
  9. namespace base {
  10. namespace debug {
  11. // Handler to silently dump the current process without crashing.
  12. // Before calling this function, call SetDumpWithoutCrashingFunction to pass a
  13. // function pointer.
  14. // Windows:
  15. // This must be done for each instance of base (i.e. module) and is normally
  16. // chrome_elf!DumpProcessWithoutCrash. See example code in chrome_main.cc that
  17. // does this for chrome.dll and chrome_child.dll. Note: Crashpad sets this up
  18. // for main chrome.exe as part of calling crash_reporter::InitializeCrashpad.
  19. // Mac/Linux:
  20. // Crashpad does this as part of crash_reporter::InitializeCrashpad.
  21. // Returns false if called before SetDumpWithoutCrashingFunction.
  22. //
  23. // This function must not be called with a tail call because that would cause
  24. // the caller to be omitted from the call stack in the crash dump, and that is
  25. // confusing and omits what is likely the most important context.
  26. BASE_EXPORT bool NOT_TAIL_CALLED DumpWithoutCrashing();
  27. // Sets a function that'll be invoked to dump the current process when
  28. // DumpWithoutCrashing() is called. May be called with null to remove a
  29. // previously set function.
  30. BASE_EXPORT void SetDumpWithoutCrashingFunction(void (CDECL *function)());
  31. } // namespace debug
  32. } // namespace base
  33. #endif // BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_