| Previous | Contents | Index |
The sample debugging session in Example 8-2 demonstrates how Ladebug handles the symbols from the sample COBOL program in Example 8-1.
| Example 8-2 Sample COBOL Debugging Session |
|---|
Welcome to the Ladebug Debugger Version 4.0
------------------
object file name: example
Reading symbolic information ...done
(ladebug) stop at 51
[#1: stop at "example.cob":51 ]
(ladebug) run
*** Ladebug COBOL Example ***
A_1 = 1
B-2 = 2
C_3 = 3
C-3 = 3
D-4 = 4
D_4 = 4
[1] stopped at [cobol_example:51 0x12000cd14]
51 CALL "Overloaded-Name".
(ladebug) whatis d-4 (1)
array [subrange 1 ... 1 of int] of char d-4
(ladebug) whatis D_4 (1)
array [subrange 1 ... 1 of int] of char D_4
(ladebug) print d_4 (1)
"4"
(ladebug) whereis d-4 (1)
"example.cob"`cobol_example`D-4
(ladebug) whereis b-2 (2)
"B_2"
B_2
"example.cob"`cobol_example`B_2
"example.cob"`overloaded_name`B-2
"example.cob"`b_2
(ladebug) which b-2 (3)
"example.cob"`cobol_example`B_2
(ladebug) print b-2 (4)
2
(ladebug) step
stopped at [overloaded_name:61 0x12000ce04]
61 program-id. OverLoaded-NAME.
(ladebug) stop at 78
[2] stopped at [cobol_example:78 0x12000cf20]
(ladebug) next
stopped at [overloaded_name:69 0x12000ce30]
69 display "*** Overloaded-Name ***".
(ladebug) which b-2 (5)
"example.cob"`overloaded_name`B-2
(ladebug) whatis b-2
pic 99 usage display b-2
(ladebug) print b-2
12
(ladebug) return
*** Overloaded-Name ***
b_2 = 12
*** end of Overloaded-Name ***
stopped at [cobol_example:51 0x12000cd58]
51 CALL "Overloaded-Name".
(ladebug) n
stopped at [cobol_example:52 0x12000cd68]
52 CALL "B-2".
(ladebug) s
stopped at [b_2:78 0x12000cef4]
78 program-id. b-2.
(ladebug) which b-2
"c_example6-2.cob"`b_2
(ladebug) whatis c_example6-2.cob`b_2
void b_2(void)
(ladebug) cont
*** b_2 ***
*** end of b_2 ***
***END Ladebug COBOL Example***
Thread has finished executing
(ladebug) q
|
"example.cob"`cobol_example`B_2 -- PIC X external "example.cob"`overloaded_name`B-2 -- PIX 99 "example.cob"`b_2 -- program id |
For another example of debugging a COBOL program with Ladebug, see the
appendix on tools in the <REFERENCE>(DEC_COB_UM).
8.4 Debugging Mixed-Language Programs
The Ladebug debugger lets you debug mixed-language programs. The flow of control across programs written in different languages in your executable image is transparent.
The debugger automatically identifies the language of the current program or code segment on the basis of information embedded in the executable file. For example, if program execution is suspended in a code segment in COBOL, the current language is COBOL. If the program executes a C function, the current language becomes C. The current language determines for the debugger the valid expression syntax and the semantics used to evaluate an expression.
The debugger sets the $lang variable to the language of the current program or code segment. By manually setting the $lang debugger variable, you can force the debugger to interpret expressions used in commands by the rules and semantics of a particular language. For example, you can check the current setting of $lang and change it as follows:
(ladebug) print $lang "C++" (ladebug) set $lang = "Cobol" |
When the debugger reaches the end of your program, the $lang variable is not set to the
language of the _exit routine, which is
written in machine code.
8.5 Limitations on Assignment
The following limitations apply to assignment in COBOL debugging:
01 itema pic 9(9)v99. 01 itemb pic 9999v99. 01 bigitem pic 9(13)v9(5). |
(ladebug) assign itema = 1.23 (ladebug) assign itema = 8765.22 (ladebug) assign itema = itemb |
(ladebug) assign itema = 1.2 (ladebug) assign bigitem = itema |
(ladebug) assign itemb = itema |
Other limitations when you debug COBOL programs include:
01 A.
03 B.
05 C pic 9.
|
C of B of a |
(ladebug) ./10i |
(ladebug) ./10 i |
This part describes the following advanced debugging topics:
With the debugger, you can debug more than one program or process. This chapter explains how to:
This chapter contains two sample multiprocess debugging sessions, one
from the graphical user interface, (see Section 9.1.3), and one from
the command interface (see Section 9.1.4).
9.1 Debugging Multiprocess Applications
This section describes how to bring a process under debugger control
and attach and detach a process, and contains a sample session.
9.1.1 Bringing a Process Under Debugger Control
The Source View Context Panel contains menu buttons that list the processes under debugger control. It allows you to change the process by selecting any process on the menu and making it the current process.
To select a process, pull down the Process menu button and select the
process you want. The contents of the Source View and the Call Stack
and any displayed optional views are updated to reflect the current
context.
9.1.2 Attaching and Detaching Processes
To attach to a process not currently under debugger control, choose Command:Attach to Process in the Main Window. This displays a Process Selection dialog box that shows you the list of active processes to which you have access (Figure 9-1).
Figure 9-1 Process Selection Dialog Box
Select the process you want to attach to. The Source View reflects the new process. If you have optional views displayed, they will be updated to reflect the new process.
If no breakpoint is set in the process to which you are attaching, the process will run to completion. However, you can set the $stoponattach toggle in the dialog box to stop the process right after the debugger attaches to it by default.
The Source View will not reflect the new process if the debugger cannot find the path to the actual source file.
You can attach to a process using the attach or load command at the command prompt. The views are not updated until the run command is executed. If a break is not set, the process will run to completion. Use the stop in or stop at command to set a break. For more information, see Section 3.2.8.
After Ladebug attaches to a process, control is returned to the debugger when the process stops (for example, after having received a signal). You can also manually return control to the debugger by pressing Ctrl/C.
To detach a process, choose Commands:Detach Process in the Main Window. This displays a dialog box showing all the current processes under debugger control.
Click on the desired process to remove it from debugger control. If the process is current (displayed in the Source View and Optional Views), the process will run to completion and the views are reinitialized (blanked out). If the process you detach is not current, it will run to completion and the current process will continue to display in the Source View.
The views do not close automatically. To close the views, use the Views menu or exit the debugger.
You can also detach a process by using the detach command at the command prompt. Ladebug only detaches the specified process and removes all the user-specified breakpoints from that process.
The following restrictions apply when you debug an attached process:
This section describes how to use the debugger graphical user interface to debug a multiprocess application. It presents an example application that forks a child process and execs a program.
Ladebug provides predefined debugger variables that you can set in order to debug multiprocess applications that fork and/or exec.
Setting $catchforks to 1 instructs Ladebug to notify the user when a program forks a child process. Setting $catchexecs to 1 instructs Ladebug to notify the user when a program execs. Setting $stopparentonfork to 1 stops the parent process when a program forks a child process.
For more information on debugger variables, see Section 9.1.9.1. For different scenarios in which these variables are used, see Section 9.1.9.2 and Section 9.1.9.3.
The general steps for debugging a multiprocess application are as follows:
Figure 9-2 Multiprocess Application
You can continue debugging the child process or return to the parent process by selecting it in the process menu pulldown. When the process has finished executing, a message displays that process has exited and the Source View reinitializes (blanks out).
You can also bring a process into debugger control in the following ways:
Example 9-1 demonstrates the use of Ladebug commands to debug a multiprocess application using the command interface.
In the first part of the program, the process command shows the current process. The load lets you load an image or core file. Specifying show process all displays a list of processes, running or stopped.
| Example 9-1 Debugging a Multiprocess Application - Loading an Image File and Showing Processes |
|---|
$ ladebug Welcome to the Ladebug Debugger Version 4.0-9 (ladebug) process There is no current process. You may start one by using the `load' or `attach' commands. (ladebug) load a.out Reading symbolic information ...done (ladebug) process(1) Current Process: localhost:18340 (a.out). (ladebug) show process all(2) >localhost:18340 (a.out) Unstarted. (ladebug) load file-func Reading symbolic information ...done (ladebug) process Current Process: localhost:18551 (file-func).(3) (ladebug) show process all(4) localhost:18340 (a.out) Unstarted. >localhost:18551 (file-func) Unstarted. (ladebug) process 18340(5) (ladebug) process Current Process: localhost:18340 (a.out). (ladebug) list 1(6) 1 2 int main(int argc, char* argv[]) 3 { 4 int a = sizeof(**argv); 5 int b = sizeof(+(**argv)); 6 int c = sizeof(-(**argv)); 7 return a+b+c; 8 } |
Switching between processes sets the current process context, as shown in Example 9-2.
| Example 9-2 Debugging a Multiprocess Application - Switching Between Processes |
|---|
(ladebug) process 18551(1) (ladebug) process Current Process: localhost:18551 (file-func). (ladebug) list 1(2) 1 2 3 #include <stdio.h> 4 5 int gfi = 100; 6 7 int g1 = 10; 8 9 int funcA(i) { 10 11 int a, x; 12 x = 1; 13 a = i + g1 + x; 14 return a; 15 } 16 17 int funcB(i) { 18 19 int a; 20 a = i; 21 return a; |
| Previous | Next | Contents | Index |