crash_event_native.py 2.7 KB

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