Debugging Intel® Array Building Blocks Programs Using GDB

User's Guide: GNU Debugger Integration

Introduction :

This article demonstrates the basic usage of debugger integration for Intel® ArBB with GDB on Linux* OS.

Version :

Intel® Array Building Blocks 1.0 Beta 1 for Linux* OS

Application Notes :

The debugger integration allows programmers to inspect the content of Intel® ArBB scalar and containers using GDB commands.

Prerequisites :

Intel® Array Building Blocks 1.0 Beta 1 product must be installed. For information on how to get and install Intel® ArBB software on Linux* platform, refer to this KB article.

GDB 7.0 or later, and the GDB installation must be configured using with-python.

Python is required for pretty printing of Intel® ArBB data objects.

Basic Usage :

As an example, assuming a GDB session is running where the following code has been executed in the current scope:

i16            i(16);
boolean        b(true);
dense<i32>     d1;
dense<boolean> d2(8);
dense<i32, 2>  d3(2, 4);
dense<i32, 2>  d4(2, 2, 2);

If the user types:
[shell:nogutter:nocontrols]print i[/shell:nogutter:nocontrols]
The result will be:

[shell:nogutter:nocontrols]$1 = 16 [/shell:nogutter:nocontrols]
If the user types:

[shell:nogutter:nocontrols]print b [/shell:nogutter:nocontrols]
The result will be:

[shell:nogutter:nocontrols]$2 = true [/shell:nogutter:nocontrols]
If the user types:

[shell:nogutter:nocontrols]print d1 [/shell:nogutter:nocontrols]
The result is shown below. Please note that the number following the "$" symbol is incremented by GDB according to the number of times 'print' has been executed.

[shell:nogutter:nocontrols]$3 = ArBB dense, uninitialized = { [0] uninitialized } [/shell:nogutter:nocontrols]
If the user types:

[shell:nogutter:nocontrols]print d2 [/shell:nogutter:nocontrols]
The result will be:

[cpp:nogutter:nocontrols]$4 = ArBB dense<arbb_boolean, 1> = { [0] = container (8) = {false, false, false, false, false, false, false, false} } [/cpp:nogutter:nocontrols]
If the user types:

[shell:nogutter:nocontrols]print d3 [/shell:nogutter:nocontrols]
The result will be:

[cpp:nogutter:nocontrols]$5 = ArBB dense<arbb_u32, 2> = { [0] = container (2, 4) = {[0] = {0, 0}, [1] = {0, 0}, [2] = {0, 0}, [3] = {0, 0}} } [/cpp:nogutter:nocontrols]
If the user types:

[shell:nogutter:nocontrols]print d4 [/shell:nogutter:nocontrols]
The result will be:

[cpp:nogutter:nocontrols]$6 = ArBB dense<arbb_u32, 3> = { [0] = container (2, 2, 2) = {[0] = {[0] = {0,0}, [1] = {0, 0}}, [1] = {[0] = {0,0}, [1] = {0, 0}}} } [/cpp:nogutter:nocontrols]
The formatting of the containers above is subject to GDB settings for printing arrays and may not exactly match the above examples. Among the relevant options are those set by the following GDB commands:

  • set print array
  • set print array-indexes
  • set print elements
  • set print pretty
Please refer to the GDB documentation for details.

In addition to providing information via the standard 'print' command, a custom command is available to print individual elements of a dense variable. The syntax of the command is as follows:

[shell:nogutter:nocontrols]arbb print var[page][row][col] [/shell:nogutter:nocontrols]
The number of indexes provided must match the dimensionality of variable. If the dense variable holds an array or user type, the elements in each sub-container matching the given indexes will be printed. At this time, expression evaluation is not support. A single variable name must be provided and indexes must be numeric. This command does not currently support options to print values in other than base 10.

The GDB integration also provides some level of support for GUI debuggers that are built on top of GDB. For instance, when you add an Intel® ArBB variable to the "Expressions" window in the Eclipse CDT debugger, the "pretty printed" value is shown in the "Details" field for the variable as follows:

Eclipse CDT debugger

Known Issues or Limitations :

  1. The debugger can only be used to inspect Intel® ArBB scalars and containers whose elements are of built-in types, such as i32 and f64. It does not work well with containers whose elements are of user-defined types.
  2. The debugger only works for the emulation mode. That is, the Intel® ArBB optimization level must be set to O0 using the environment variable ARBB_OPT_LEVEL. Programs with big input size may run very slow or even crash in this mode.

For more complete information about compiler optimizations, see our Optimization Notice.