about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2020-08-22 12:47:01 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2020-08-31 07:50:01 +0200
commit80e40a3d2ca735db955807ad0605b43ca22e4e35 (patch)
tree4d41d7b53565f833444d3520eb22eed3e8bf26f1 /test
parent5d8beb271d9890241a6d61dd476fab26ca37ebbf (diff)
downloadmiasm-80e40a3d2ca735db955807ad0605b43ca22e4e35.tar.gz
miasm-80e40a3d2ca735db955807ad0605b43ca22e4e35.zip
Avoid generate default locationdb
Diffstat (limited to 'test')
-rw-r--r--test/analysis/dse.py16
-rw-r--r--test/arch/aarch64/unit/asm_test.py11
-rw-r--r--test/arch/mep/jit/ut_helpers_jit.py4
-rw-r--r--test/arch/mips32/unit/asm_test.py11
-rw-r--r--test/arch/x86/qemu/testqemu.py4
-rw-r--r--test/arch/x86/qemu/testqemu64.py4
-rwxr-xr-xtest/arch/x86/sem.py3
-rw-r--r--test/arch/x86/unit/access_xmm.py4
-rw-r--r--test/arch/x86/unit/asm_test.py15
-rwxr-xr-xtest/arch/x86/unit/mn_pushpop.py24
-rw-r--r--test/arch/x86/unit/test_asm_x86_64.py10
-rw-r--r--test/core/asmblock.py60
-rwxr-xr-xtest/core/parse_asm.py16
-rwxr-xr-xtest/core/test_types.py4
-rw-r--r--test/jitter/bad_block.py4
-rw-r--r--test/jitter/jit_options.py10
-rw-r--r--test/jitter/jitcore.py4
-rw-r--r--test/jitter/jitload.py5
-rw-r--r--test/jitter/jmp_out_mem.py5
-rw-r--r--test/jitter/mem_breakpoint.py4
-rw-r--r--test/jitter/test_post_instr.py4
-rw-r--r--test/jitter/vm_mngr.py4
-rwxr-xr-xtest/os_dep/common.py4
-rwxr-xr-xtest/os_dep/linux/stdlib.py4
-rw-r--r--test/os_dep/linux/test_env.py4
-rwxr-xr-xtest/os_dep/win_api_x86_32.py4
26 files changed, 146 insertions, 96 deletions
diff --git a/test/analysis/dse.py b/test/analysis/dse.py
index 7d5998f1..cd813d2c 100644
--- a/test/analysis/dse.py
+++ b/test/analysis/dse.py
@@ -10,6 +10,7 @@ from miasm.core.asmblock import asm_resolve_final
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
 from miasm.analysis.dse import DSEEngine
+from miasm.core.locationdb import LocationDB
 
 
 class DSETest(object):
@@ -31,9 +32,10 @@ class DSETest(object):
     run_addr = 0x0
 
     def __init__(self, jitter_engine):
+        self.loc_db = LocationDB()
         self.machine = Machine(self.arch_name)
         jitter = self.machine.jitter
-        self.myjit = jitter(jitter_engine)
+        self.myjit = jitter(self.loc_db, jitter_engine)
         self.myjit.init_stack()
 
         self.myjit.set_trace_log()
@@ -52,7 +54,7 @@ class DSETest(object):
         self.myjit.cpu.ECX = 4
         self.myjit.cpu.EDX = 5
 
-        self.dse = DSEEngine(self.machine)
+        self.dse = DSEEngine(self.machine, self.loc_db)
         self.dse.attach(self.myjit)
 
     def __call__(self):
@@ -71,17 +73,17 @@ class DSETest(object):
 
     def asm(self):
         mn_x86 = self.machine.mn
