Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to remote debug using attach to process

How to remote debug using attach to process

Problem

How to attach to a remote unix process and debug, using Visual COBOL for eclipse based on a PC.

 

Requirements

VISUAL COBOL for eclipse installed on PC.

<See Installing Visual COBOL on Windows>

 

Visual COBOL development hub installed on the Unix machine.

<See Installing Micro Focus Visual COBOL Development Hub>

 

RDO daemon process must be running.

<See Configuring the Remote System Explorer Support>

 

Resolution

High level diagram & summary

Two remote projects are created in the same workspace using Visual COBOL for eclipse on a PC

quickdebug is the actual development project.

APquickdebug is the glue for attaching to the deployed running process to debug and test.

APquickdebug references the quickdebug project

APquickdebug has a debug configuration, which has quickdebug referenced for source code and the debug symbols.

tesbin is a soft symbolic link created on the unix machine in the APquickdebug unix project area. NB. this is not created using the IDE, see detailed section below.

 

On the unix side

/Quickdebug and /APquickdebug are created by the PC eclipse IDE.

/testbin needs to be created as this is where the quickdebug executable will be deployed to.

A symbolic link to testbin needs to be created inside /APquickdebug project area using the Unix command line not the eclipse IDE.

Detailed set up and run.

1 Create a remote COBOL project quickdebug.

2 Create a test environment.

3 Create deployment script.

4 Create a remote COBOL project APquickdebug.

5 Create a symbolic soft link.

6 Setup for debug.

7 Setup the debug configuration.

8 Start the debugger.

9 Use the debugger.

1 Create a remote COBOL project quickdebug

Insert the code from Program1.cbl below

The code for Program1.cbl
program-id. Program1 as "Program1".

       environment division.
       configuration section.

       data division.
       working-storage section.
       01  ans           pic x.

       procedure division.
       main section.
       main-010.
           display "started program 1"

           move space to ans

           perform until ans ="Q"
               display "press Q enter to exit..."
               accept ans
           end-perform
           .
       main-090.
           goback.

       end program Program1.


This program will just sit there accepting input until “Q” is pressed.

This emulates a standalone process which we can attach to and debug.

2 Create a test environment

Make a directory testbin in the user home directory on the Unix machine.

>mkdir testbin

This is to emulate deployment of the executable quickdebug to a test environment.

3 Create deployment script

Automatically deploy the executable quickdebug to the test environment, by using the post build event of the quickdebug project.

set –x
echo "deploying quickdebug to testbin"
pwd
cp -p New_Configuration.bin/quickdebug ../APquickdebug/testbin
ls -l ../APquickdebug/testbin/
ls -l New_Configuration.bin
echo "done it"

4 Create a remote COBOL project APquickdebug.

/APquickdebug holds all the required information to glue the source code and debugging symbols in /quickdebug with the executable in /testbin.

In order not to interfere with the test area, create a remote project on the same machine as /testbin, but in a different /APquickdebug location.

5 Create a symbolic soft link.

APquickdebug needs to know how \ where to find the quickdebug executable in the test environment testbin.

On the unix machine using the command prompt, not the eclipse IDE, create a symbolic link to the test environment testbin directory using a command like this.

soft link example
ln -s /home/support/support/tonyt/testbin /home/support/support/tonyt/testit/APquickdebug/testbin

5 Create setup and run test scripts

The scripts to setup the test environment and run the test application have been put into the APquickdebug remote project, they can be put anywhere on the UNIX machine.

Examples of setup.sh and runit.sh are given below

The setup.sh
#!/usr/bin/bash
#
#set -x
JAVA_HOME=/usr/java6
export JAVA_HOME
PATH=/usr/java6/bin:$PATH:
export PATH
java -version

. /home/products/vcdevhub22/bin/cobsetenv

export COBMODE=32
which cob
cob -V

LANG=en_US
export LANG

TERM=vt220
export TERM
#
# end
#

 

The runit.sh
#!/usr/bin/bash
# trace myprogram
#truss -e -rall -f -o junk.truss ./Program1
#
oldpwd=$PWD
cd testbin
./quickdebug
cd $oldpwd
# 
# end
#

6 Setup for debug.


Put a project reference in APquickdebug to quickdebug.

Clean compile both projects, and make sure the executable is copied to the test environment ~/testbin

On the unix machine in the APquickdebug project, run the setup.sh and the runit.sh to start the executable quickdebug in the test environment testbin directory.

 

/home1/support/support/tonyt/testit/APquickdebug >. ./setup.sh
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr6-20090925_01(SR6))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr6-20090923_42924 (JIT enabled, AOT enabled)
J9VM - 20090923_042924
JIT  - r9_20090902_1330ifx1
GC   - 20090817_AA)
JCL  - 20090924_01
COBDIR set to /home/products/vcdevhub22
/home/products/vcdevhub22/bin/cob
version @(#)cob.c       2.2.0.93
PRN=KXCAI/AAD:Ao.U4.13.04
PTI=32/64 bit
PTI=Micro Focus Visual COBOL Development Hub 2.2
PTI=pkg_77569
PTI=ES
PTI=SOA Configured
I see no work
/home1/support/support/tonyt/testit/APquickdebug >. ./runit.sh
started program 1
press Q enter to exit...


The application will be asking for input.

7 Setup the debug configuration.

We need to attach to this process and debug it using the eclipse IDE, and the glue which is the APquickdebug project.

Create a debug configuration for the APquickdebug project.

In General settings - remove X Server (DISPLAY)

In Source settings - add quickdebug project


In Common settings - remove allocate console

In Debug symbols  - add quickdebug project

8 Start the debugger.

Apply these settings and press debug, and a select process menu will appear.

Enter quickdebug and press OK.

In the debug perspective you should see something like this

Now set a breakpoint on line 18

Double click in left margin.

Now press zoom to allow the program to continue

 

Go to the application and enter a value “x” and press enter; now the code should break at line 18 allowing for debugging of the test environment application.

9 Use the debugger.

The debugger is attached to the program in testbin and using the source and debug symbols in the quickdebug project via a glue project APquickdebug.

Note

Just clean compiling both projects seems to reset everything in case of any trouble.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-03-07 14:12
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.