| 291 | } |
| 292 | |
| 293 | fn record_function_for_perf(&self, ptr: *const u8, size: usize, name: &str) { |
| 294 | // The Linux perf tool supports JIT code via a /tmp/perf-$PID.map file, |
| 295 | // which contains memory regions and their associated names. If we |
| 296 | // are profiling with perf and saving binaries to PERF_BUILDID_DIR |
| 297 | // for post-profile analysis, write information about each function |
| 298 | // we define. |
| 299 | if cfg!(unix) && ::std::env::var_os("PERF_BUILDID_DIR").is_some() { |
| 300 | let mut map_file = ::std::fs::OpenOptions::new() |
| 301 | .create(true) |
| 302 | .append(true) |
| 303 | .open(format!("/tmp/perf-{}.map", ::std::process::id())) |
| 304 | .unwrap(); |
| 305 | |
| 306 | let _ = writeln!(map_file, "{:x} {:x} {}", ptr as usize, size, name); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | /// Finalize all functions and data objects that are defined but not yet finalized. |
| 311 | /// All symbols referenced in their bodies that are declared as needing a definition |