You need to run through the
Java calling COBOL and accessing COBOL working-storage (separate projects) example before attempting this, as it creates the projects required (
JCallShare and
CCallShare) to complete these steps.
The attach to process technique used here can also be applied to the other examples in this section that deal with separate
projects.
-
Set two breakpoints in the Java program (Demo4.java):
-
From within
JCallShare, open
Demo4.java in the editor.
-
Set breakpoints on line 9 (the line that reads
System.out.println("--Java--");) and line 37 (the line that reads
progs.demo4();).
-
Set a breakpoint in the first COBOL program (demo4.cbl):
-
From within
CCallShare, open
demo4.cbl in the editor.
-
Set a breakpoint on line 15 (the line that reads
display "--In COBOL Program demo4--").
-
Click
to the right of
(Debug) and select the run configuration that you used to run
Demo4.java in the previous example.
-
If you are prompted to switch to the Debug perspective, click
Switch.
The Debug perspective is displayed, and the debugger runs until it hits the first breakpoint set in
Demo4.java.
-
Use the usual debug commands to step into, step over, etc... until you reach the next breakpoint (line 37 -
progs.demo4();).
Shortcut: Click
(
Resume) to jump to the breakpoint.
At this point, only
Demo4.java is on the debug stack. We need to also attach
demo4.cbl, so that we can also step though that code.
-
Attach
demo4.cbl to the running Java debug process:
-
Click
to the right of
(Debug) and select
Debug Configurations.
The
Debug Configurations dialog box is displayed.
-
In the left-hand pane, double-click
COBOL Attach to Process.
A new configuration is displayed in the right-hand pane.
-
In the
Name field, enter a name for the configuration.
-
Click
Browse to the right of the
COBOL Project field, and then select
CCallShare.
-
Click
Debug.
The
Select Process dialog box is displayed.
-
Select the Java process currently being debugged, and then click
OK.
Tip: The process is named
javaw.exe; if you have more than one entry, match the process ID with the one displayed in the debug stack.
The
demo4.cbl program is added to the stack.
-
Within the debug stack, ensure that the
Demo4.main entry is selected, and then click
(Resume) again.
Debugging flow continues to
demo4.cbl and stops on the breakpoint set previously.
-
Continue to debug as normal.
This demonstrates how you can debug through both the Java code and the COBOL code.