How to remote debug using attach to process
How to attach to a remote unix process and debug, using Visual COBOL for eclipse based on a PC.
VISUAL COBOL for eclipse installed on PC.
Visual COBOL development hub installed on the Unix machine.
RDO daemon process must be running.
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.
Insert the code from Program1.cbl below
The code for Program1.cbl
This program will just sit there accepting input until “Q” is pressed.
This emulates a standalone process which we can attach to and debug.
Make a directory testbin in the user home directory on the Unix machine.
This is to emulate deployment of the executable quickdebug to a test environment.
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"
/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.
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
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
#!/usr/bin/bash # trace myprogram #truss -e -rall -f -o junk.truss ./Program1 # oldpwd=$PWD cd testbin ./quickdebug cd $oldpwd # # end #
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.
The application will be asking for input.
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
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.
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.
Just clean compiling both projects seems to reset everything in case of any trouble.