-        blocks, loc_db = parse_asm.parse_txt(
+        blocks = parse_asm.parse_txt(
             mn_x86,
             self.arch_attrib,
             self.TXT,
-            loc_db=self.myjit.ir_arch.loc_db
+            self.loc_db
         )
 
         # fix shellcode addr
-        loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
+        self.loc_db.set_location_offset(self.loc_db.get_name_location("main"), 0x0)
         output = StrPatchwork()
-        patches = asm_resolve_final(mn_x86, blocks, loc_db)
+        patches = asm_resolve_final(mn_x86, blocks, self.loc_db)
         for offset, raw in viewitems(patches):
             output[offset] = raw
 
@@ -120,7 +122,7 @@ class DSEAttachInBreakpoint(DSETest):
 
     def bp_attach(self, jitter):
         """Attach a DSE in the current jitter"""
-        self.dse = DSEEngine(self.machine)
+        self.dse = DSEEngine(self.machine, self.loc_db)
         self.dse.attach(self.myjit)
         self.dse.update_state_from_concrete()
         self.dse.update_state({
diff --git a/test/arch/aarch64/unit/asm_test.py b/test/arch/aarch64/unit/asm_test.py
index fe59f0d8..d6ed5223 100644
--- a/test/arch/aarch64/unit/asm_test.py
+++ b/test/arch/aarch64/unit/asm_test.py
@@ -10,12 +10,14 @@ from miasm.core import asmblock
 from miasm.loader.strpatchwork import StrPatchwork
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import *
+from miasm.core.locationdb import LocationDB
 
 reg_and_id = dict(mn_aarch64.regs.all_regs_ids_byname)
 
 class Asm_Test(object):
     def __init__(self, jitter):
-        self.myjit = Machine("aarch64l").jitter(jitter)
+        self.loc_db = LocationDB()
+        self.myjit = Machine("aarch64l").jitter(self.loc_db, jitter)
         self.myjit.init_stack()
 
     def __call__(self):
@@ -24,12 +26,11 @@ class Asm_Test(object):
         self.check()
 
     def asm(self):
-        blocks, loc_db = parse_asm.parse_txt(mn_aarch64, 'l', self.TXT,
-                                                  loc_db = self.myjit.ir_arch.loc_db)
+        blocks = parse_asm.parse_txt(mn_aarch64, 'l', self.TXT, self.loc_db)
         # fix shellcode addr
-        loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
+        self.loc_db.set_location_offset(self.loc_db.get_name_location("main"), 0x0)
         s = StrPatchwork()
-        patches = asmblock.asm_resolve_final(mn_aarch64, blocks, loc_db)
+        patches = asmblock.asm_resolve_final(mn_aarch64, blocks, self.loc_db)
         for offset, raw in viewitems(patches):
             s[offset] = raw
 
diff --git a/test/arch/mep/jit/ut_helpers_jit.py b/test/arch/mep/jit/ut_helpers_jit.py
index 0c756e39..e031f5a8 100644
--- a/test/arch/mep/jit/ut_helpers_jit.py
+++ b/test/arch/mep/jit/ut_helpers_jit.py
@@ -5,6 +5,7 @@ from __future__ import print_function
 
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 
 def jit_instructions(mn_str):
@@ -13,6 +14,7 @@ def jit_instructions(mn_str):
     # Get the miasm Machine
     machine = Machine("mepb")
     mn_mep = machine.mn()
+    loc_db = LocationDB()
 
     # Assemble the instructions
     asm = b""
@@ -22,7 +24,7 @@ def jit_instructions(mn_str):
         asm += mn_mep.asm(instr)[0]
 
     # Init the jitter and add the assembled instructions to memory
-    jitter = machine.jitter(jit_type="gcc")
+    jitter = machine.jitter(loc_db, jit_type="gcc")
     jitter.vm.add_memory_page(0, PAGE_READ | PAGE_WRITE, asm)
 
     # Set the breakpoint
diff --git a/test/arch/mips32/unit/asm_test.py b/test/arch/mips32/unit/asm_test.py
index 2dcaf6fc..164cc143 100644
--- a/test/arch/mips32/unit/asm_test.py
+++ b/test/arch/mips32/unit/asm_test.py
@@ -10,6 +10,7 @@ from miasm.core import asmblock
 from miasm.loader.strpatchwork import StrPatchwork
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import *
+from miasm.core.locationdb import LocationDB
 
 
 reg_and_id = dict(mn_mips32.regs.all_regs_ids_byname)
@@ -17,7 +18,8 @@ reg_and_id = dict(mn_mips32.regs.all_regs_ids_byname)
 class Asm_Test(object):
 
     def __init__(self, jitter):
-        self.myjit = Machine("mips32l").jitter(jitter)
+        self.loc_db = LocationDB()
+        self.myjit = Machine("mips32l").jitter(self.loc_db, jitter)
         self.myjit.init_stack()
 
     def __call__(self):
@@ -26,12 +28,11 @@ class Asm_Test(object):
         self.check()
 
     def asm(self):
-        blocks, loc_db = parse_asm.parse_txt(mn_mips32, 'l', self.TXT,
-                                                  loc_db=self.myjit.ir_arch.loc_db)
+        blocks = parse_asm.parse_txt(mn_mips32, 'l', self.TXT, self.loc_db)
         # fix shellcode addr
-        loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
+        self.loc_db.set_location_offset(self.loc_db.get_name_location("main"), 0x0)
         s = StrPatchwork()
-        patches = asmblock.asm_resolve_final(mn_mips32, blocks, loc_db)
+        patches = asmblock.asm_resolve_final(mn_mips32, blocks, self.loc_db)
         for offset, raw in viewitems(patches):
             s[offset] = raw
 
diff --git a/test/arch/x86/qemu/testqemu.py b/test/arch/x86/qemu/testqemu.py
index 64312928..6a516ac3 100644
--- a/test/arch/x86/qemu/testqemu.py
+++ b/test/arch/x86/qemu/testqemu.py
@@ -13,6 +13,7 @@ except AttributeError:
 from miasm.analysis.sandbox import Sandbox_Linux_x86_32
 from miasm.jitter.jitload import log_func
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 # Utils
 def parse_fmt(s):
@@ -122,7 +123,8 @@ options = parser.parse_args()
 expected = open(options.expected)
 
 # Create sandbox
-sb = Sandbox_Linux_x86_32(options.filename, options, globals())
+loc_db = LocationDB()
+sb = Sandbox_Linux_x86_32(loc_db, options.filename, options, globals())
 try:
     addr = sb.elf.getsectionbyname(".symtab")[options.funcname].value
 except AttributeError:
diff --git a/test/arch/x86/qemu/testqemu64.py b/test/arch/x86/qemu/testqemu64.py
index 8d25ca68..b17abe66 100644
--- a/test/arch/x86/qemu/testqemu64.py
+++ b/test/arch/x86/qemu/testqemu64.py
@@ -13,6 +13,7 @@ except AttributeError:
 from miasm.analysis.sandbox import Sandbox_Linux_x86_64
 from miasm.jitter.jitload import log_func
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 # Utils
 def parse_fmt(s):
@@ -118,7 +119,8 @@ options = parser.parse_args()
 expected = open(options.expected)
 
 # Create sandbox
-sb = Sandbox_Linux_x86_64(options.filename, options, globals())
+loc_db = LocationDB()
+sb = Sandbox_Linux_x86_64(loc_db, options.filename, options, globals())
 try:
     addr = sb.elf.getsectionbyname(".symtab")[options.funcname].value
 except AttributeError:
diff --git a/test/arch/x86/sem.py b/test/arch/x86/sem.py
index 10980b05..3d40d44c 100755
--- a/test/arch/x86/sem.py
+++ b/test/arch/x86/sem.py
@@ -56,7 +56,8 @@ def compute(ir, mode, asm, inputstate={}, debug=False):
 
 
 def compute_txt(ir, mode, txt, inputstate={}, debug=False):
-    asmcfg, loc_db = parse_asm.parse_txt(mn, mode, txt)
+    loc_db = LocationDB()
+    asmcfg = parse_asm.parse_txt(mn, mode, txt, loc_db)
     loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
     patches = asmblock.asm_resolve_final(mn, asmcfg, loc_db)
     ir_arch = ir(loc_db)
diff --git a/test/arch/x86/unit/access_xmm.py b/test/arch/x86/unit/access_xmm.py
index 65248b2e..c7ecfb1e 100644
--- a/test/arch/x86/unit/access_xmm.py
+++ b/test/arch/x86/unit/access_xmm.py
@@ -2,9 +2,11 @@
 """Test getter and setter for XMM registers (128 bits)"""
 
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
 
 # Jitter engine doesn't matter, use the always available 'python' one
-myjit = Machine("x86_32").jitter("python")
+loc_db = LocationDB()
+myjit = Machine("x86_32").jitter(loc_db, "python")
 
 # Test basic access (get)
 assert myjit.cpu.XMM0 == 0
diff --git a/test/arch/x86/unit/asm_test.py b/test/arch/x86/unit/asm_test.py
index 6e7c55e2..d3ecf660 100644
--- a/test/arch/x86/unit/asm_test.py
+++ b/test/arch/x86/unit/asm_test.py
@@ -11,15 +11,16 @@ from miasm.expression.expression import *
 from miasm.core import asmblock
 from miasm.loader.strpatchwork import StrPatchwork
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
 from miasm.jitter.csts import *
 
 reg_and_id = dict(mn_x86.regs.all_regs_ids_byname)
-
 class Asm_Test(object):
     run_addr = 0x0
 
     def __init__(self, jitter_engine):
-        self.myjit = Machine(self.arch_name).jitter(jitter_engine)
+        self.loc_db = LocationDB()
+        self.myjit = Machine(self.arch_name).jitter(self.loc_db, jitter_engine)
         self.myjit.init_stack()
 
     def test_init(self):
@@ -44,12 +45,11 @@ class Asm_Test(object):
         assert(self.myjit.pc == self.ret_addr)
 
     def asm(self):
-        blocks, loc_db = parse_asm.parse_txt(mn_x86, self.arch_attrib, self.TXT,
-                                                  loc_db = self.myjit.ir_arch.loc_db)
+        blocks = parse_asm.parse_txt(mn_x86, self.arch_attrib, self.TXT, self.loc_db)
         # fix shellcode addr
-        loc_db.set_location_offset(loc_db.get_name_location("main"), 0x0)
+        self.loc_db.set_location_offset(self.loc_db.get_name_location("main"), 0x0)
         s = StrPatchwork()
-        patches = asmblock.asm_resolve_final(mn_x86, blocks, loc_db)
+        patches = asmblock.asm_resolve_final(mn_x86, blocks, self.loc_db)
         for offset, raw in viewitems(patches):
             s[offset] = raw
 
@@ -77,7 +77,8 @@ class Asm_Test_16(Asm_Test):
     ret_addr = 0x1337
 
     def __init__(self, jitter_engine):
-        self.myjit = Machine(self.arch_name).jitter(jitter_engine)
+        self.loc_db = LocationDB()
+        self.myjit = Machine(self.arch_name).jitter(self.loc_db, jitter_engine)
         self.myjit.stack_base = 0x1000
         self.myjit.stack_size = 0x1000
         self.myjit.init_stack()
diff --git a/test/arch/x86/unit/mn_pushpop.py b/test/arch/x86/unit/mn_pushpop.py
index 6dc37b74..c13f5989 100755
--- a/test/arch/x86/unit/mn_pushpop.py
+++ b/test/arch/x86/unit/mn_pushpop.py
@@ -21,7 +21,7 @@ class Test_PUSHAD_32(Asm_Test_32):
     MYSTRING = "test pushad 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -48,7 +48,7 @@ class Test_PUSHA_32(Asm_Test_32):
     MYSTRING = "test pusha 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -75,7 +75,7 @@ class Test_PUSHA_16(Asm_Test_16):
     MYSTRING = "test pusha 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -102,7 +102,7 @@ class Test_PUSHAD_16(Asm_Test_16):
     MYSTRING = "test pushad 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -129,7 +129,7 @@ class Test_PUSH_mode32_32(Asm_Test_32):
     MYSTRING = "test push mode32 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -152,7 +152,7 @@ class Test_PUSH_mode32_16(Asm_Test_32):
     MYSTRING = "test push mode32 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -175,7 +175,7 @@ class Test_PUSH_mode16_16(Asm_Test_16):
     MYSTRING = "test push mode16 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -198,7 +198,7 @@ class Test_PUSH_mode16_32(Asm_Test_16):
     MYSTRING = "test push mode16 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         init_regs(self)
@@ -221,7 +221,7 @@ class Test_POP_mode32_32(Asm_Test_32):
     MYSTRING = "test pop mode32 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         self.value = 0x11223344
@@ -243,7 +243,7 @@ class Test_POP_mode32_16(Asm_Test_32):
     MYSTRING = "test pop mode32 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         self.value = 0x1122
@@ -265,7 +265,7 @@ class Test_POP_mode16_16(Asm_Test_16):
     MYSTRING = "test pop mode16 16"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         self.value = 0x1122
@@ -287,7 +287,7 @@ class Test_POP_mode16_32(Asm_Test_16):
     MYSTRING = "test pop mode16 32"
 
     def prepare(self):
-        self.myjit.ir_arch.loc_db.add_location("lbl_ret", self.ret_addr)
+        self.loc_db.add_location("lbl_ret", self.ret_addr)
 
     def test_init(self):
         self.value = 0x11223344
diff --git a/test/arch/x86/unit/test_asm_x86_64.py b/test/arch/x86/unit/test_asm_x86_64.py
index e23f9a19..e1d99ec1 100644
--- a/test/arch/x86/unit/test_asm_x86_64.py
+++ b/test/arch/x86/unit/test_asm_x86_64.py
@@ -2,11 +2,13 @@ from miasm.core import asmblock
 from miasm.arch.x86  import arch
 from miasm.core import parse_asm
 from miasm.core.interval import interval
+from miasm.core.locationdb import LocationDB
 
 my_mn = arch.mn_x86
+loc_db = LocationDB()
 
-
-asmcfg, loc_db = parse_asm.parse_txt(my_mn, 64, r'''
+asmcfg = parse_asm.parse_txt(
+    my_mn, 64, r'''
 main:
   PUSH   RBP
   MOV    RBP, RSP
@@ -18,7 +20,9 @@ end:
   POP    RBP
   RET
 
-''')
+''',
+    loc_db
+)
 
 loc_db.set_location_offset(loc_db.get_name_location("main"), 0x100001000)
 dst_interval = interval([(0x100001000, 0x100002000)])
diff --git a/test/core/asmblock.py b/test/core/asmblock.py
index 47f92569..fa66f75b 100644
--- a/test/core/asmblock.py
+++ b/test/core/asmblock.py
@@ -12,14 +12,16 @@ from miasm.core.asmblock import AsmCFG, AsmConstraint, AsmBlock, \
     bbl_simplifier
 from miasm.core.graph import DiGraphSimplifier, MatchGraphJoker
 from miasm.expression.expression import ExprId
+from miasm.core.locationdb import LocationDB
 
 # Initial data: from 'samples/simple_test.bin'
 data = decode_hex("5589e583ec10837d08007509c745fc01100000eb73837d08017709c745fc02100000eb64837d08057709c745fc03100000eb55837d080774138b450801c083f80e7509c745fc04100000eb3c8b450801c083f80e7509c745fc05100000eb298b450883e03085c07409c745fc06100000eb16837d08427509c745fc07100000eb07c745fc081000008b45fcc9c3")
-cont = Container.from_string(data)
+loc_db = LocationDB()
+cont = Container.from_string(data, loc_db)
 
 # Test Disasm engine
 machine = Machine("x86_32")
-mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db)
+mdis = machine.dis_engine(cont.bin_stream, loc_db=loc_db)
 ## Disassembly of one block
 first_block = mdis.dis_block(0)
 assert len(first_block.lines) == 5
@@ -111,8 +113,8 @@ open("graph2.dot", "w").write(asmcfg.dot())
 # Test helper methods
 ## loc_key_to_block should always be updated
 assert asmcfg.loc_key_to_block(first_block.loc_key) == first_block
-testlabel = mdis.loc_db.get_or_create_name_location("testlabel")
-my_block = AsmBlock(testlabel)
+testlabel = loc_db.get_or_create_name_location("testlabel")
+my_block = AsmBlock(loc_db, testlabel)
 asmcfg.add_block(my_block)
 assert len(asmcfg) == 3
 assert asmcfg.loc_key_to_block(first_block.loc_key) == first_block
@@ -122,8 +124,8 @@ assert asmcfg.loc_key_to_block(my_block.loc_key) == my_block
 assert len(list(asmcfg.get_bad_blocks())) == 0
 assert len(list(asmcfg.get_bad_blocks_predecessors())) == 0
 ### Add a bad block, not linked
-testlabel_bad = mdis.loc_db.get_or_create_name_location("testlabel_bad")
-my_bad_block = AsmBlockBad(testlabel_bad)
+testlabel_bad = loc_db.get_or_create_name_location("testlabel_bad")
+my_bad_block = AsmBlockBad(loc_db, testlabel_bad)
 asmcfg.add_block(my_bad_block)
 assert list(asmcfg.get_bad_blocks()) == [my_bad_block]
 assert len(list(asmcfg.get_bad_blocks_predecessors())) == 0
@@ -141,8 +143,8 @@ assert len(list(asmcfg.get_bad_blocks_predecessors(strict=True))) == 0
 ## Sanity check
 asmcfg.sanity_check()
 ### Next on itself
-testlabel_nextitself = mdis.loc_db.get_or_create_name_location("testlabel_nextitself")
-my_block_ni = AsmBlock(testlabel_nextitself)
+testlabel_nextitself = loc_db.get_or_create_name_location("testlabel_nextitself")
+my_block_ni = AsmBlock(loc_db, testlabel_nextitself)
 my_block_ni.bto.add(AsmConstraintNext(my_block_ni.loc_key))
 asmcfg.add_block(my_block_ni)
 error_raised = False
@@ -155,13 +157,13 @@ assert error_raised
 asmcfg.del_block(my_block_ni)
 asmcfg.sanity_check()
 ### Multiple next on the same node
-testlabel_target = mdis.loc_db.get_or_create_name_location("testlabel_target")
-my_block_target = AsmBlock(testlabel_target)
+testlabel_target = loc_db.get_or_create_name_location("testlabel_target")
+my_block_target = AsmBlock(loc_db, testlabel_target)
 asmcfg.add_block(my_block_target)
-testlabel_src1 = mdis.loc_db.get_or_create_name_location("testlabel_src1")
-testlabel_src2 = mdis.loc_db.get_or_create_name_location("testlabel_src2")
-my_block_src1 = AsmBlock(testlabel_src1)
-my_block_src2 = AsmBlock(testlabel_src2)
+testlabel_src1 = loc_db.get_or_create_name_location("testlabel_src1")
+testlabel_src2 = loc_db.get_or_create_name_location("testlabel_src2")
+my_block_src1 = AsmBlock(loc_db, testlabel_src1)
+my_block_src2 = AsmBlock(loc_db, testlabel_src2)
 my_block_src1.bto.add(AsmConstraintNext(my_block_target.loc_key))
 asmcfg.add_block(my_block_src1)
 ### OK for now
@@ -190,10 +192,10 @@ assert asmcfg.loc_key_to_block(my_block_src1.loc_key).max_size == 0
 
 ## Check pendings
 ### Create a pending element
-testlabel_pend_src = mdis.loc_db.get_or_create_name_location("testlabel_pend_src")
-testlabel_pend_dst = mdis.loc_db.get_or_create_name_location("testlabel_pend_dst")
-my_block_src = AsmBlock(testlabel_pend_src)
-my_block_dst = AsmBlock(testlabel_pend_dst)
+testlabel_pend_src = loc_db.get_or_create_name_location("testlabel_pend_src")
+testlabel_pend_dst = loc_db.get_or_create_name_location("testlabel_pend_dst")
+my_block_src = AsmBlock(loc_db, testlabel_pend_src)
+my_block_dst = AsmBlock(loc_db, testlabel_pend_dst)
 my_block_src.bto.add(AsmConstraintTo(my_block_dst.loc_key))
 asmcfg.add_block(my_block_src)
 ### Check resulting state
@@ -220,8 +222,8 @@ asmcfg.sanity_check()
 
 # Test block_merge
 data2 = decode_hex("31c0eb0c31c9750c31d2eb0c31ffebf831dbebf031edebfc31f6ebf031e4c3")
-cont2 = Container.from_string(data2)
-mdis = machine.dis_engine(cont2.bin_stream, loc_db=cont2.loc_db)
+cont2 = Container.from_string(data2, loc_db)
+mdis = machine.dis_engine(cont2.bin_stream, loc_db=loc_db)
 ## Elements to merge
 asmcfg = mdis.dis_multiblock(0)
 ## Block alone
@@ -253,7 +255,7 @@ assert len(entry_block.lines) == 4
 assert list(map(str, entry_block.lines)) == ['XOR        EAX, EAX',
                                        'XOR        EBX, EBX',
                                        'XOR        ECX, ECX',
-                                       'JNZ        loc_key_3']
+                                       'JNZ        loc_key_27']
 assert len(asmcfg.successors(entry_block.loc_key)) == 2
 assert len(entry_block.bto) == 2
 nextb = asmcfg.loc_key_to_block(next((cons.loc_key for cons in entry_block.bto
@@ -264,11 +266,11 @@ assert len(nextb.lines) == 4
 assert list(map(str, nextb.lines)) == ['XOR        EDX, EDX',
                                  'XOR        ESI, ESI',
                                  'XOR        EDI, EDI',
-                                 'JMP        loc_key_4']
+                                 'JMP        loc_key_28']
 assert asmcfg.successors(nextb.loc_key) == [nextb.loc_key]
 assert len(tob.lines) == 2
 assert list(map(str, tob.lines)) == ['XOR        EBP, EBP',
-                               'JMP        loc_key_3']
+                               'JMP        loc_key_27']
 assert asmcfg.successors(tob.loc_key) == [tob.loc_key]
 
 # Check split_block
@@ -278,7 +280,7 @@ mdis.apply_splitting(asmcfg)
 assert asmcfg_bef == asmcfg
 open("graph5.dot", "w").write(asmcfg.dot())
 ## Create conditions for a block split
-inside_firstbbl = mdis.loc_db.get_offset_location(4)
+inside_firstbbl = loc_db.get_offset_location(4)
 tob.bto.add(AsmConstraintTo(inside_firstbbl))
 asmcfg.rebuild_edges()
 assert len(asmcfg.pendings) == 1
@@ -295,7 +297,7 @@ lbl_newb = asmcfg.successors(entry_block.loc_key)[0]
 newb = asmcfg.loc_key_to_block(lbl_newb)
 assert len(newb.lines) == 2
 assert list(map(str, newb.lines)) == ['XOR        ECX, ECX',
-                                'JNZ        loc_key_3']
+                                'JNZ        loc_key_27']
 preds = asmcfg.predecessors(lbl_newb)
 assert len(preds) == 2
 assert entry_block.loc_key in preds
@@ -306,8 +308,8 @@ assert asmcfg.edges2constraint[(tob.loc_key, lbl_newb)] == AsmConstraint.c_to
 
 # Check double block split
 data = decode_hex("74097405b8020000007405b803000000b804000000c3")
-cont = Container.from_string(data)
-mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db)
+cont = Container.from_string(data, loc_db)
+mdis = machine.dis_engine(cont.bin_stream, loc_db=loc_db)
 asmcfg = mdis.dis_multiblock(0)
 ## Check resulting disasm
 assert len(asmcfg.nodes()) == 6
