MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / insert_function

Method insert_function

plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs:224–317  ·  view source on GitHub ↗
(
        &mut self,
        full_name: Option<String>,
        raw_name: Option<String>,
        return_type: Option<TypeUID>,
        address: Option<u64>,
        parameters: &Vec<Option<(String, T

Source from the content-addressed store, hash-verified

222
223 #[allow(clippy::too_many_arguments)]
224 pub(crate) fn insert_function(
225 &mut self,
226 full_name: Option<String>,
227 raw_name: Option<String>,
228 return_type: Option<TypeUID>,
229 address: Option<u64>,
230 parameters: &Vec<Option<(String, TypeUID)>>,
231 variable_arguments: bool,
232 use_cfa: bool,
233 ) -> Option<usize> {
234 // Returns the index of the function
235 // Raw names should be the primary key, but if they don't exist, use the full name
236 // TODO : Consider further falling back on address/architecture
237
238 /*
239 If it has a raw_name and we know it, update it and return
240 Else if it has a full_name and we know it, update it and return
241 Else Add a new entry if we don't know the full_name or raw_name
242 */
243
244 if let Some(ident) = &raw_name {
245 // check if we already know about this raw name's index
246 // if we do, and the full name will change, remove the known full index if it exists
247 // update the function
248 // if the full name exists, update the stored index for the full name
249 if let Some(idx) = self.raw_function_name_indices.get(ident) {
250 let function = self.functions.get_mut(*idx).unwrap();
251
252 if function.full_name.is_some() && function.full_name != full_name {
253 self.full_function_name_indices
254 .remove(function.full_name.as_ref().unwrap());
255 }
256
257 function.update(full_name, raw_name, return_type, address, parameters);
258
259 if function.full_name.is_some() {
260 self.full_function_name_indices
261 .insert(function.full_name.clone().unwrap(), *idx);
262 }
263
264 return Some(*idx);
265 }
266 } else if let Some(ident) = &full_name {
267 // check if we already know about this full name's index
268 // if we do, and the raw name will change, remove the known raw index if it exists
269 // update the function
270 // if the raw name exists, update the stored index for the raw name
271 if let Some(idx) = self.full_function_name_indices.get(ident) {
272 let function = self.functions.get_mut(*idx).unwrap();
273
274 if function.raw_name.is_some() && function.raw_name != raw_name {
275 self.raw_function_name_indices
276 .remove(function.raw_name.as_ref().unwrap());
277 }
278
279 function.update(full_name, raw_name, return_type, address, parameters);
280
281 if function.raw_name.is_some() {

Callers 1

parse_function_entryFunction · 0.80

Calls 8

getMethod · 0.45
removeMethod · 0.45
as_refMethod · 0.45
updateMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected