From 6c5ef00f76ab8861ece3f4de28080f84a1a4ee2d Mon Sep 17 00:00:00 2001 From: "elena.totmenina" Date: Thu, 23 Sep 2021 16:58:01 +0300 Subject: [PATCH 01/16] Add tests --- numba_dppy/tests/test_debug_dppy_numba.py | 194 ++++++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 28f66f6f97..48df5e7d7f 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -66,6 +66,42 @@ def run(self, script): self.child.expect("(gdb)", timeout=5) self.child.sendline("run " + self.script_path(script)) + def backtrace(self): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("backtrace") + + def print(self, var): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("print " + var) + + def info_functions(self, function): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("info functions " + function) + + def info_locals(self): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("info locals") + + def next(self): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("next") + + def ptype(self, var): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("ptype " + var) + + def whatis(self, var): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("whatis " + var) + + def step(self): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("step") + + def stepi(self): + self.child.expect("(gdb)", timeout=5) + self.child.sendline("stepi") + @staticmethod def script_path(script): package_path = pathlib.Path(numba_dppy.__file__).parent @@ -81,3 +117,161 @@ def test_breakpoint_row_number(api): app.child.expect(r"Thread .* hit Breakpoint .* at dppy_numba_basic.py:25") app.child.expect(r"25\s+param_c = param_a \+ 10") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_backtrace(api): + app = gdb() + + app.breakpoint("simple_dppy_func.py:22") + app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.backtrace() + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") + app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + app.child.expect(r"\#0\s+__main__::func_sum \(\) at simple_dppy_func.py:22") + app.child.expect(r"\#1\s+__main__::kernel_sum \(\) at simple_dppy_func.py:29") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_break_conditional(api): + app = gdb() + + app.breakpoint("simple_sum.py:23 if i == 1") + app.run("simple_sum.py --api={api}".format(api=api)) + app.print("i") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") + app.child.expect(r"23\s+c\[i\] = a\[i\] \+ b\[i\]") + app.child.expect(r"\$1 = 1") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_break_file_function(api): + app = gdb() + + app.breakpoint("simple_sum.py:data_parallel_sum") + app.run("simple_sum.py --api={api}".format(api=api)) + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") + app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_break_function(api): + app = gdb() + + app.breakpoint("data_parallel_sum") + app.run("simple_sum.py --api={api}".format(api=api)) + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") + app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_break_nested_function(api): + app = gdb() + + app.breakpoint("simple_dppy_func.py:func_sum") + app.run("simple_dppy_func.py --api={api}".format(api=api)) + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") + app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_info_functions(api): + app = gdb() + + app.breakpoint("simple_sum.py:22") + app.run("simple_sum.py --api={api}".format(api=api)) + app.info_functions("data_parallel_sum") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") + app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + app.child.expect(r"20:\s+void __main__::data_parallel_sum\(DPPYArray\, .*\);") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_local_variables(api): + app = gdb() + + app.breakpoint("sum_local_vars.py:22") + app.run("sum_local_vars.py --api={api}".format(api=api)) + app.info_locals() + app.next() + app.next() + app.next() + app.next() + app.print("a") + app.print("l1") + app.print("l2") + app.ptype("a") + app.whatis("a") + app.ptype("l1") + app.whatis("l1") + + app.child.expect(r"Thread .* hit Breakpoint .* at sum_local_vars.py:22") + app.child.expect(r"22\s+i = dppy.get_global_id\(0\)") + app.child.expect(r"a = '\\000' \") + app.child.expect(r"b = '\\000' \") + app.child.expect(r"c = '\\000' \") + app.child.expect(r"i = .*") + app.child.expect(r"l1 = .*") + app.child.expect(r"l2 = .*") + app.child.expect(r"__ocl_dbg_gid0 = .*") + app.child.expect(r"__ocl_dbg_gid1 = .*") + app.child.expect(r"__ocl_dbg_gid2 = .*") + app.child.expect(r"__ocl_dbg_lid0 = .*") + app.child.expect(r"__ocl_dbg_lid1 = .*") + app.child.expect(r"__ocl_dbg_lid2 = .*") + app.child.expect(r"__ocl_dbg_grid0 = .*") + app.child.expect(r"__ocl_dbg_grid1 = .*") + app.child.expect(r"__ocl_dbg_grid2 = .*") + app.child.expect(r"\$1 = '\\000' \") + app.child.expect(r"\$3 = 2.5931931659579277") + app.child.expect(r"\$4 = 0.22954882979393004") + app.child.expect(r"type = byte \[56\]") + app.child.expect(r"type = double") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_next(api): + app = gdb() + + app.breakpoint("simple_dppy_func.py:29") + app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.next() + app.next() + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") + app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") + app.child.expect(r"Done\.\.\.") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_step(api): + app = gdb() + + app.breakpoint("simple_dppy_func.py:29") + app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.step() + app.step() + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") + app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") + app.child.expect(r"__main__::func_sum \(\) at simple_dppy_func.py:22") + app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + + +@pytest.mark.parametrize("api", ["numba-dppy"]) +def test_step(api): + app = gdb() + + app.breakpoint("simple_dppy_func.py:29") + app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.stepi() + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") + app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") + app.child.expect(r".+29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\])") From aa692070150b09844c08140a141b01592f5da760 Mon Sep 17 00:00:00 2001 From: "elena.totmenina" Date: Thu, 23 Sep 2021 17:20:28 +0300 Subject: [PATCH 02/16] fix --- numba_dppy/tests/test_debug_dppy_numba.py | 80 +++++++++++++---------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 48df5e7d7f..bbb1ad04ef 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -119,12 +119,12 @@ def test_breakpoint_row_number(api): app.child.expect(r"25\s+param_c = param_a \+ 10") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_backtrace(api): +# commands/backtrace +def test_backtrace(): app = gdb() app.breakpoint("simple_dppy_func.py:22") - app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.run("simple_dppy_func.py") app.backtrace() app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") @@ -133,12 +133,12 @@ def test_backtrace(api): app.child.expect(r"\#1\s+__main__::kernel_sum \(\) at simple_dppy_func.py:29") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_break_conditional(api): +# commands/break_conditional +def test_break_conditional(): app = gdb() app.breakpoint("simple_sum.py:23 if i == 1") - app.run("simple_sum.py --api={api}".format(api=api)) + app.run("simple_sum.py") app.print("i") app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") @@ -146,58 +146,60 @@ def test_break_conditional(api): app.child.expect(r"\$1 = 1") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_break_file_function(api): +# commands/break_file_func +def test_break_file_function(): app = gdb() app.breakpoint("simple_sum.py:data_parallel_sum") - app.run("simple_sum.py --api={api}".format(api=api)) + app.run("simple_sum.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_break_function(api): +# commands/break_func +def test_break_function(): app = gdb() app.breakpoint("data_parallel_sum") - app.run("simple_sum.py --api={api}".format(api=api)) + app.run("simple_sum.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_break_nested_function(api): +# commands/break_nested_func +def test_break_nested_function(): app = gdb() app.breakpoint("simple_dppy_func.py:func_sum") - app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.run("simple_dppy_func.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") app.child.expect(r"22\s+result = a_in_func \+ b_in_func") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_info_functions(api): +# commands/info_func +def test_info_functions(): app = gdb() app.breakpoint("simple_sum.py:22") - app.run("simple_sum.py --api={api}".format(api=api)) + app.run("simple_sum.py") app.info_functions("data_parallel_sum") app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") app.child.expect(r"22\s+result = a_in_func \+ b_in_func") - app.child.expect(r"20:\s+void __main__::data_parallel_sum\(DPPYArray\, .*\);") + app.child.expect( + r"20:\s+void __main__::data_parallel_sum\(DPPYArray\, .*\);" + ) -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_local_variables(api): +# commands/local_variables_0 +def test_local_variables(): app = gdb() app.breakpoint("sum_local_vars.py:22") - app.run("sum_local_vars.py --api={api}".format(api=api)) + app.run("sum_local_vars.py") app.info_locals() app.next() app.next() @@ -235,43 +237,51 @@ def test_local_variables(api): app.child.expect(r"type = double") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_next(api): +# commands/next +def test_next(): app = gdb() app.breakpoint("simple_dppy_func.py:29") - app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.run("simple_dppy_func.py") app.next() app.next() app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") - app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") + app.child.expect( + r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + ) app.child.expect(r"Done\.\.\.") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_step(api): +# commands/step_dppy_func +def test_step(): app = gdb() app.breakpoint("simple_dppy_func.py:29") - app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.run("simple_dppy_func.py") app.step() app.step() app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") - app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") + app.child.expect( + r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + ) app.child.expect(r"__main__::func_sum \(\) at simple_dppy_func.py:22") app.child.expect(r"22\s+result = a_in_func \+ b_in_func") -@pytest.mark.parametrize("api", ["numba-dppy"]) -def test_step(api): +# commands/stepi +def test_stepi(): app = gdb() app.breakpoint("simple_dppy_func.py:29") - app.run("simple_dppy_func.py --api={api}".format(api=api)) + app.run("simple_dppy_func.py") app.stepi() app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") - app.child.expect(r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)") - app.child.expect(r".+29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\])") + app.child.expect( + r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + ) + app.child.expect( + r".+29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\])" + ) From ee4d97ce88af2a0e6f86e36d26798745608d12ce Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Thu, 23 Sep 2021 20:33:56 +0300 Subject: [PATCH 03/16] Fix test_backtrace --- numba_dppy/tests/test_debug_dppy_numba.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index bbb1ad04ef..05a3df43d3 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -123,14 +123,16 @@ def test_breakpoint_row_number(api): def test_backtrace(): app = gdb() - app.breakpoint("simple_dppy_func.py:22") + app.breakpoint("simple_dppy_func.py:23") app.run("simple_dppy_func.py") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:23") + app.child.expect(r"23\s+result = a_in_func \+ b_in_func") + app.backtrace() - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") - app.child.expect(r"22\s+result = a_in_func \+ b_in_func") - app.child.expect(r"\#0\s+__main__::func_sum \(\) at simple_dppy_func.py:22") - app.child.expect(r"\#1\s+__main__::kernel_sum \(\) at simple_dppy_func.py:29") + app.child.expect(r"#0.*__main__::func_sum .* at simple_dppy_func.py:23") + app.child.expect(r"#1.*__main__::kernel_sum .* at simple_dppy_func.py:30") # commands/break_conditional From 27afffb6d81ff764dbec59782eabe46e2030e2d8 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:29:46 +0300 Subject: [PATCH 04/16] Fix test_break_conditional --- numba_dppy/tests/test_debug_dppy_numba.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 05a3df43d3..998ac3be6d 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -139,12 +139,14 @@ def test_backtrace(): def test_break_conditional(): app = gdb() - app.breakpoint("simple_sum.py:23 if i == 1") + app.breakpoint("simple_sum.py:24 if i == 1") app.run("simple_sum.py") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:24") + app.child.expect(r"24\s+c\[i\] = a\[i\] \+ b\[i\]") + app.print("i") - app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") - app.child.expect(r"23\s+c\[i\] = a\[i\] \+ b\[i\]") app.child.expect(r"\$1 = 1") From afdea85fd861208d92a73bfb2130f29fef756a1d Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:37:31 +0300 Subject: [PATCH 05/16] Fix test_break_file_function --- numba_dppy/tests/test_debug_dppy_numba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 998ac3be6d..e93b232ed0 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -157,8 +157,8 @@ def test_break_file_function(): app.breakpoint("simple_sum.py:data_parallel_sum") app.run("simple_sum.py") - app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") - app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") + app.child.expect(r"23\s*i = dppy.get_global_id\(0\)") # commands/break_func From e309405bf1de7f5b1ee9346fd20e3347048a4fec Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:38:49 +0300 Subject: [PATCH 06/16] Fix test_break_function --- numba_dppy/tests/test_debug_dppy_numba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index e93b232ed0..b6db4982c5 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -168,8 +168,8 @@ def test_break_function(): app.breakpoint("data_parallel_sum") app.run("simple_sum.py") - app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:20") - app.child.expect(r"20\s+@dppy\.kernel\(debug=True\)") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") + app.child.expect(r"23\s*i = dppy.get_global_id\(0\)") # commands/break_nested_func From 3d49ce434cf458e12959bcd3936e4945797080d7 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:41:05 +0300 Subject: [PATCH 07/16] Fix test_break_nested_function --- numba_dppy/tests/test_debug_dppy_numba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index b6db4982c5..e569e19420 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -179,8 +179,8 @@ def test_break_nested_function(): app.breakpoint("simple_dppy_func.py:func_sum") app.run("simple_dppy_func.py") - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") - app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:23") + app.child.expect(r"23\s+result = a_in_func \+ b_in_func") # commands/info_func From dd3e3819aca607b3fb00b62e7118eb51246e4288 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:41:37 +0300 Subject: [PATCH 08/16] Use \s+ for whitespaces --- numba_dppy/tests/test_debug_dppy_numba.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index e569e19420..9708ed4fa2 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -158,7 +158,7 @@ def test_break_file_function(): app.run("simple_sum.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") - app.child.expect(r"23\s*i = dppy.get_global_id\(0\)") + app.child.expect(r"23\s+i = dppy.get_global_id\(0\)") # commands/break_func @@ -169,7 +169,7 @@ def test_break_function(): app.run("simple_sum.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") - app.child.expect(r"23\s*i = dppy.get_global_id\(0\)") + app.child.expect(r"23\s+i = dppy.get_global_id\(0\)") # commands/break_nested_func From 698ad3c37a8101c5f7e01d9cde8d9afa70c51220 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:44:55 +0300 Subject: [PATCH 09/16] Fix test_info_functions --- numba_dppy/tests/test_debug_dppy_numba.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 9708ed4fa2..1b64c69d5b 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -189,13 +189,13 @@ def test_info_functions(): app.breakpoint("simple_sum.py:22") app.run("simple_sum.py") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_sum.py:23") + app.child.expect(r"23\s+i = dppy.get_global_id\(0\)") + app.info_functions("data_parallel_sum") - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:22") - app.child.expect(r"22\s+result = a_in_func \+ b_in_func") - app.child.expect( - r"20:\s+void __main__::data_parallel_sum\(DPPYArray\, .*\);" - ) + app.child.expect(r"21:\s+void __main__::data_parallel_sum\(.*\);") # commands/local_variables_0 From 3e1e3514a477dfb171e47628c4c75721b1545a18 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:57:09 +0300 Subject: [PATCH 10/16] Fix test_local_variables --- numba_dppy/tests/test_debug_dppy_numba.py | 52 +++++++++++------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 1b64c69d5b..d6681f54fe 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -202,42 +202,40 @@ def test_info_functions(): def test_local_variables(): app = gdb() - app.breakpoint("sum_local_vars.py:22") + app.breakpoint("sum_local_vars.py:26") app.run("sum_local_vars.py") + + app.child.expect(r"Thread .* hit Breakpoint .* at sum_local_vars.py:26") + app.child.expect(r"26\s+c\[i\] = l1 \+ l2") + app.info_locals() - app.next() - app.next() - app.next() - app.next() + + app.child.expect(r"a = .*") + app.child.expect(r"b = .*") + app.child.expect(r"c = .*") + app.child.expect(r"i = 0") + app.child.expect(r"l1 = [0-9]\.[0-9]{3}") + app.child.expect(r"l2 = [0-9]\.[0-9]{3}") + app.print("a") + app.child.expect(r"\$1 = '\\000' \") + app.print("l1") + app.child.expect(r"\$2 = [0-9]\.[0-9]{3}") + app.print("l2") + app.child.expect(r"\$3 = [0-9]\.[0-9]{3}") + app.ptype("a") + app.child.expect(r"type = byte \[56\]") + app.whatis("a") + app.child.expect(r"type = byte \[56\]") + app.ptype("l1") - app.whatis("l1") + app.child.expect(r"type = double") - app.child.expect(r"Thread .* hit Breakpoint .* at sum_local_vars.py:22") - app.child.expect(r"22\s+i = dppy.get_global_id\(0\)") - app.child.expect(r"a = '\\000' \") - app.child.expect(r"b = '\\000' \") - app.child.expect(r"c = '\\000' \") - app.child.expect(r"i = .*") - app.child.expect(r"l1 = .*") - app.child.expect(r"l2 = .*") - app.child.expect(r"__ocl_dbg_gid0 = .*") - app.child.expect(r"__ocl_dbg_gid1 = .*") - app.child.expect(r"__ocl_dbg_gid2 = .*") - app.child.expect(r"__ocl_dbg_lid0 = .*") - app.child.expect(r"__ocl_dbg_lid1 = .*") - app.child.expect(r"__ocl_dbg_lid2 = .*") - app.child.expect(r"__ocl_dbg_grid0 = .*") - app.child.expect(r"__ocl_dbg_grid1 = .*") - app.child.expect(r"__ocl_dbg_grid2 = .*") - app.child.expect(r"\$1 = '\\000' \") - app.child.expect(r"\$3 = 2.5931931659579277") - app.child.expect(r"\$4 = 0.22954882979393004") - app.child.expect(r"type = byte \[56\]") + app.whatis("l1") app.child.expect(r"type = double") From c4436f4de4374cbc7e51c8680ce6e75fb9da0748 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 10:59:49 +0300 Subject: [PATCH 11/16] Fix test_next --- numba_dppy/tests/test_debug_dppy_numba.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index d6681f54fe..76c3727805 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -243,15 +243,17 @@ def test_local_variables(): def test_next(): app = gdb() - app.breakpoint("simple_dppy_func.py:29") + app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") - app.next() - app.next() - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:30") app.child.expect( - r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + r"30\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" ) + + app.next() + app.next() + app.child.expect(r"Done\.\.\.") From 96a6c310a7c5c3dbec863f92f95c9c0b7f65b33c Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 11:31:35 +0300 Subject: [PATCH 12/16] Fix test_step --- numba_dppy/tests/test_debug_dppy_numba.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 76c3727805..fb496c114a 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -261,17 +261,18 @@ def test_next(): def test_step(): app = gdb() - app.breakpoint("simple_dppy_func.py:29") + app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:30") + app.child.expect( + r"30\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + ) + app.step() app.step() - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") - app.child.expect( - r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" - ) - app.child.expect(r"__main__::func_sum \(\) at simple_dppy_func.py:22") - app.child.expect(r"22\s+result = a_in_func \+ b_in_func") + app.child.expect(r"__main__::func_sum \(\) at simple_dppy_func.py:23") + app.child.expect(r"23\s+result = a_in_func \+ b_in_func") # commands/stepi From c75bbcb89f4593163617cb75060f2842797a92e4 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 11:39:29 +0300 Subject: [PATCH 13/16] Fix test_stepi --- numba_dppy/tests/test_debug_dppy_numba.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index fb496c114a..5a74e8c307 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -279,14 +279,24 @@ def test_step(): def test_stepi(): app = gdb() - app.breakpoint("simple_dppy_func.py:29") + app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") + + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:30") + app.child.expect( + r"30\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + ) + app.stepi() - app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:29") app.child.expect( - r"29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" + r"0x[0-f]+\s+30\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" ) + + app.stepi() + + app.child.expect(r"Switching to Thread") + app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:30") app.child.expect( - r".+29\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\])" + r"30\s+c_in_kernel\[i\] = func_sum\(a_in_kernel\[i\], b_in_kernel\[i\]\)" ) From a5316ead55910eddbf660f9abaa78781f1b07011 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 12:08:10 +0300 Subject: [PATCH 14/16] Fix test_local_variables --- numba_dppy/tests/test_debug_dppy_numba.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 5a74e8c307..584fdb60c9 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -210,9 +210,9 @@ def test_local_variables(): app.info_locals() - app.child.expect(r"a = .*") - app.child.expect(r"b = .*") - app.child.expect(r"c = .*") + app.child.expect(r"a =") + app.child.expect(r"b =") + app.child.expect(r"c =") app.child.expect(r"i = 0") app.child.expect(r"l1 = [0-9]\.[0-9]{3}") app.child.expect(r"l2 = [0-9]\.[0-9]{3}") From 805d9008668f96c45e65413b9ec4dc95f151afb1 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 12:22:19 +0300 Subject: [PATCH 15/16] Use fixture for GDB app --- numba_dppy/tests/test_debug_dppy_numba.py | 49 ++++++++--------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 584fdb60c9..603d3003ce 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -108,10 +108,13 @@ def script_path(script): return str(package_path / "examples/debug" / script) -@pytest.mark.parametrize("api", ["numba", "numba-dppy"]) -def test_breakpoint_row_number(api): - app = gdb() +@pytest.fixture +def app(): + return gdb() + +@pytest.mark.parametrize("api", ["numba", "numba-dppy"]) +def test_breakpoint_row_number(app, api): app.breakpoint("dppy_numba_basic.py:25") app.run("dppy_numba_basic.py --api={api}".format(api=api)) @@ -120,9 +123,7 @@ def test_breakpoint_row_number(api): # commands/backtrace -def test_backtrace(): - app = gdb() - +def test_backtrace(app): app.breakpoint("simple_dppy_func.py:23") app.run("simple_dppy_func.py") @@ -136,9 +137,7 @@ def test_backtrace(): # commands/break_conditional -def test_break_conditional(): - app = gdb() - +def test_break_conditional(app): app.breakpoint("simple_sum.py:24 if i == 1") app.run("simple_sum.py") @@ -151,9 +150,7 @@ def test_break_conditional(): # commands/break_file_func -def test_break_file_function(): - app = gdb() - +def test_break_file_function(app): app.breakpoint("simple_sum.py:data_parallel_sum") app.run("simple_sum.py") @@ -162,9 +159,7 @@ def test_break_file_function(): # commands/break_func -def test_break_function(): - app = gdb() - +def test_break_function(app): app.breakpoint("data_parallel_sum") app.run("simple_sum.py") @@ -173,9 +168,7 @@ def test_break_function(): # commands/break_nested_func -def test_break_nested_function(): - app = gdb() - +def test_break_nested_function(app): app.breakpoint("simple_dppy_func.py:func_sum") app.run("simple_dppy_func.py") @@ -184,9 +177,7 @@ def test_break_nested_function(): # commands/info_func -def test_info_functions(): - app = gdb() - +def test_info_functions(app): app.breakpoint("simple_sum.py:22") app.run("simple_sum.py") @@ -199,9 +190,7 @@ def test_info_functions(): # commands/local_variables_0 -def test_local_variables(): - app = gdb() - +def test_local_variables(app): app.breakpoint("sum_local_vars.py:26") app.run("sum_local_vars.py") @@ -240,9 +229,7 @@ def test_local_variables(): # commands/next -def test_next(): - app = gdb() - +def test_next(app): app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") @@ -258,9 +245,7 @@ def test_next(): # commands/step_dppy_func -def test_step(): - app = gdb() - +def test_step(app): app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") app.child.expect(r"Thread .* hit Breakpoint .* at simple_dppy_func.py:30") @@ -276,9 +261,7 @@ def test_step(): # commands/stepi -def test_stepi(): - app = gdb() - +def test_stepi(app): app.breakpoint("simple_dppy_func.py:30") app.run("simple_dppy_func.py") From 53d44c3e8218ec2549a55dc45b87cf87ee1a71bf Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 24 Sep 2021 12:28:07 +0300 Subject: [PATCH 16/16] Add common method _command() --- numba_dppy/tests/test_debug_dppy_numba.py | 37 +++++++++-------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/numba_dppy/tests/test_debug_dppy_numba.py b/numba_dppy/tests/test_debug_dppy_numba.py index 603d3003ce..d6967a440e 100644 --- a/numba_dppy/tests/test_debug_dppy_numba.py +++ b/numba_dppy/tests/test_debug_dppy_numba.py @@ -58,49 +58,42 @@ def teardown_gdb(self): self.child.expect("Quit anyway?", timeout=5) self.child.sendline("y") - def breakpoint(self, breakpoint): + def _command(self, command): self.child.expect("(gdb)", timeout=5) - self.child.sendline("break " + breakpoint) + self.child.sendline(command) + + def breakpoint(self, breakpoint): + self._command("break " + breakpoint) def run(self, script): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("run " + self.script_path(script)) + self._command("run " + self.script_path(script)) def backtrace(self): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("backtrace") + self._command("backtrace") def print(self, var): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("print " + var) + self._command("print " + var) def info_functions(self, function): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("info functions " + function) + self._command("info functions " + function) def info_locals(self): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("info locals") + self._command("info locals") def next(self): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("next") + self._command("next") def ptype(self, var): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("ptype " + var) + self._command("ptype " + var) def whatis(self, var): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("whatis " + var) + self._command("whatis " + var) def step(self): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("step") + self._command("step") def stepi(self): - self.child.expect("(gdb)", timeout=5) - self.child.sendline("stepi") + self._command("stepi") @staticmethod def script_path(script):