Rewrite gdbjit support with safety and fewer deps (#3246)
This refactoring primarily removes the dependency of the gdbjit image creation on the `finished_functions` array, which shouldn't be necessary given the input object being passed in since information can be read from the object instead. Additionally, though, this commit also removes all `unsafe` from the file, relying on various tools in the `object` crate to parse the internals and update various fields.
This commit is contained in:
@@ -213,12 +213,8 @@ impl CompiledModule {
|
||||
|
||||
// Register GDB JIT images; initialize profiler and load the wasm module.
|
||||
let dbg_jit_registration = if artifacts.native_debug_info_present {
|
||||
let bytes = create_dbg_image(
|
||||
artifacts.obj.to_vec(),
|
||||
code_range,
|
||||
&artifacts.module,
|
||||
&finished_functions,
|
||||
)?;
|
||||
let bytes = create_gdbjit_image(artifacts.obj.to_vec(), code_range)
|
||||
.map_err(SetupError::DebugInfo)?;
|
||||
profiler.module_load(&artifacts.module, &finished_functions, Some(&bytes));
|
||||
let reg = GdbJitImageRegistration::register(bytes);
|
||||
Some(reg)
|
||||
@@ -407,20 +403,6 @@ impl<'a> SymbolizeContext<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn create_dbg_image(
|
||||
obj: Vec<u8>,
|
||||
code_range: (*const u8, usize),
|
||||
module: &Module,
|
||||
finished_functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||
) -> Result<Vec<u8>, SetupError> {
|
||||
let funcs = finished_functions
|
||||
.values()
|
||||
.map(|allocated: &*mut [VMFunctionBody]| (*allocated) as *const u8)
|
||||
.collect::<Vec<_>>();
|
||||
create_gdbjit_image(obj, code_range, module.num_imported_funcs, &funcs)
|
||||
.map_err(SetupError::DebugInfo)
|
||||
}
|
||||
|
||||
fn build_code_memory(
|
||||
obj: &File,
|
||||
module: &Module,
|
||||
|
||||
Reference in New Issue
Block a user