(fd: i32, frame: &Frame)
| 251 | /// Dump a single frame's info to fd (signal-safe), reading live data. |
| 252 | #[cfg(any(unix, windows))] |
| 253 | fn dump_frame_from_raw(fd: i32, frame: &Frame) { |
| 254 | let filename = frame.code.source_path().as_str(); |
| 255 | let funcname = frame.code.obj_name.as_str(); |
| 256 | let lasti = frame.lasti(); |
| 257 | let lineno = if lasti == 0 { |
| 258 | frame.code.first_line_number.map(|n| n.get()).unwrap_or(1) as u32 |
| 259 | } else { |
| 260 | let idx = (lasti as usize).saturating_sub(1); |
| 261 | if idx < frame.code.locations.len() { |
| 262 | frame.code.locations[idx].0.line.get() as u32 |
| 263 | } else { |
| 264 | frame.code.first_line_number.map(|n| n.get()).unwrap_or(0) as u32 |
| 265 | } |
| 266 | }; |
| 267 | |
| 268 | puts(fd, " File \""); |
| 269 | dump_ascii(fd, filename); |
| 270 | puts(fd, "\", line "); |
| 271 | dump_decimal(fd, lineno as usize); |
| 272 | puts(fd, " in "); |
| 273 | dump_ascii(fd, funcname); |
| 274 | puts(fd, "\n"); |
| 275 | } |
| 276 | |
| 277 | // faulthandler_dump_traceback (signal-safe, for fatal errors) |
| 278 | #[cfg(any(unix, windows))] |
no test coverage detected