Skip to content

YJIT: Skip dump-disasm if it fails to create a file #8968

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

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions yjit/src/options.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ffi::{CStr, CString}, ptr::null};
use std::{ffi::{CStr, CString}, ptr::null, fs::File};
use crate::backend::current::TEMP_REGS;
use std::os::raw::{c_char, c_int, c_uint};

Expand Down Expand Up @@ -230,10 +230,14 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> {
("dump-disasm", _) => match opt_val {
"" => unsafe { OPTIONS.dump_disasm = Some(DumpDisasm::Stdout) },
directory => {
let pid = std::process::id();
let path = format!("{directory}/yjit_{pid}.log");
eprintln!("YJIT disasm dump: {path}");
unsafe { OPTIONS.dump_disasm = Some(DumpDisasm::File(path)) }
let path = format!("{directory}/yjit_{}.log", std::process::id());
match File::options().create(true).append(true).open(&path) {
Ok(_) => {
eprintln!("YJIT disasm dump: {path}");
unsafe { OPTIONS.dump_disasm = Some(DumpDisasm::File(path)) }
}
Err(err) => eprintln!("Failed to create {path}: {err}"),
}
}
},

Expand Down