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

Debugging Using Core Dumps

Debugging Using Core Dumps

Problem:

How to generate and debug core dump with Visual COBOL.

Resolution: 

Restriction: The following information applies to NATIVE code only.

 

When an application crashes, its state can be saved to disk in a core dump file. Once a core dump is generated, it can be loaded into the development environment where it can be examined. The dump file can be used to help debug problems, as it indicates where in the source code the error occurred, along with the values of variables, expressions, and the contents of memory as they were at the moment the error occurred. This is most useful in a production environment where it is unlikely that a debugger can be dynamically attached: the core dump can be obtained and then analyzed on another system. The source files and .IDY file(s) must be available for the program(s) that fail, as this allows the core dump to show as much information as possible regarding the state of the program at failure time.

Run-time Tunables

Some run-time behavior cannot be configured using the IDE; this must be configured using run-time tunables, which are set in a run-time configuration file. A text-based run-time configuration file should be created specifying the run-time tunables. Alternatively an application configuration file, Application.config can be used (see below). Additionally a core dump file can be created using CBLCORED (see below).

The COBCONFIG_ environment variable should be set to locate the configuration file, for example:

    SET COBCONFIG_=C:\Config\COBCONFIG.CFG

Configuration file contents

SET CORE_ON_ERROR=131
SET CORE_FILENAME=”C:\\COREDUMP\\CORE\\core.%f.@%t.%d”

CORE_ON_ERROR - Specifies the circumstances in which a core file is produced:

0 - The run-time system never produces a core file on any exception or run-time system error. This is the default behavior of the run-time system.

1 - The run-time system produces a core file when any exception is received that would normally produce a core file on the host system; for example, a run-time system error COBRT153, and so on.

2 - The run-time system produces a core file when any run-time system error occurs. After writing out the core file the process terminates immediately.

3 - The run-time system produces a snap shot core file when any run-time system error occurs. After writing out the core file the process continues as normal; for example, to display an RTS error message.

129 - Same as core_on_error=1, except no message box is displayed after the core file is created.

130 - Same as core_on_error=2, except no message box is displayed after the core file is created.

131 - Same as core_on_error=3, except no message box is displayed after the core file is created.

 

CORE_FILENAME - Specifies the name of the file that will be produced when a core file is generated:

Using the example above a file will be produced and placed in the directory C:\COREDUMP\CORE\ when a program 153core is run and produces a runtime error. The %f adds the base name of the program that encountered the error; %d adds the date and the %t adds the time to the filename.
By default the core file will be created in the same location as the executable files, however the file can be redirected to a specific location. On Windows platforms, in order to use the backslash in a path, it must be preceded with the escape character, which is also a backslash. The result would be:

C:\coredemo\core\core.153core.122536.20160401


Configuring Debug Settings

Load the Visual Studio solution / Project that created the application.

The Debug settings for the Visual Studio project need to be changed to Start external program and point to the core dump file:


Start debugging; the state of the program when it crashed is displayed. The program can now examined at the point at which the crash occurred:

 

Using an Application.config

This can be used as an alternative method to the one described above.

When building executables within the Visual Studio IDE, an Application.config file can be created in order to set various run-time tunables.

The build process will create an <executable-base-name>.exe.mfgcf file in the output folder, for example 153core.exe.mfgcf

To set run-time configuration options, select the Run-time Configuration tab > Error Handling.

  • Set the Core dump file name to required properties of the core_filename.

  • Set the Generate a core dump when a run-time error occurs = 131 (or any of the other core_on_error values as required).

Running the program from within the Visual Studio IDE (CTRL+F5):

Or running the program from a Visual COBOL command prompt:

The core dump will be created in the same location as the program executable, unless a specific path is specified,

For example C:\coredemo2\coredemo2\bin\x86\Debug\core.153core.20160407.120711

Configuring Debug Settings

Load the Visual Studio solution / Project that created the application.

The Debug settings for the Visual Studio project need to be changed to Start external program and point to the core dump file:

Start debugging; the state of the program when it crashed is displayed. The program can now examined at the point at which the crash occurred:


 

Using CBLCORED

 

CBLCORED is a command line utility that can be enabled before running a COBOL application.

In a COBOL Server production environment a core dump can be created and then analyzed on another system that has the development environment together with the source and .idy files available.

When CBLCORED is run a dialog is displayed in order to determine how the utility will behave.

  • Disabled - core dump not required.

  • Enabled with prompt – a message box is displayed when a core dump is about to be created, for example:

  • Enabled with no prompt – no message box displayed when a core dump is about to be created.

When the program fails, a core dump file CBLCORE will be created in the same folder as the application:

Configuring Debug Settings

Load the Visual Studio solution / Project that created the application.

The Debug settings for the Visual Studio project need to be changed to Start external program and point to the core dump file:

Start debugging; the state of the program when it crashed is displayed. The program can now examined at the point at which the crash occurred:

6648.coredemo.zip

3034.coredemo2.zip

 

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:
‎2016-04-08 17:19
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.