Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows dump_crash_context take reference to crash_context #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Will-MingLun-Li
Copy link

@Will-MingLun-Li Will-MingLun-Li commented Mar 14, 2025

dump_crash_context only read values of CrashContext, so we can just pass in the reference and don't need to pass the value. This is useful when used with crash handler.

For example, currently the code below wouldn't work, and crash_context can't be converted to type CrashContext since it doesn't implement Copy trait

  CRASH_HANDLER
      .set(
          crash_handler::CrashHandler::attach(unsafe {
              crash_handler::make_crash_event(|crash_context| {  // <- This is of type &CrashContext
                  let mut minidump_file = std::fs::File::create("dump.mdmp").expect("failed to create file");

                  minidump_writer::minidump_writer::MinidumpWriter::dump_crash_context(
                      crash_context,
                      None,
                      &mut minidump_file,
                  );

                  crash_handler::CrashEventResult::Handled(false)
              })
          })
          .expect("CrashHandler should be initialized"),
      )
      .expect("CRASH_HANDLER should be set");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant