MCPcopy Create free account
hub / github.com/cretz/stackparam / apply_local_var_table

Function apply_local_var_table

src/native.rs:709–768  ·  view source on GitHub ↗
(method: jmethodID, info: &mut MethodInfo)

Source from the content-addressed store, hash-verified

707}
708
709unsafe fn apply_local_var_table(method: jmethodID, info: &mut MethodInfo) -> Result<(), String> {
710 let mut entries: *mut jvmtiLocalVariableEntry = ptr::null_mut();
711 let mut entry_count: jint = 0;
712 let table_res = (**JVMTI_ENV).GetLocalVariableTable.unwrap()(JVMTI_ENV, method, &mut entry_count, &mut entries);
713 if table_res as u32 == jvmtiError::JVMTI_ERROR_ABSENT_INFORMATION as u32 {
714 // When information is absent, we don't care
715 return Result::Ok(());
716 }
717 util::unit_or_jvmti_err(table_res)?;
718 let entry_slice = slice::from_raw_parts(entries, entry_count as usize);
719 if log_enabled!(Trace) {
720 for entry in entry_slice {
721 trace!("Var table entry named {} at slot {} has type {}",
722 CStr::from_ptr(entry.name).to_string_lossy(),
723 entry.slot, CStr::from_ptr(entry.signature).to_string_lossy());
724 }
725 }
726 let mut err: Option<String> = None;
727 'param_loop: for param in info.params.iter_mut() {
728 // Find the entry at the expected slot and start location 0, but break
729 // if there is something else at that slot but not at location 0
730 let mut maybe_entry: Option<&jvmtiLocalVariableEntry> = None;
731 for entry in entry_slice {
732 if entry.slot == param.slot {
733 if entry.start_location != 0 {
734 err = Some(format!("Var at slot {} should be location 0, but is {}", entry.slot, entry.start_location));
735 break 'param_loop;
736 }
737 maybe_entry = Some(entry);
738 }
739 }
740 let entry = match maybe_entry {
741 Some(entry) => entry,
742 None => {
743 err = Some(format!("Can't find var entry for slot {} and location 0", param.slot));
744 break;
745 },
746 };
747 param.name = CStr::from_ptr(entry.name).to_string_lossy().clone().into_owned();
748 // Don't need to own this
749 let type_str = CStr::from_ptr(entry.signature).to_string_lossy();
750 if type_str != param.typ {
751 err = Some(format!("Var {} expected type {}, got {}", param.name, param.typ, type_str.clone()));
752 break;
753 }
754 }
755 // Dealloc everything, ignoring errors
756 for entry in entry_slice {
757 let _ = dealloc(entry.name);
758 let _ = dealloc(entry.signature);
759 if !entry.generic_signature.is_null() {
760 let _ = dealloc(entry.generic_signature);
761 }
762 }
763 let _ = dealloc(entries);
764 return match err {
765 Some(err_str) => Result::Err(err_str),
766 None => Result::Ok(())

Callers 1

get_frame_paramsFunction · 0.85

Calls 3

unit_or_jvmti_errFunction · 0.85
deallocFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected