| 596 | |
| 597 | #[cfg(feature = "debug-builtins")] |
| 598 | fn register_debug_image(&mut self) -> Result<()> { |
| 599 | if !self.has_native_debug_info { |
| 600 | return Ok(()); |
| 601 | } |
| 602 | |
| 603 | // TODO-DebugInfo: we're copying the whole image here, which is pretty wasteful. |
| 604 | // Use the existing memory by teaching code here about relocations in DWARF sections |
| 605 | // and anything else necessary that is done in "create_gdbjit_image" right now. |
| 606 | let image = self.mmap().to_vec(); |
| 607 | let text: &[u8] = self.text(); |
| 608 | let bytes = crate::native_debug::create_gdbjit_image(image, (text.as_ptr(), text.len()))?; |
| 609 | let reg = crate::runtime::vm::GdbJitImageRegistration::register(bytes); |
| 610 | self.debug_registration = Some(reg); |
| 611 | Ok(()) |
| 612 | } |
| 613 | |
| 614 | /// Looks up the given offset within this module's text section and returns |
| 615 | /// the trap code associated with that instruction, if there is one. |