(&self)
| 242 | } |
| 243 | |
| 244 | fn maybe_write_file_header(&self) -> io::Result<()> { |
| 245 | let header = FileHeader { |
| 246 | timestamp: self.get_time_stamp(), |
| 247 | e_machine: self.e_machine, |
| 248 | magic: 0x4A695444, |
| 249 | version: 1, |
| 250 | size: mem::size_of::<FileHeader>() as u32, |
| 251 | pad1: 0, |
| 252 | pid: process::id(), |
| 253 | flags: 0, |
| 254 | }; |
| 255 | |
| 256 | // If it looks like some other engine in the same process has opened the |
| 257 | // file and added data already then assume that they were the ones to |
| 258 | // add the file header. If it's empty, though, assume we're the ones to |
| 259 | // add the file header. |
| 260 | // |
| 261 | // This is subject to a TOCTOU-style race condition but there's not |
| 262 | // really anything we can do about that. That'd require higher-level |
| 263 | // coordination in the application to boot up profiling agents serially |
| 264 | // or something like that. Either that or a better dump format where we |
| 265 | // can place output in our own engine-specific file. Alas. |
| 266 | if self.jitdump_file.metadata()?.len() == 0 { |
| 267 | self.maybe_atomic_write_all(object::bytes_of(&header))?; |
| 268 | } |
| 269 | Ok(()) |
| 270 | } |
| 271 | |
| 272 | /// Get raw access to the underlying file that is being written to. |
| 273 | pub fn file(&self) -> &File { |
no test coverage detected