@@ -328,10 +330,10 @@ solutions = list(matcher.match(asmcfg))
 assert len(solutions) == 1
 solution = solutions.pop()
 for jbbl, label in viewitems(solution):
-    offset = mdis.loc_db.get_location_offset(label)
+    offset = loc_db.get_location_offset(label)
     assert offset == int(jbbl._name, 16)
 
-loc_key_dum = mdis.loc_db.get_or_create_name_location("dummy_loc")
+loc_key_dum = loc_db.get_or_create_name_location("dummy_loc")
 asmcfg.add_node(loc_key_dum)
 error_raised = False
 try:
diff --git a/test/core/parse_asm.py b/test/core/parse_asm.py
index ab2bca4a..fdf1fbb8 100755
--- a/test/core/parse_asm.py
+++ b/test/core/parse_asm.py
@@ -3,6 +3,7 @@
 
 from builtins import range
 import unittest
+from miasm.core.locationdb import LocationDB
 
 
 class TestParseAsm(unittest.TestCase):
@@ -10,6 +11,7 @@ class TestParseAsm(unittest.TestCase):
     def test_ParseTxt(self):
         from miasm.arch.x86.arch import mn_x86
         from miasm.core.parse_asm import parse_txt
+        loc_db = LocationDB()
 
         ASM0 = '''
         ;
@@ -33,13 +35,14 @@ class TestParseAsm(unittest.TestCase):
         ASM1 = '''
         .XXX
         '''
-        self.assertTrue(parse_txt(mn_x86, 32, ASM0))
-        self.assertRaises(ValueError, parse_txt, mn_x86, 32, ASM1)
+        self.assertTrue(parse_txt(mn_x86, 32, ASM0, loc_db))
+        self.assertRaises(ValueError, parse_txt, mn_x86, 32, ASM1, loc_db)
 
     def test_DirectiveDontSplit(self):
         from miasm.arch.x86.arch import mn_x86
         from miasm.core.parse_asm import parse_txt
         from miasm.core.asmblock import asm_resolve_final
+        loc_db = LocationDB()
 
         ASM0 = '''
         lbl0:
