Search This Blog

Thursday, August 16, 2012

How to Debug C++ program running on AIX from Windows

great and easy way to debug your running c++ program on aic from windows.
here is the complete video guide.

http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/index.jsp?topic=/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session/player.html

the PDF doc could be found here http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/topic/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session.pdf


  1. The IBM Debugger for AIX is Eclipse-based. It is based on the Client/Server architecture. The client, or the User Interface is what you interact with. It is based on Eclipse and all platforms of IBM Debugger products have a similar-looking UI. However, they talk to a different engine.  The Debug Engine controls the user’s application.  With the help of expression evaluator, it can debug C, C++,  Cobol , and PL/I programs. On ZSeries, the engine can also debug high level assembly. The UI calls the engine by establishing a TCP/IP connection to the debugger engine. Users can debug on I-series, TPF mainframe, Z-series, AIX and on Windows®.  But before you attempt to launch a debug session, make sure your program is compiled with –g option. Otherwise, no source is displayed. This presentation illustrates how to launch a debug session on Windows.         
  2. There are other options that affect debugging.  -qfullpath will affect the ability of the debugger to find source files. -qlinedebug suppresses information on variables. -qtbtable can be used to suppress traceback tables. This can affect the ability of the debugger to build stack traces. -O should not be used. Debugging optimized code is possible, but the results can be misleading. Consult the your compiler documentation for more information.                                                                                                                                                                                                                                                                                                                                                                 
  3. This presentation illustrates how to launch a debug session on Windows. On Windows, from Start->All Programs->IBM->IBM Debugger for AIX->IBM Debugger for AIX, you can launch the UI. You can also set a shortcut to the UI program and place it on your desktop and double click the icon. Once the UI is launched, there are several steps to follow in order to launch a debug session.                                                                                                                                                                                                                                                                                                                                                                 
  4. Step 1: Select a profile location. Once the debugger is launched, you are prompted for a profile location. This is a place for breakpoint setting, view setting, and any other customization that you have done to the user interface.  You can select the check box “Use this as the default and do not ask again” to bypass this dialogue in the future.                                                                                                                                                                                                                                                                                                                                                                 
  5. Step 2: Check the Debugger Daemon. By default, the debugger daemon is set to port 8001, you will need to know the number when launching the debug engine.  In the UI, under the debugger daemon, circled in red, there are controls that let you:  stop listening, change port, and obtain workstation IP. Information provided from these controls is necessary for step 3.                                                                                                                                                                                                                                                                                                                                                                 
  6. Step 3: Launching the debugger engine  From a telnet/ssh session to the AIX machine where the debugger engine resides, the irmtdbgc –qhost=workstation:port a.out  command line will  launch the debugger engine. You can also attach to a running process by using the –a flag.  Note that if you use the default 8001 port,  it is not necessary to specify the port.  In the examples here, you are launching the debugger engine to connect to the host sunshine, default port 8001, to debug a program a.out, core file and attach to a process.                                                                                                                                                                                                                                                                                                                                                                 
  7. You can also specify the default host and port with the DER_DBG_ADDR environment parameter.  For example, you can put the export statement in your profile export DER_DBG_ADDR=host:port And then launch the debugger engine in a simpler way. irmtdbgc a.out will then launch the debugger engine to connect to host sunshine, port 8001 to debug program a.out                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Enjoy
Yaniv Tzanany                                                                                                                                                                                                                                                                                                                                                   

No comments: