capture_context_mac.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2014 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef CRASHPAD_CLIENT_CAPTURE_CONTEXT_MAC_H_
  15. #define CRASHPAD_CLIENT_CAPTURE_CONTEXT_MAC_H_
  16. #include <mach/mach.h>
  17. #include "build/build_config.h"
  18. namespace crashpad {
  19. #if defined(ARCH_CPU_X86_FAMILY)
  20. using NativeCPUContext = x86_thread_state;
  21. #endif
  22. //! \brief Saves the CPU context.
  23. //!
  24. //! The CPU context will be captured as accurately and completely as possible,
  25. //! containing an atomic snapshot at the point of this function’s return. This
  26. //! function does not modify any registers.
  27. //!
  28. //! \param[out] cpu_context The structure to store the context in.
  29. //!
  30. //! \note On x86_64, the value for `%%rdi` will be populated with the address of
  31. //! this function’s argument, as mandated by the ABI. If the value of
  32. //! `%%rdi` prior to calling this function is needed, it must be obtained
  33. //! separately prior to calling this function. For example:
  34. //! \code
  35. //! uint64_t rdi;
  36. //! asm("movq %%rdi, %0" : "=m"(rdi));
  37. //! \endcode
  38. void CaptureContext(NativeCPUContext* cpu_context);
  39. } // namespace crashpad
  40. #endif // CRASHPAD_CLIENT_CAPTURE_CONTEXT_MAC_H_