@@ -65,10 +68,8 @@ class TestParseAsm(unittest.TestCase):
         .string "toto"
         '''
 
-        asmcfg, loc_db = parse_txt(mn_x86, 32, ASM0)
-        patches = asm_resolve_final(mn_x86,
-                                    asmcfg,
-                                    loc_db)
+        asmcfg = parse_txt(mn_x86, 32, ASM0, loc_db)
+        patches = asm_resolve_final(mn_x86, asmcfg, loc_db)
         lbls = []
         for i in range(6):
             lbls.append(loc_db.get_name_location('lbl%d' % i))
@@ -87,6 +88,7 @@ class TestParseAsm(unittest.TestCase):
     def test_DirectiveSplit(self):
         from miasm.arch.x86.arch import mn_x86
         from miasm.core.parse_asm import parse_txt
+        loc_db = LocationDB()
 
         ASM0 = '''
         lbl0:
@@ -96,7 +98,7 @@ class TestParseAsm(unittest.TestCase):
             RET
         '''
 
-        asmcfg, loc_db = parse_txt(mn_x86, 32, ASM0)
+        asmcfg = parse_txt(mn_x86, 32, ASM0, loc_db)
         lbls = []
         for i in range(2):
             lbls.append(loc_db.get_name_location('lbl%d' % i))
diff --git a/test/core/test_types.py b/test/core/test_types.py
index 13a7824e..b903b809 100755
--- a/test/core/test_types.py
+++ b/test/core/test_types.py
@@ -14,6 +14,7 @@ from miasm.core.types import MemStruct, Num, Ptr, Str, \
                               set_allocator, MemUnion, Struct
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
 from miasm.os_dep.common import heap
+from miasm.core.locationdb import LocationDB
 
 # Two structures with some fields
 class OtherStruct(MemStruct):
@@ -35,7 +36,8 @@ class MyStruct(MemStruct):
         ("i", Ptr("I", Num("I"))),
     ]
 
-jitter = Machine("x86_32").jitter("python")
+loc_db = LocationDB()
+jitter = Machine("x86_32").jitter(loc_db, "python")
 jitter.init_stack()
 addr = 0x1000
 size = 0x1000
diff --git a/test/jitter/bad_block.py b/test/jitter/bad_block.py
index 256d2388..e7484c9e 100644
--- a/test/jitter/bad_block.py
+++ b/test/jitter/bad_block.py
@@ -2,6 +2,7 @@ import sys
 from miasm.core.utils import decode_hex
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_UNK_MNEMO
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
 
 def code_sentinelle(jitter):
     jitter.run = False
@@ -9,7 +10,8 @@ def code_sentinelle(jitter):
     return True
 
 machine = Machine("x86_32")
-jitter = machine.jitter(sys.argv[1])
+loc_db = LocationDB()
+jitter = machine.jitter(loc_db, sys.argv[1])
 
 jitter.init_stack()
 
diff --git a/test/jitter/jit_options.py b/test/jitter/jit_options.py
index 74808330..f1258323 100644
--- a/test/jitter/jit_options.py
+++ b/test/jitter/jit_options.py
@@ -5,6 +5,7 @@ import sys
 from miasm.core.utils import decode_hex
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
 from pdb import pm
 
 # Shellcode
@@ -21,16 +22,17 @@ from pdb import pm
 
 data = decode_hex("b810000000bb0100000083e8010f44cb75f8c3")
 run_addr = 0x40000000
+loc_db = LocationDB()
 
 def code_sentinelle(jitter):
     jitter.run = False
     jitter.pc = 0
     return True
 
-def init_jitter():
+def init_jitter(loc_db):
     global data, run_addr
     # Create jitter
-    myjit = Machine("x86_32").jitter(sys.argv[1])
+    myjit = Machine("x86_32").jitter(loc_db, sys.argv[1])
 
     myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data)
 
@@ -44,7 +46,7 @@ def init_jitter():
 
 # Test 'max_exec_per_call'
 print("[+] First run, to jit blocks")
-myjit = init_jitter()
+myjit = init_jitter(loc_db)
 myjit.init_run(run_addr)
 myjit.continue_run()
 
@@ -78,7 +80,7 @@ assert myjit.cpu.EAX >= 0xA
 
 # Test 'jit_maxline'
 print("[+] Run instr one by one")
-myjit = init_jitter()
+myjit = init_jitter(loc_db)
 myjit.jit.options["jit_maxline"] = 1
 myjit.jit.options["max_exec_per_call"] = 1
 
diff --git a/test/jitter/jitcore.py b/test/jitter/jitcore.py
index 75360542..1e009d9a 100644
--- a/test/jitter/jitcore.py
+++ b/test/jitter/jitcore.py
@@ -1,8 +1,10 @@
 import sys
+from miasm.core.locationdb import LocationDB
 
 from miasm.analysis.machine import Machine
 machine = Machine("x86_64")
-jitter = machine.jitter(sys.argv[1])
+loc_db = LocationDB()
+jitter = machine.jitter(loc_db, sys.argv[1])
 
 jitter.cpu.RAX = 16565615892967251934
 assert jitter.cpu.RAX == 16565615892967251934
diff --git a/test/jitter/jitload.py b/test/jitter/jitload.py
index 3038c21c..7a72d1d5 100644
--- a/test/jitter/jitload.py
+++ b/test/jitter/jitload.py
@@ -5,12 +5,15 @@ from miasm.core.utils import decode_hex, encode_hex
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
 from miasm.analysis.machine import Machine
 from miasm.expression.expression import ExprId, ExprAssign, ExprInt, ExprMem
+from miasm.core.locationdb import LocationDB
+
 
 # Initial data: from 'example/samples/x86_32_sc.bin'
 data = decode_hex("8d49048d5b0180f90174058d5bffeb038d5b0189d8c3")
+loc_db = LocationDB()
 
 # Init jitter
-myjit = Machine("x86_32").jitter(sys.argv[1])
+myjit = Machine("x86_32").jitter(loc_db, sys.argv[1])
 myjit.init_stack()
 
 run_addr = 0x40000000
diff --git a/test/jitter/jmp_out_mem.py b/test/jitter/jmp_out_mem.py
index 2b064f73..3d01aacc 100644
--- a/test/jitter/jmp_out_mem.py
+++ b/test/jitter/jmp_out_mem.py
@@ -2,6 +2,8 @@ import sys
 from miasm.core.utils import decode_hex
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, EXCEPT_ACCESS_VIOL
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
+
 
 def code_sentinelle(jitter):
     jitter.run = False
@@ -10,7 +12,8 @@ def code_sentinelle(jitter):
 
 
 machine = Machine("x86_32")
-jitter = machine.jitter(sys.argv[1])
+loc_db = LocationDB()
+jitter = machine.jitter(loc_db, sys.argv[1])
 
 jitter.init_stack()
 
diff --git a/test/jitter/mem_breakpoint.py b/test/jitter/mem_breakpoint.py
index 502d3d2b..8a5d69c5 100644
--- a/test/jitter/mem_breakpoint.py
+++ b/test/jitter/mem_breakpoint.py
@@ -5,6 +5,7 @@ from miasm.core.utils import decode_hex
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, \
     EXCEPT_BREAKPOINT_MEMORY, EXCEPT_ACCESS_VIOL
+from miasm.core.locationdb import LocationDB
 
 def mem_breakpoint_handler(jitter):
     print("======")
@@ -35,7 +36,8 @@ def mem_breakpoint_handler(jitter):
     return True
 
 machine = Machine("aarch64l")
-jitter = machine.jitter(sys.argv[1])
+loc_db = LocationDB()
+jitter = machine.jitter(loc_db, sys.argv[1])
 
 start_addr = 0xFFFFFF8008080000
 end_addr = start_addr + 0x8000000
diff --git a/test/jitter/test_post_instr.py b/test/jitter/test_post_instr.py
index 52274a46..16e51830 100644
--- a/test/jitter/test_post_instr.py
+++ b/test/jitter/test_post_instr.py
@@ -5,9 +5,11 @@ from miasm.core.utils import decode_hex
 from miasm.analysis.machine import Machine
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE, \
     EXCEPT_BREAKPOINT_MEMORY, EXCEPT_ACCESS_VIOL
+from miasm.core.locationdb import LocationDB
 
 machine = Machine("x86_32")
-jitter = machine.jitter(sys.argv[1])
+loc_db = LocationDB()
+jitter = machine.jitter(loc_db, sys.argv[1])
 
 # Prepare stack and reset memory accesses to avoid an exception
 jitter.vm.add_memory_page(0x10000, PAGE_READ|PAGE_WRITE, b"\x00"*0x1000, "stack")
diff --git a/test/jitter/vm_mngr.py b/test/jitter/vm_mngr.py
index 0fec1734..404d20fe 100644
--- a/test/jitter/vm_mngr.py
+++ b/test/jitter/vm_mngr.py
@@ -1,8 +1,10 @@
 import sys
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
 from miasm.analysis.machine import Machine
+from miasm.core.locationdb import LocationDB
 
-myjit = Machine("x86_32").jitter(sys.argv[1])
+loc_db = LocationDB()
+myjit = Machine("x86_32").jitter(loc_db, sys.argv[1])
 
 base_addr = 0x13371337
 page_size = 0x1000
diff --git a/test/os_dep/common.py b/test/os_dep/common.py
index 749d71a7..ca7b8bc1 100755
--- a/test/os_dep/common.py
+++ b/test/os_dep/common.py
@@ -8,10 +8,12 @@ from miasm.analysis.machine import Machine
 import miasm.os_dep.common as commonapi
 from miasm.core.utils import pck32
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 machine = Machine("x86_32")
 
-jit = machine.jitter()
+loc_db = LocationDB()
+jit = machine.jitter(loc_db)
 jit.init_stack()
 
 class TestCommonAPI(unittest.TestCase):
diff --git a/test/os_dep/linux/stdlib.py b/test/os_dep/linux/stdlib.py
index a0432e65..c57499c7 100755
--- a/test/os_dep/linux/stdlib.py
+++ b/test/os_dep/linux/stdlib.py
@@ -7,10 +7,12 @@ from miasm.analysis.machine import Machine
 import miasm.os_dep.linux_stdlib as stdlib
 from miasm.core.utils import pck32
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 machine = Machine("x86_32")
 
-jit = machine.jitter()
+loc_db = LocationDB()
+jit = machine.jitter(loc_db)
 jit.init_stack()
 
 heap = stdlib.linobjs.heap
diff --git a/test/os_dep/linux/test_env.py b/test/os_dep/linux/test_env.py
index 13351a84..5bf3d2a0 100644
--- a/test/os_dep/linux/test_env.py
+++ b/test/os_dep/linux/test_env.py
@@ -5,6 +5,7 @@ from pdb import pm
 from miasm.analysis.binary import Container
 from miasm.analysis.sandbox import Sandbox_Linux_x86_32, Sandbox_Linux_x86_64,\
     Sandbox_Linux_arml, Sandbox_Linux_aarch64l
+from miasm.core.locationdb import LocationDB
 
 if len(sys.argv) < 2:
     print("Usage: %s <arch> ..." % sys.argv[0])
@@ -29,7 +30,8 @@ parser.add_argument("filename", help="ELF Filename")
 options = parser.parse_args(sys.argv[2:])
 
 # Create sandbox
-sb = sandbox(options.filename, options, globals())
+loc_db = LocationDB()
+sb = sandbox(loc_db, options.filename, options, globals())
 
 # Run
 sb.run()
diff --git a/test/os_dep/win_api_x86_32.py b/test/os_dep/win_api_x86_32.py
index 6d1c9835..19a3a9f7 100755
--- a/test/os_dep/win_api_x86_32.py
+++ b/test/os_dep/win_api_x86_32.py
@@ -9,10 +9,12 @@ import miasm.os_dep.win_api_x86_32 as winapi
 from miasm.os_dep.win_api_x86_32 import get_win_str_a, get_win_str_w
 from miasm.core.utils import pck32
 from miasm.jitter.csts import PAGE_READ, PAGE_WRITE
+from miasm.core.locationdb import LocationDB
 
 machine = Machine("x86_32")
 
-jit = machine.jitter()
+loc_db = LocationDB()
+jit = machine.jitter(loc_db)
 jit.init_stack()
 
 heap = winapi.winobjs.heap