Introduction
Identifying software coding issues on a high-performance computing targeted platform often requires accessing the system remotely or through firewalls. In these cases it may be desirable to minimize the bandwidth overhead created by the feature-rich Elicpse* IDE integrated user interface or it’s Eclipse* Rich Client Platform based standalone user interface.
The solution provided for these use cases consists of two command-line debuggers.
The Intel® Debugger for applications running on Intel® 64 handles debugging any code running on the Intel 64 architecture based host system.
The Intel Debugger for applications running on Intel® Xeon Phi™ Coprocessor connects to the Intel® Xeon Phi™ Coprocessor target and allows attaching to processes running on it. These can be native processes or offload processes generated by a host application.
The approach is such that with one or two remote terminal sessions it is possible to debug an application using Intel® Xeon Phi™ Coprocessor in scenarios where having a full graphical user interface is not possible, or practical. The debugger command interface and syntax closely follows the conventions familiar from GDB*, thus minimizing the need to learn new debug concepts.
Additionally a GDB* debugger install supporting both native local debug on the Intel® Xeon Phi™ Coprocessor and gdbserver assisted cross-debug is available at http://software.intel.com/en-us/forums/topic/278102
Debugger Installation
The Intel® Debugger for Intel® Xeon Phi™ Coprocessor is part of the Intel® Composer XE 2013 for Linux*. As such it gets installed automatically when running the install script for the Intel® Parallel Studio XE 2013 package.
The installer will guide you through the installation process. It may require you to accept license agreements and to make choices about install location and components to be installed.
If you intend to use the Eclipse* based graphical user interface as well, please ensure to have
- Java* runtime environment (JRE) 1.5 or 1.6 (also known as 6.0) installed to use the Eclipse* framework for the standalone debug solution
- Eclipse* IDE 7.0 “Helios”, 8.0 “Indigo”, or 8.1 “Juno” installed to use the Intel® Debugger Integration with Eclipse* CDT, the Eclipse* IDE for C/C++ developers.
Once the Intel® Composer XE and Intel® Debugger installation is complete you can set up the environment with
$ source /opt/intel/composerxe/bin/compilervars.sh intel64
It is not recommended to only use the idbvars.sh (/opt/intel/composerxe/bin/idbvars.sh ) environment setup script as more likely than not your codebase will have compiler environment dependencies for library paths and such. Having these library path dependencies resolved correctly will make debugging more convenient.
Debugger Executables
After installation is complete you will find the debugger executables at /opt/intel/composerxe/bin/intel64_mic
idbc is the command line debugger driver for the host.
idbc_mic is the command line debugger driver for the Intel® Xeon Phi™ Coprocessor.
For command-line debug, any other binaries in this directory can be ignored.
Debugging on the Host
The Intel® Debugger included with the Intel® Composer XE 2013 comes in two versions. The command-line version for host-side debug can be launched using the command idbc.
The host debugger and the Intel® Xeon Phi™ Coprocessor target debugger are not coupled when doing command-line debugging. It is up to the user to manually start the Intel Debugger for Intel® Xeon Phi™ Coprocessor and attach to the offload process once it is created.
To launch the host-side debugger simply invoke it with
$ idbc
and then use the command
(idb) file <debuggee binary>
where <debuggee binary> is the executable to be debugged that was built with symbol info enabled (-g).
Alternatively you can also attach to a running process
(idb) attach <pid>
or, launch the executable directly when starting the debugger
$ idbc <debuggee binary>
To list the source of a specific file use
(idb) list <filename>
To stop at a specific place you could use
(idb) break <line>
or
(idb) break <func>
The command-line syntax follows the same pattern as and is highly compatible with GDB*. You can step through code, list variable contents the same way you are used to with GNU*’s debug solution.
For further details, there is a detailed command line reference document located at /opt/intel/composerxe/Documentation/en_US/debugger/cl/index.htm
In addition pointers to the overall documentation and debugger user interface integrated user manual can be found at /opt/intel/composerxe/Documentation/en_US/debugger/debugger_documentation.htm
Debug Synchronization between Host and Coprocessor
In command-line debug mode, the development host debugger idbc is not notified when an offload process is launched on the coprocessor. Thus, unlike the Eclipse* IDE integrated GUI debug solution a remote debug connection is not automatically established. The Intel® Xeon Phi Coprocessor debugger idbc_mic has to be launched explicitly. This is why it is necessary to set your host side breakpoint somewhere where you expect a worthwhile target load to already exist; after doing your attach with idbc_mic, set a breakpoint there where you want to start debugging.
If you are debugging a heterogeneous application and intend to debug host and coprocessor code simultaneously, it will be necessary to run both idbc for the host, and idbc_mic for the coprocessor targeted codebase.
This implies that two terminal windows, or (for a remote debug setup) two ssh sessions, will be necessary.
Launching your Application Manually on the Coprocessor
If the application running on the Intel® Xeon Phi™ Coprocessor is not already launched through an offload process, and you want to start the application manually on the coprocessor only and attach to it, the process must contain an endless worker loop. The only exception to this is if the coprocessor code of interest is executed upon a user-triggered event, as otherwise the location the debugger stops on the target is in general nondeterministic.
Recommended Endless Worker Loop
The recommended implementation to ensure the endless worker loop in your native or Intel® Xeon Phi™ Coprocessor application is executed even with aggressive compiler optimizations enabled looks as follows (C/C++ example provided):
void attach_idb() {
volatile int loop = 1;
do {
volatile int a = 1;
} while (loop);
}
Call this function at a location suitable for attaching the debugger.
This is necessary, because when the Intel Debugger for Intel® Xeon Phi™ Coprocessor is attached to the process, the location the debugger stops on the target is random. Typically this is somewhere in the scheduler waiting for work from the host.
For offload code you can alternatively do an empty offload followed by a read on the CPU (Fortran example provided):
!dir$ offload begin target(mic)
!dir$ end offload
! read into a temp var. Gives time to attach on the Intel® Xeon Phi™ Coprocessor, then enter some value to proceed.
! This technique may not always be suitable but is easier to apply
read *, temp
You can upload the application to the coprocessor using a utility like ftp, sftp, or a network file system. The coprocessor IP address by default is 172.31.x.1, where x specifies the coprocessor number, if multiple coprocessors are installed on your system.
Note:
When debugging native coprocessor applications on the command line, the shared library libmyodbl-service.so needs to be copied to the coprocessor.
The way to achieve this is to create an overlay, so the file is uploaded at boot time. Follow the instructions on how to use overlays in the MPSS readme.txt (http://registrationcenter.intel.com/irc_nas/2618/readme.txt).
The steps needed to implement this specific overlay look like this:
a. Create /etc/sysconfig/mic/conf.d/myo.conf on the coprocessor target containing the following:
# MYO download files
Overlay / /opt/intel/mic/myo/config/myo.filelist
b. Create /opt/intel/mic/myo/config/myo.filelist on the debug host containing
dir /lib64 755 0 0
file /lib64/libmyodbl-service.so
/opt/intel/mic/myo/lib/libmyodbl-service.so 755 0 0
Connecting the Debugger to the Coprocessor
The standard method a process gets started on the Intel® Xeon Phi™ Coprocessor is through an offload process initiated via offload pragma or some other language extension. Since the host debugger and the command-line version of the Intel Debugger for Intel® Xeon Phi™ Coprocessor are not coupled, the debugger for the coprocessor will neither be launched directly at offload, nor will the debugger stop at a defined point.
Thus we recommend adding an endless worker loop into your coprocessor code, even if it is launched as an offload process.

Figure 1: Host-Target Debug Connection
Native Coprocessor Application
If the application is written to run natively on the Intel® Xeon Phi™ Coprocessor, you can start the application using the debugger for the Intel® Xeon™ Phi™ Coprocessor. It is launched on the development host with the command idbc_mic. This will then automatically download the idbserver remote debug agent onto the coprocessor and establish TCP/IP based remote debug run-control.
1. Upload the debug build of the application to the coprocessor.
2. Launch the debugger by using the following command on the development host:
$ idbc_mic -tco -rconnect=tcpip:mic[n]:port
For example, enter idbc_mic -tco -rconnect=tcpip:mic0:2000 for the first MIC device using the default port.
Default:
<port> = 2000
Instead of mic[n] specifying a specific Intel® Xeon Phi™ coprocessor you can alternatively use the IP address in the format 172.31.x.x.
Heterogeneous Application
If the application is a heterogeneous application (an application with processes both on the Intel® 64 host as well as the Intel® Xeon Phi™ Coprocessor), start the process on the coprocessor and then attach the target debugger to the process.
You should set your host side breakpoint somewhere where you expect a worthwhile target load to already exist. Then after doing your attach with idbc_mic, you can set a breakpoint where you want to start debugging, or run to the aforementioned endless worker loop.
Launch the debugger by using the following command from the development host:
$ idbc_mic -tco -rconnect=tcpip:mic[n]:port
For example, enter idbc_mic -tco -rconnect=tcpip:mic0:2000 for the first MIC device using the default port.
Default:
<port> = 2000
Instead of mic[n] specifying a specific Intel® Xeon Phi™ coprocessor you can alternative also use the IP address in the format 172.31.x.x.
If you are debugging a heterogeneous application, run the application and attach the debugger to it:
Enter the following command:
(idb) attach <pid> [<image_file>]
Arguments:
<pid> The pid of the process to attach to.
<image_file> The image file name.
Note:
If the image file name is not specified, the image file of the current process is assumed.
Note:
For offload applications it is required to specify /opt/intel/composerxe/lib/mic/offload_main as the image file.
To identify the process to attach to the following command can be used
(idb)idb show process-list ["proc-name"]
Debugging on the Coprocessor Basics
Once the Intel Debugger for Intel® Xeon Phi™ Coprocessor is connected to the coprocessor, the next step is to launch or attach to a debuggee process and to ensure the relevant symbol information and source files are available.
Using LD_LIBRARY_PATH
If the target-side application is dynamically linked against shared objects that are not part of the compiler or driver, and that need LD_LIBRARY_PATH to be set in order to find them,
Set a breakpoint before the libraries are loaded.
When the debugger stops at that location, use the command
(idb) set environment LD_LIBRARY_PATH path
Do the same for other environment variables that the application might need.
Specifying Additional Symbol Info Search Paths
To tell the debugger where to search for the debug information specific to your application:
(idb) set solib-search-path path[:path]
e.g.
(idb) set solib-search-path /usr/linux-k1om-4.7/linux-k1om/lib64/lib:/usr/linux-k1om-4.7/x86_64-k1om-linux/lib64
To ensure the correct target Linux* runtime library is picked up by the debugger
You can use the corresponding show command syntax to get a listing of all directories in the search path:
(idb) show solib-search-path
Taking Control of the Application with the Debugger:
If you are debugging a heterogeneous application, run the application and attach the debugger to it:
Enter the following command:
(idb) attach <pid> [<image_file>]
Arguments:
<pid> The pid of the process to attach to.
<image_file> The image file name and path.
Note:
If the image file name is not specified, the image file of the current process is assumed. The image file is expected to be present on the host and the target. The command needs to know the path on the host for reading symbol information. Symbol information is always read on the development host
Note:
For offload applications it is required to specify
/opt/intel/composerxe/lib/mic/offload_main
as the image file.
To identify the process to attach to the following command can be used
(idb)idb show process-list ["proc-name"]
Semantics:idb show process-list prints all processes running on the target and variable $lsproc will hold the number of processes found as a negative number, i.e. If there are 5 processes running, $lsproc will be -5
idb show process-list "proc-name" will get the process list and search for a process named proc-name. If found, $lsproc will contain the process id or 0 if no applicable process has been found.
Note:
When debugging native coprocessor applications on the command line, the shared library libmyodbl-service.so needs to be uploaded manually.
The way to achieve this is to create an overlay, so the file is uploaded at boot time. Follow the instructions on how to use overlays in the MPSS readme.txt. The steps needed to implement this specific overlay look like this:
- 1. Create /etc/sysconfig/mic/conf.d/myo.conf on the coprocessor target containing the following:
# MYO download files
Overlay / /opt/intel/mic/myo/config/myo.filelist - 2. Create /opt/intel/mic/myo/config/myo.filelist on the debug host containing
dir /lib64 755 0 0
file /lib64/libmyodbl-service.so
opt/intel/mic/myo/lib/libmyodbl-service.so 755 0 0
Starting Application from within the Debugger
To debug an application run natively on Intel® Xeon Phi™ Coprocessor, besides being able to attach to a running application, you can also start the application using the debugger:
1. Specify the remote executable file:
(idb) idb file-remote target-bin-path
2. Specify the file containing debug info on the host:
(idb) idb file-remote target-bin-path
3. After setting breakpoints and applying any other application specific environment settings, start the application:
(idb)run
The debugger starts the application, or attaches to the application's process, and stops it.
Endless Worker Loop
The recommended implementation to ensure the endless worker loop in your native or Intel® Xeon Phi™ Coprocessor application is executed, even with aggressive compiler optimizations enabled, looks as follows (C/C++ example provided):
void attach_idb() {
volatile int loop = 1;
do {
volatile int a = 1;
} while (loop);
}
Call this function at a location suitable for attaching the debugger.
This is necessary, because when the Intel Debugger for Intel® Xeon Phi™ Coprocessor is attached to the process, the location the debugger stops on the target is random. Typically this is somewhere in the scheduler waiting for work from the host.
For offload code you can alternatively do an empty offload, followed by a read on the CPU (Fortran example provided):
!dir$ offload begin target(mic)
!dir$ end offload
! read into a temp var. Gives time to attach on the Intel® Xeon Phi™ Coprocessor, then enter some value to proceed.
! This technique may not always be suitable but is easier to apply
read *, temp
Starting to Debug from Endless Worker Loop
If you added an endless worker loop to your offload or native code to ensure that you automatically start debugging the Intel® Xeon Phi™ Coprocessor based code at a well defined place, the following method may be used to start debugging just outside of the loop.
- Using the following command:
(idb) list <filename>
You can identify the source line number forvolatile int a=1. - Set the loop counter variable to 0, and set a breakpoint at that line
(idb) p loop=0
(idb) break <line number> - Continue
(idb) continue
Note:
When debugging native coprocessor applications on the command line, the shared library libmyodbl-service.so needs to be uploaded manually.
The way to achieve this is to create an overlay, so the file is uploaded at boot time. Follow the instructions on how to use overlays in the MPSS readme.txt. The steps needed to implement this specific overlay look like this:
a. Create /etc/sysconfig/mic/conf.d/myo.conf on the coprocessor target containing the following
# MYO download files
Overlay / /opt/intel/mic/myo/config/myo.filelist
b. Create /opt/intel/mic/myo/config/myo.filelist on the debug host containing
dir /lib64 755 0 0
file /lib64/libmyodbl-service.so
opt/intel/mic/myo/lib/libmyodbl-service.so 755 0 0
Shared Object Debugging
Using LD_LIBRARY_PATH
If the target-side application is dynamically linked against shared objects that are not part of the compiler or driver, and needs LD_LIBRARY_PATH to be set in order to find them, set a breakpoint before the libraries are loaded. When the debugger stops at that location, you can use the command
(idb) set environment LD_LIBRARY_PATH
to set that variable. Do the same for other environment variables the application might need.
Specifying Additional Symbol Info Search Paths
You may need to tell the debugger where to search for the debug information specific to your application if the application was not built on the same system, or if the shared object containing the debug information has been moved from its original location. Use the following command:
(idb) set solib-search-path path[:path].
Known Issues
Home Directory Location on Intel® Xeon Phi™ Coprocessor not resolved correctly
The Intel® Debugger for Intel® Xeon Phi™ Coprocessor assumes that the directory layout and location of the home directory for a given user are identical on the Intel® 64 host system and the Intel® Xeon Phi™ Coprocessor.
If this is not the case for your development setup, you may have to edit the idbc_mic debugger driver.
- Open idbc_mic with an editor of your choice
- Replace the lines
scp $INSTALLDIR/debugger/mic/lib/idbserver_mic
$rconnect_ip:$HOME /idbserver_mic
ssh $rconnect_ip "$HOME/idbserver_mic -c
tcpip:$rconnect_port -x"&
with
REMOTE_HOME=`ssh mic0 pwd`
scp $INSTALLDIR/debugger/mic/lib/idbserver_mic $rconnect_ip:$REMOTE_HOME/idbserver_mic
ssh $rconnect_ip "$REMOTE_HOME/idbserver_mic -c
tcpip:$rconnect_port -x"&
Command-line Debug with GDB*
The GNU* Project Debugger GDB* with support for Intel® Xeon Phi™ Coprocessor is currently available at the following location:
http://software.intel.com/en-us/forums/topic/278102
Please download GDB* from
http://registrationcenter.intel.com/irc_nas/2618/gdb-intel-mic-2.1.3126.tgz
The GDB* readme can be found at
http://registrationcenter.intel.com/irc_nas/2618/gdb-intel-mic-2.1.3126-readme.txt
Debugger Installation
- Download gdb-intel-mic-2.1.xxxx.tgz
- Unpack
$ tar xzf gdb-intel-mic-2.1.xxxx.tgz - Copy gdb/gdbserver to Intel® Xeon Phi™ Coprocessor
$ scp gdb gdbserver root@mic0:/usr/bin
or with user account
$ scp gdb gdbserver mic0:
Native Debugging on the Intel® Xeon Phi™ Coprocessor with GDB*
- Run GDB* on the Intel® Xeon Phi™ Coprocessor
$ ssh –t mic0 /usr/bin/gdb
or with user account
$ ssh –t mic0 ./gdb - Attach to a running application via the process-id
(gdb) shell pidof <my_application> <pid>
where <pid> is the process-id and <my_application> is the name of the application you intend to debug.
(gdb) attach <pid> - Run an application directly from GDB*
(gdb) file /target/path/to/applicaton
(gdb) start
Remote debugging with GDB*
- Run GDB* on your localhost
$ /usr/linux-k1om-4.7/bin/x86_64-k1om-linux-gdb - Start gdbserver on the Intel® Xeon Phi™Coprocessor
(gdb) target extended-remote | ssh –T mic0 gdbserver –-multi –
Remote debugging using |ssh -T mic0 gdbserver --multi -
Remote debugging using stdio - Attach to a running application via the process-id (pid)
(gdb) file /local/path/to/applicaton
(gdb) attach <remote-pid> - Run an application directly from GDB*
(gdb) file /local/path/to/applicaton
(gdb) set remote exec-file /target/path/to/application
Conclusion
The Intel Debuggers included in the Intel® Composer XE 2013 suite do not only provide a full GUI based debug solution, but also include two command-line debuggers that can be used in conjunction for offload code analysis and debug.
Additionally the Intel Debugger for Intel® Xeon Phi™ Coprocessor alone can be used to debug code running natively on the Intel® Xeon Phi™ Coprocessor based coprocessor.
Since the two command-line debug solutions are independent and do not synchronize breakpoints or debuggee application states with each other, there are a few steps the developer needs to be aware of when using the debug solutions in this fashion.
Nevertheless, the approach described in this whitepaper allows for a flexible debug approach even in those scenarios where remote debug with bandwidth constraints force the developer to avoid a full debug graphical user interface.
In addition there now is a GNU Project Debugger with native Intel® Xeon Phi™ application debug support as well as remote cross-debug support via gdbsever available on the Intel® Developer Zone
Additional Resources
Documentation
For details on the available Intel Debugger command-line syntax, please refer to command line reference manual located at
/opt/intel/composerxe/Documentation/en_US/debugger/cl/index.htm
In addition pointers to the overall documentation, getting started guide, and debugger user interface integrated user manual can be found at
/opt/intel/composerxe/Documentation/en_US/debugger/debugger_documentation.htm
The full debugger user manual is available from the Help pulldown menu in the Intel Debugger graphical user interface or from the help pulldown menu of the Eclipse IDE’s debugger perspective when using the Eclipse integrated debug solution.
MPSS 2.1 README:
http://registrationcenter.intel.com/irc_nas/2618/readme.txt
GNU* Project Debugger GDB* README:
http://registrationcenter.intel.com/irc_nas/2618/gdb-intel-mic-2.1.3126-readme.txt
Distribution Locations
Intel® Composer XE 2013:
http://software.intel.com/en-us/intel-composer-xe/
Java* Runtime Environment:
http://www.java.com
Eclipse* CDT: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2
GNU* Project Debugger GDB*:
The GNU* Project Debugger GDB* with support for Intel® Xeon Phi™ Coprocessor is currently available at the following location:
http://software.intel.com/en-us/forums/topic/278102
Please download GDB* from
http://registrationcenter.intel.com/irc_nas/2618/gdb-intel-mic-2.1.3126.tgz
Native Debug Tutorial
Alongside this whitepaper we include a tutorial “lab” to follow, to learn how to debug a natively run application. The current directory on the host is assumed to be: ~/lab_workspace/debugger/host-dbg/.To compile the Intel® Xeon Phi™ Coprocessor native application one needs to source the compiler script first and then to run make. The makefile compiles the executable program and the shared library lib64/libmylib.so from main.cpp and mylib.cpp.
$ source /opt/intel/composer_xe_2013/bin/compilervars.sh intel64
$ make all
icpc -g -O0 -mmic -fPIC -c -c main.cpp
icpc -g -O0 -mmic -fPIC -c mylib.cpp
icc -mmic -shared mylib.o -o lib64/libmylib.so
icc -mmic main.o -L./lib64 -lmylib -o prog
x86_64-k1om-linux-ld: warning: libimf.so, needed by ./lib64/libmylib.so, not
found (try using -rpath or -rpath-link)
x86_64-k1om-linux-ld: warning: libsvml.so, needed by ./lib64/libmylib.so, not
found (try using -rpath or -rpath-link)
x86_64-k1om-linux-ld: warning: libintlc.so.5, needed by ./lib64/libmylib.so,
not found (try using -rpath or -rpath-link)
The warnings indicate that dynamically linked shared objects needed for execution on the Intel® Xeon Phi™ Coprocessor are not found during build on the host. These warnings are harmless as long as these shared objects are present and in the path on the coprocessor itself at runtime.
We will take care of this in the next section.
Lab 1 – Intel® Xeon Phi™ Coprocessor Native Debugging using IDB
Copy files to the coprocessor
Open a terminal and create the target directories for the application on the Intel® Xeon Phi™ Coprocessor:
$ ssh 172.31.x.x
# cd tmp
# mkdir target-dbg
# cd target-dbg
# mkdir lib64
Upload the application and shared library from the host to the Intel® Xeon Phi™ Coprocessor card:
$ sudo scp /tmp/host-dbg/prog mic0:/tmp/target-dbg/
$ sudo scp /tmp/host-dbg/lib64/libmylib.so
mic0:/tmp/target-dbg/lib64
Upload the compiler shared libraries required for this example:
$ sudo scp /opt/intel/composerxe/lib/mic/libintlc.so
mic0:/tmp/target-dbg/lib64/
$ sudo scp /opt/intel/composerxe/lib/mic/libintlc.so.5
mic0:/tmp/target-dbg/lib64/
$ sudo scp /opt/intel/composerxe/lib/mic/libimf.so
mic0:/tmp/target-dbg/lib64/
$ sudo scp /opt/intel/composerxe/lib/mic/libsvml.so
mic0:/tmp/target-dbg/lib64/
Start the debugger, launch the debuggee
Start the debugger:
$ idbc_mic -tco -rconnect=tcpip:mic0:2000
Intel(R) Debugger Remote Server, Build [79.xxx.xx]
This version is configured for k1om on Linux
Copyright (C) 2006-2012 Intel Corporation. All rights reserved.
Intel(R) Many Integrated Core Architecture Debugger (Intel(R) MIC Debugger) Version 13.0, Build [79.280.23]
NOTE: The evaluation period for this product ends in 585 days.
Set the remote file:
(idb) idb file-remote /tmp/target-dbg/prog
Setup the environment:
(idb) set env LD_LIBRARY_PATH /tmp/target-dbg/lib64
(idb) set solib-search-path /usr/linux-k1om-4.7/linux-k1om/lib64/lib:/usr/linux-k1om-4.7/x86_64-k1om-linux/lib64
Set the symbol file:
(idb) file ~/lab_workspace/debugger/host-dbg/prog
Reading symbols from ~/lab_workspace/debugger/host-dbg/prog...done.
Info: Optimized variables show as <no value> when no location is allocated.
Set a breakpoint at main, start the application:
(idb) break main
Breakpoint 1 at 0x400703: file ~/lab_workspace/debugger/host-dbg/main.cpp, line 36.
(idb) run
Starting program: ~/lab_workspace/debugger/host-dbg/prog
[New Thread 4614 (LWP 4614)]
Breakpoint 1, main (argc=1, argv=0x7fff9098b3a8) at ~/lab_workspace/debugger/host-dbg/main.cpp:36
5 printPid();
Debug your application and…
(idb) quit
Lab 2 – Intel® Xeon Phi™ Coprocessor Native Debugging using IDB
Open another terminal and launch the debuggee:
$ telnet 172.31.x.x
Trying 172.31.x.x...
Connected to 172.31.x.x.
Escape character is '^]'.
Intel® Xeon Phi™ Coprocessor Platform Software Stack release 2.0
Kernel 2.6.34-g38bc7c2 on an k1om
~ # cd tmp/target-dbg/
/tmp/target-dbg # export LD_LIBRARY_PATH=~/lab_workspace/debugger/target-dbg/lib64
~/lab_workspace/debugger/target-dbg # ./prog
PID: 3966
The debuggee prints its PID on the console. In another terminal we can instruct IDB to debug to that process:
$ idbc_mic -tco -rconnect=tcpip:mic0:2000
Intel(R) Many Integrated Core Architecture Debugger (Intel(R) MIC Debugger) Version 13.0, Build [79.280.23]
NOTE: The evaluation period for this product ends in 585 days.
(idb) attach 3966 ~/lab_workspace/debugger/host-dbg/prog
Attaching to program: ~/lab_workspace/debugger/host-dbg/prog, process 3966
[New Thread 3966 (LWP 3966)]
Reading symbols from ~/lab_workspace/debugger/host-dbg/prog...done.
__mktime_internal () in /lib64/libc-2.12.so
Set a breakpoint at the worker loop:
(idb) break main.cpp:38
Info: Optimized variables show as <no value> when no location is allocated.
Breakpoint 1 at 0x40070c: file /nfs/iul/disks/iul_team2/msturm/TPT/ISV-Workshop-lab/host-dbg/main.cpp, line 38.
(idb) continue
Continuing.
Breakpoint 1, main (argc=1, argv=0x7fff92b35798) at /nfs/iul/disks/iul_team2/msturm/TPT/ISV-Workshop-lab/host-dbg/main.cpp:38
38 while(loop)sleep(1);
Set a breakpoint outside the worker loop, set the loop variable to 0 and continue:
(idb) b main.cpp:39
Breakpoint 2 at 0x400729: file /nfs/iul/disks/iul_team2/msturm/TPT/ISV-Workshop-lab/host-dbg/main.cpp, line 39.
(idb) p loop=0
$1 = false
(idb) c
Continuing.
Breakpoint 2, main (argc=1, argv=0x7fff92b35798) at /nfs/iul/disks/iul_team2/msturm/TPT/ISV-Workshop-lab/host-dbg/main.cpp:39
39 printMsg("Test message");
(idb) c
Continuing.
Program exited normally.
“MSG: Test message” is printed to the other console and the application exits.
About the Author
Robert Mueller-Albrecht is a Technical Consulting Engineer at Intel Corporation with focus on software development tools solutions for embedded computing and on debug solutions across a wide range of Intel® architecture based designs. He joined Intel in 2001, after working for CAD-UL AG and obtaining an MSc in Physics at the Technical University of Kaiserslautern.
Notices
INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS OTHERWISE AGREED IN WRITING BY INTEL, THE INTEL PRODUCTS ARE NOT DESIGNED NOR INTENDED FOR ANY APPLICATION IN WHICH THE FAILURE OF THE INTEL PRODUCT COULD CREATE A SITUATION WHERE PERSONAL INJURY OR DEATH MAY OCCUR.
Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.
The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.
Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or go to: http://www.intel.com/design/literature.htm
Intel, the Intel logo, VTune, Cilk and Xeon are trademarks of Intel Corporation in the U.S. and other countries.
Java is a registered trademark of Oracle and/or its affiliates
*Other names and brands may be claimed as the property of others
Copyright© 2012 Intel Corporation. All rights reserved.
Optimization Notice

