crash_event_native.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import time
  2. from collections.abc import Mapping, MutableMapping, Sequence
  3. def get_frames(
  4. sdk_frame_function: str,
  5. sdk_frame_package: str,
  6. system_frame_package: str,
  7. ) -> Sequence[MutableMapping[str, str]]:
  8. frames = [
  9. {
  10. "function": "RtlUserThreadStart",
  11. "symbol": "RtlUserThreadStart",
  12. "package": "C:\\WINDOWS\\SYSTEM32\\ntdll.dll",
  13. },
  14. {
  15. "function": "BaseThreadInitThunk",
  16. "symbol": "BaseThreadInitThunk",
  17. "package": "C:\\WINDOWS\\System32\\KERNEL32.DLL",
  18. },
  19. {
  20. "function": "snprintf",
  21. "symbol": "snprintf",
  22. "package": "D:\\Sentry\\Sentaurs\\Game\\Sentaurs.exe",
  23. },
  24. {
  25. "function": sdk_frame_function,
  26. "symbol": sdk_frame_function,
  27. "package": sdk_frame_package,
  28. },
  29. {
  30. "function": "boost::serialization::singleton<T>::singleton<T>",
  31. "symbol": "??0?$singleton@V?$extended_type_info_typeid@T_E_SC_SI_OPT_IR_MODE_SELECTOR@@@serialization@boost@@@serialization@boost@@IEAA@XZ",
  32. "package": system_frame_package,
  33. },
  34. ]
  35. return frames
  36. def get_crash_event(
  37. sdk_frame_function="sentry_value_to_msgpack",
  38. sdk_frame_package="E:\\Sentry\\Sentaurs\\Game\\Sentaurs.exe",
  39. system_frame_package="C:\\Windows\\System32\\DriverStore\\FileRepository\\u0398226.inf_amd64_c5d9587384e4b5ff\\B398182\\amdxx64.dll",
  40. **kwargs,
  41. ) -> dict[str, object]:
  42. return get_crash_event_with_frames(
  43. get_frames(sdk_frame_function, sdk_frame_package, system_frame_package),
  44. **kwargs,
  45. )
  46. def get_crash_event_with_frames(frames: Sequence[Mapping[str, str]], **kwargs) -> dict[str, object]:
  47. result = {
  48. "event_id": "0a52a8331d3b45089ebd74f8118d4fa1",
  49. "release": "14.7",
  50. "platform": "native",
  51. "exception": {
  52. "values": [
  53. {
  54. "type": "EXCEPTION_ACCESS_VIOLATION_READ / 0x65707980",
  55. "value": "Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ / 0x65707980",
  56. "stacktrace": {"frames": frames},
  57. "mechanism": {"type": "minidump", "synthetic": True, "handled": False},
  58. }
  59. ]
  60. },
  61. "level": "fatal",
  62. "contexts": {
  63. "device": {"arch": "x86_64", "type": "device"},
  64. "os": {
  65. "name": "Windows",
  66. "version": "10.0.22631",
  67. "build": "3296",
  68. "kernel_version": "10.0.22621.3296",
  69. "type": "os",
  70. },
  71. },
  72. "sdk": {"name": "sentry.native", "version": "0.6.0"},
  73. "timestamp": time.time(),
  74. "type": "error",
  75. }
  76. result.update(kwargs)
  77. return result