Registers a new region of code. Must not have been previously registered and must be `unregister`'d to prevent leaking memory. This is required to enable traps to work correctly since the signal handler will lookup in the `GLOBAL_CODE` list to determine which a particular pc is a trap or not.
(image: &Arc<CodeMemory>, address: Range<usize>)
| 396 | /// will lookup in the `GLOBAL_CODE` list to determine which a particular pc |
| 397 | /// is a trap or not. |
| 398 | pub fn register_code(image: &Arc<CodeMemory>, address: Range<usize>) -> Result<(), OutOfMemory> { |
| 399 | if address.is_empty() { |
| 400 | return Ok(()); |
| 401 | } |
| 402 | let start = address.start; |
| 403 | let end = address.end - 1; |
| 404 | let prev = global_code().write().insert(end, (start, image.clone()))?; |
| 405 | assert!(prev.is_none()); |
| 406 | Ok(()) |
| 407 | } |
| 408 | |
| 409 | /// Unregisters a code mmap from the global map. |
| 410 | /// |