Examining the Symbol Table¶
See GDB* documentation.
info functions
¶
At least following syntax is supported:
info functions
info functions [regexp]
Note
Running the info functions
command without arguments may produce a lot of output
as the list of all functions in all loaded shared libraries is typically very long.
Example¶
Source file numba_dpex/examples/debug/simple_sum.py
:
5import dpnp as np
6
7import numba_dpex as ndpx
8
9
10@ndpx.kernel(debug=True)
11def data_parallel_sum(item, a, b, c):
12 i = item.get_id(0)
13 c[i] = a[i] + b[i] # Condition breakpoint location
14
15
16global_size = 10
17N = global_size
18
19a = np.array(np.random.random(N), dtype=np.float32)
20b = np.array(np.random.random(N), dtype=np.float32)
21c = np.ones_like(a)
22
23ndpx.call_kernel(data_parallel_sum, ndpx.Range(global_size), a, b, c)
24
25print("Done...")
Output of the debug session:
$ NUMBA_OPT=0 gdb-oneapi -q python
(gdb) set breakpoint pending on
(gdb) break simple_sum.py:22
(gdb) run simple_sum.py
(gdb) info functions data_parallel_sum
...
All functions matching regular expression "data_parallel_sum":
File simple_sum.py:
20: void __main__::data_parallel_sum(Array<float, 1, C, mutable, aligned>, Array<float, 1, C, mutable, aligned>, Array<float, 1, C, mutable, aligned>);
(gdb) continue
(gdb) info functions __main__
...
All functions matching regular expression "__main__":
20: void __main__::data_parallel_sum(Array<float, 1, C, mutable, aligned>, Array<float, 1, C, mutable, aligned>, Array<float, 1, C, mutable, aligned>);
(gdb) continue
...
Done...
whatis [arg]
and ptype [arg]
¶
To print the type of a variable, run the ptype <variable>
or whatis <variable>
commands:
(gdb) whatis a
type = byte [56]
(gdb) ptype l1
type = double
(gdb) whatis l1
type = double
(gdb) continue
...
Done...
Example - Complex Data Types¶
Source code numba_dpex/examples/debug/side-by-side-2.py
:
14def common_loop_body(i, a, b):
15 param_a = a[i]
16 param_b = b[i]
17 param_c = param_a + 10 # Set breakpoint here
18 param_d = param_b * 0.5
19 result = param_c + param_d
20 return result
Debug session:
$ gdb-oneapi -q python
...
(gdb) set environment NUMBA_OPT 0
(gdb) set environment NUMBA_EXTEND_VARIABLE_LIFETIMES 1
(gdb) break side-by-side-2.py:29 if param_a == 5
...
(gdb) run numba_dpex/examples/debug/side-by-side-2.py --api=numba-dpex-kernel
...
Thread 2.1 hit Breakpoint 1, with SIMD lane 5, __main__::common_loop_body (i=5, a=..., b=...) at side-by-side-2.py:29
29 result = param_c + param_d
(gdb) ptype a
type = struct array(float32, 1d, C) ({float addrspace(1)*, float addrspace(1)*, i64, i64, float addrspace(1)*, [1 x i64], [1 x i64]}) {
float *meminfo;
float *parent;
int64 nitems;
int64 itemsize;
float *data;
i64 shape[1];
i64 strides[1];
}
(gdb) whatis a
type = array(float32, 1d, C) ({float addrspace(1)*, float addrspace(1)*, i64, i64, float addrspace(1)*, [1 x i64], [1 x i64]})