Skip to content

Commit 9ade019

Browse files
authored
Merge pull request #6 from BinaryAnalysisPlatform/fix-tid-search
Fix tid search
2 parents 688cf83 + 0917550 commit 9ade019

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup (
66
name = 'bap',
7-
version = '1.0.0',
7+
version = '1.1.0',
88
description = 'Python bindings to Binary Analysis Platform (BAP)',
99
author = 'BAP Team',
1010
url = 'https://github.com/BinaryAnalysisPlatform/bap-python',

src/bap/adt.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ def find(self,key, d=None) :
462462
If a key is an instance of Tid class, then a term with
463463
corresponding tid is returned.
464464
465-
If a key is a number, or an instance of `bil.Int' class, then
466-
a term with a matching address is returned.
465+
If a key is a number, or an instance of `bil.Int' class or is
466+
an integer, then a term with a matching address is returned.
467467
468468
Example
469469
-------
@@ -475,24 +475,26 @@ def find(self,key, d=None) :
475475
>>> main = proj.program.subs.find('main')
476476
>>> main = proj.program.subs.find(main.id)
477477
>>> main = proj.program.subs.find(main.id.name)
478+
478479
"""
479-
def by_id(t,key) : return t.id == key
480-
def by_name(t,key) :
481-
if key.startswith(('@','%')):
482-
return t.id.name == key
480+
def by_id(t, k) : return t.id.number == k
481+
def by_name(t,k) :
482+
if k.startswith(('@','%')):
483+
return t.id.name == k
483484
else:
484-
return hasattr(t,'name') and t.name == key
485-
def by_addr(t,key) :
485+
return hasattr(t, 'name') and t.name == k
486+
def by_addr(t,k) :
486487
value = t.attrs.get('address', None)
487488
if value is not None:
488489
return parse_addr(value) == key
489490

490491
test = by_addr
491492
if isinstance(key,str):
492493
test = by_name
493-
elif isinstance(key,Tid):
494+
elif hasattr(key,'constr') and key.constr == 'Tid':
495+
key = key.number
494496
test = by_id
495-
elif isinstance(key,Int):
497+
elif hasattr(key,'constr') and key.constr == 'Int':
496498
key = key.value
497499
test = by_addr
498500

0 commit comments

Comments
 (0)