Skip to content

Commit 8a5cd4b

Browse files
mkrasnitskiemesare
authored andcommitted
Add VariableSourceType type alias
1 parent 85c04ea commit 8a5cd4b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use binaryninja::{
2121
rc::*,
2222
symbol::SymbolType,
2323
templatesimplifier::simplify_str_to_fqn,
24-
types::{Conf, FunctionParameter, NamedTypedVariable, Type, Variable},
25-
binaryninjacore_sys::BNVariableSourceType,
24+
types::{Conf, FunctionParameter, NamedTypedVariable, Type, Variable, VariableSourceType},
2625
};
2726

2827
use gimli::{DebuggingInformationEntry, Dwarf, Unit};
@@ -415,7 +414,7 @@ impl DebugInfoBuilder {
415414
return;
416415
}
417416

418-
let var = Variable::new(BNVariableSourceType::StackVariableSourceType, 0, adjusted_offset);
417+
let var = Variable::new(VariableSourceType::StackVariableSourceType, 0, adjusted_offset);
419418
function.stack_variables.push(NamedTypedVariable::new(var, name, t, false));
420419

421420
}

rust/examples/pdb-ng/src/symbol_parser.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ use pdb::{
3535
};
3636

3737
use binaryninja::architecture::{Architecture, ArchitectureExt, Register};
38-
use binaryninja::binaryninjacore_sys::BNVariableSourceType;
3938
use binaryninja::binaryview::BinaryViewBase;
4039
use binaryninja::demangle::demangle_ms;
4140
use binaryninja::rc::Ref;
4241
use binaryninja::types::{
4342
max_confidence, min_confidence, Conf, ConfMergable, FunctionParameter, QualifiedName,
44-
StructureBuilder, Type, TypeClass, Variable,
43+
StructureBuilder, Type, TypeClass, Variable, VariableSourceType,
4544
};
4645

4746
use crate::PDBParserInstance;
@@ -736,7 +735,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
736735
let storage = if let Some(reg) = self.convert_register(data.register) {
737736
vec![ParsedLocation {
738737
location: Variable {
739-
t: BNVariableSourceType::RegisterVariableSourceType,
738+
t: VariableSourceType::RegisterVariableSourceType,
740739
index: 0,
741740
storage: reg,
742741
},
@@ -1425,7 +1424,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
14251424
type_: self.lookup_type_conf(&data.type_index, false)?,
14261425
storage: vec![ParsedLocation {
14271426
location: Variable {
1428-
t: BNVariableSourceType::StackVariableSourceType,
1427+
t: VariableSourceType::StackVariableSourceType,
14291428
index: 0,
14301429
storage: data.offset as i64,
14311430
},
@@ -1443,7 +1442,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
14431442
type_: self.lookup_type_conf(&data.type_index, false)?,
14441443
storage: vec![ParsedLocation {
14451444
location: Variable {
1446-
t: BNVariableSourceType::StackVariableSourceType,
1445+
t: VariableSourceType::StackVariableSourceType,
14471446
index: 0,
14481447
storage: data.offset as i64,
14491448
},
@@ -1587,7 +1586,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
15871586
if let Some(reg) = self.convert_register(data.register) {
15881587
Ok(Some(ParsedSymbol::Location(ParsedLocation {
15891588
location: Variable {
1590-
t: BNVariableSourceType::RegisterVariableSourceType,
1589+
t: VariableSourceType::RegisterVariableSourceType,
15911590
index: 0,
15921591
storage: reg,
15931592
},
@@ -1654,7 +1653,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
16541653
type_: self.lookup_type_conf(&data.type_index, false)?,
16551654
storage: vec![ParsedLocation {
16561655
location: Variable {
1657-
t: BNVariableSourceType::StackVariableSourceType,
1656+
t: VariableSourceType::StackVariableSourceType,
16581657
index: 0,
16591658
storage: data.offset as i64,
16601659
},
@@ -1696,14 +1695,14 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
16961695
for loc in &new_storage {
16971696
match loc {
16981697
Variable {
1699-
t: BNVariableSourceType::RegisterVariableSourceType,
1698+
t: VariableSourceType::RegisterVariableSourceType,
17001699
..
17011700
} => {
17021701
// Assume register vars are always parameters
17031702
really_is_param = true;
17041703
}
17051704
Variable {
1706-
t: BNVariableSourceType::StackVariableSourceType,
1705+
t: VariableSourceType::StackVariableSourceType,
17071706
storage,
17081707
..
17091708
} if *storage >= 0 => {

rust/src/types.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub type MemberAccess = BNMemberAccess;
5555
pub type MemberScope = BNMemberScope;
5656
pub type ILBranchDependence = BNILBranchDependence;
5757
pub type DataFlowQueryOption = BNDataFlowQueryOption;
58+
pub type VariableSourceType = BNVariableSourceType;
5859

5960
////////////////
6061
// Confidence
@@ -1378,9 +1379,9 @@ impl FunctionParameter {
13781379

13791380
pub(crate) fn from_raw(member: BNFunctionParameter) -> Self {
13801381
let name = if member.name.is_null() {
1381-
if member.location.type_ == BNVariableSourceType::RegisterVariableSourceType {
1382+
if member.location.type_ == VariableSourceType::RegisterVariableSourceType {
13821383
format!("reg_{}", member.location.storage)
1383-
} else if member.location.type_ == BNVariableSourceType::StackVariableSourceType {
1384+
} else if member.location.type_ == VariableSourceType::StackVariableSourceType {
13841385
format!("arg_{}", member.location.storage)
13851386
} else {
13861387
String::new()
@@ -1412,13 +1413,13 @@ impl FunctionParameter {
14121413

14131414
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
14141415
pub struct Variable {
1415-
pub t: BNVariableSourceType,
1416+
pub t: VariableSourceType,
14161417
pub index: u32,
14171418
pub storage: i64,
14181419
}
14191420

14201421
impl Variable {
1421-
pub fn new(t: BNVariableSourceType, index: u32, storage: i64) -> Self {
1422+
pub fn new(t: VariableSourceType, index: u32, storage: i64) -> Self {
14221423
Self { t, index, storage }
14231424
}
14241425

0 commit comments

Comments
 (0)