329 lines
18 KiB
HTML
329 lines
18 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Example in ILE C: Logging software error (OPM API without pointers)" />
|
|
<meta name="abstract" content="This program illustrates how to use APIs to log software errors using FFDC." />
|
|
<meta name="description" content="This program illustrates how to use APIs to log software errors using FFDC." />
|
|
<meta name="DC.Relation" scheme="URI" content="opmIlecompare.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="opmLoggingCOBOL.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="opmLoggingRPG.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="opmLoggingILERPG.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="opmLoggingILEC" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Example in ILE C: Logging software error (OPM API without pointers)</title>
|
|
</head>
|
|
<body id="opmLoggingILEC"><a name="opmLoggingILEC"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example in ILE C: Logging software error (OPM API without pointers)</h1>
|
|
<div><p>This program illustrates how to use APIs to log software errors
|
|
using FFDC. </p>
|
|
<div class="section"><p>This program calls the Log Software Error (QPDLOGER) API to perform
|
|
FFDC without the use of pointers. The OPM program physically moves the data
|
|
that is pointed to, as shown at <a href="#opmLoggingILEC__SPTNOPTR">(1)</a>,
|
|
which slows down performance.</p>
|
|
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for
|
|
important legal information.</div>
|
|
<pre>/*********************************************************************/
|
|
/* */
|
|
/*Program Name: FFDCPGM1 */
|
|
/* */
|
|
/*Program Language: ILE C */
|
|
/* */
|
|
/*Description: This program illustrates how to use APIs to log */
|
|
/* software errors using FFDC. */
|
|
/* */
|
|
/* */
|
|
/*Header Files Included: except */
|
|
/* stdio */
|
|
/* string */
|
|
/* qmhchgem */
|
|
/* qpdloger */
|
|
/* qusec */
|
|
/* */
|
|
/*APIs Used: QPDLOGER */
|
|
/* */
|
|
/*********************************************************************/
|
|
/*********************************************************************/
|
|
/*********************************************************************/
|
|
/* System Includes */
|
|
/*********************************************************************/
|
|
#include <except.h> /* from QSYSINC/H */
|
|
#include <stdio.h> /* from QSYSINC/H */
|
|
#include <string.h> /* from QSYSINC/H */
|
|
|
|
/*********************************************************************/
|
|
/* Miscellaneous Includes */
|
|
/*********************************************************************/
|
|
#include <qmhchgem.h>
|
|
#include <qpdloger.h>
|
|
#include <qusec.h>
|
|
|
|
/*********************************************************************/
|
|
/* Structures */
|
|
/*********************************************************************/
|
|
typedef struct {
|
|
void *parm1;
|
|
void *parm2;
|
|
char *pgm_name;
|
|
int pgm_name_size;
|
|
} ffdc_info_t;
|
|
|
|
/*********************************************************************/
|
|
/* Prototypes */
|
|
/*********************************************************************/
|
|
void UNEXPECTED_HDLR(_INTRPT_Hndlr_Parms_T *);
|
|
|
|
/*********************************************************************/
|
|
/* FUNCTION NAME: main */
|
|
/* */
|
|
/* FUNCTION: Generates exception and then passes control */
|
|
/* to exception handler. */
|
|
/* */
|
|
/* INPUT: Two character strings. */
|
|
/* */
|
|
/* OUTPUT: NONE */
|
|
/* */
|
|
/* EXCEPTIONS: CPFxxxx - All unexpected CPF exceptions */
|
|
/* MCHxxxx - All unexpected MCH exceptions */
|
|
/* */
|
|
/*********************************************************************/
|
|
void main(int argc, char *argv[])
|
|
{
|
|
|
|
/*******************************************************************/
|
|
/* NOTE: argv will contain the parameters passed in to this */
|
|
/* function. In this case, two parameters are passed */
|
|
/* in. */
|
|
|
|
/*******************************************************************/
|
|
/*******************************************************************/
|
|
/* The argv parameter contains the parameters that were passed as */
|
|
/* character arrays. argv[0] contains the program name, and the */
|
|
/* parameter(s) starts with argv[1]. */
|
|
/*******************************************************************/
|
|
|
|
char *nulptr; /* Pointer used to generate error */
|
|
char pgm_name[30]; /* Program name */
|
|
volatile ffdc_info_t ffdc_info; /* FFDC info for unexpected error */
|
|
|
|
/*******************************************************************/
|
|
/* Set up FFDC information for unexpected error. */
|
|
/*******************************************************************/
|
|
ffdc_info.parm1 = argv[1];
|
|
ffdc_info.parm2 = argv[2];
|
|
ffdc_info.pgm_name = pgm_name;
|
|
memcpy(pgm_name, argv[0], strlen(argv[0]));
|
|
ffdc_info.pgm_name_size = strlen(argv[0]);
|
|
|
|
/*******************************************************************/
|
|
/* Enable the exception handler, and pass ffdc_info into the */
|
|
/* exception handler via the communications area so that data */
|
|
/* can be used for FFDC. */
|
|
/*******************************************************************/
|
|
|
|
#pragma exception_handler (UNEXPECTED_HDLR, ffdc_info, 0, _C2_MH_ESCAPE)
|
|
|
|
/*******************************************************************/
|
|
/* Set the pointer to null, then try to increment. This will */
|
|
/* generate an MCH3601 error that will be trapped by the */
|
|
/* unexpected handler. */
|
|
/*******************************************************************/
|
|
nulptr = NULL;
|
|
nulptr++;
|
|
|
|
#pragma disable_handler
|
|
|
|
} /* main */
|
|
|
|
/*********************************************************************/
|
|
/* FUNCTION NAME: UNEXPECTED_HDLR */
|
|
/* */
|
|
/* FUNCTION: Handle unexpected exception. This exception */
|
|
/* handler is used to log the software error via */
|
|
/* FFDC. */
|
|
/* */
|
|
/* INPUT: Interrupt handler information */
|
|
/* */
|
|
/* OUTPUT: NONE */
|
|
/* */
|
|
/* EXCEPTIONS: CPFxxxx - All unexpected CPF exceptions */
|
|
/* MCHxxxx - All unexpected MCH exceptions */
|
|
/* */
|
|
/*********************************************************************/
|
|
void UNEXPECTED_HDLR(_INTRPT_Hndlr_Parms_T *errmsg)
|
|
{
|
|
|
|
typedef struct {
|
|
char obj_name[30];
|
|
char obj_lib[30];
|
|
char obj_type[10];
|
|
} obj_info_t;
|
|
|
|
typedef struct {
|
|
int data_offset;
|
|
int data_length;
|
|
} data_info_t;
|
|
|
|
char pgm_suspected[10],
|
|
msg_id[12],
|
|
msg_key[4],
|
|
print_job_log,
|
|
data[2*(sizeof(char *))],
|
|
*data_item,
|
|
ile_mod_name[11];
|
|
int point_of_failure,
|
|
num_items,
|
|
num_objs;
|
|
data_info_t data_info[2];
|
|
obj_info_t obj_info[1];
|
|
ffdc_info_t *ffdc_info;
|
|
Qus_EC_t ErrorCode;
|
|
|
|
ErrorCode.Bytes_Provided = 0;
|
|
|
|
/*******************************************************************/
|
|
/* Getting pointer in local storage to the Communications Area. */
|
|
/*******************************************************************/
|
|
ffdc_info = (ffdc_info_t *)(errmsg->Com_Area);
|
|
|
|
/*******************************************************************/
|
|
/* Need to notify message handler that we will handle the error. */
|
|
/* Leave the message in the job log, just mark it handled. */
|
|
/*******************************************************************/
|
|
QMHCHGEM(&(errmsg->Target), /* Invocation pointer */
|
|
0, /* Call stack counter */
|
|
(char *)&errmsg->Msg_Ref_Key,/* Message key */
|
|
"*HANDLE ", /* Modification option */
|
|
"", /* Reply text */
|
|
0, /* Reply text length */
|
|
&ErrorCode); /* Error code */
|
|
|
|
/*******************************************************************/
|
|
/* Set up the suspected program. */
|
|
/*******************************************************************/
|
|
memcpy(pgm_suspected, "*PRV ", 10);
|
|
|
|
/*******************************************************************/
|
|
/* Set up the detection identifier. */
|
|
/*******************************************************************/
|
|
memset(msg_id, ' ', 12);
|
|
memcpy(msg_id, errmsg->Msg_Id, 7);
|
|
|
|
/*******************************************************************/
|
|
/* Set up the message key. */
|
|
/*******************************************************************/
|
|
memcpy(msg_key, (char *)&errmsg->Msg_Ref_Key, 4);
|
|
|
|
/*******************************************************************/
|
|
/* Set up point of failure. Since this example program is small */
|
|
/* and we know where the error occurred, we will just put a dummy */
|
|
/* value in. However, this can be very useful information in */
|
|
/* larger programs. */
|
|
/*******************************************************************/
|
|
point_of_failure = 100;
|
|
|
|
/*******************************************************************/
|
|
/* Set up to print the job log. */
|
|
/*******************************************************************/
|
|
print_job_log = 'Y';
|
|
|
|
/*******************************************************************/
|
|
/* Set up data items. */
|
|
/*******************************************************************/
|
|
data_item = data;
|
|
|
|
/*******************************************************************/
|
|
/* Put in first parameter. */
|
|
/*******************************************************************/
|
|
memcpy(data_item, (char *)ffdc_info->parm1, sizeof(char *)); <span class="uicontrol" id="opmLoggingILEC__SPTNOPTR"><a name="opmLoggingILEC__SPTNOPTR"><!-- --></a>(1)</span>
|
|
|
|
/*******************************************************************/
|
|
/* Add in the second parameter. */
|
|
/*******************************************************************/
|
|
data_item += sizeof(char *);
|
|
memcpy(data_item, (char *)ffdc_info->parm2, sizeof(char *));
|
|
|
|
/*******************************************************************/
|
|
/* Reset the data item pointer. */
|
|
/*******************************************************************/
|
|
data_item -= sizeof(char *);
|
|
|
|
/*******************************************************************/
|
|
/* Set up data item offset/length information. */
|
|
/*******************************************************************/
|
|
data_info[0].data_offset = 0;
|
|
data_info[0].data_length = sizeof(char *);
|
|
data_info[1].data_offset = sizeof(char *);
|
|
data_info[1].data_length = sizeof(char *);
|
|
|
|
/*******************************************************************/
|
|
/* Set up the number of data items. In this case we only have one.*/
|
|
/*******************************************************************/
|
|
num_items = 2;
|
|
|
|
/*******************************************************************/
|
|
/* Set up the object name array. In this case, we have no objects */
|
|
/* to dump, but we will put dummy values in to illustrate. */
|
|
/*******************************************************************/
|
|
memcpy(obj_info[0].obj_name, "OBJUSRSPC ", 30);
|
|
memcpy(obj_info[0].obj_lib, "QTEMP ", 30);
|
|
memcpy(obj_info[0].obj_type, "*USRSPC ", 10);
|
|
|
|
/*******************************************************************/
|
|
/* Set the number of objects in name array. */
|
|
/*******************************************************************/
|
|
num_objs = 0;
|
|
|
|
/*******************************************************************/
|
|
/* Set up the ILE module name. */
|
|
/*******************************************************************/
|
|
memcpy(ile_mod_name, ffdc_info->pgm_name, ffdc_info->pgm_name_size);
|
|
|
|
/*******************************************************************/
|
|
/* Call QPDLOGER to perform FFDC. */
|
|
/*******************************************************************/
|
|
ErrorCode.Bytes_Provided = sizeof(ErrorCode);
|
|
QPDLOGER(pgm_suspected,
|
|
msg_id,
|
|
msg_key,
|
|
point_of_failure,
|
|
&print_job_log,
|
|
data_item,
|
|
data_info,
|
|
num_items,
|
|
obj_info,
|
|
num_objs,
|
|
&ErrorCode,
|
|
ile_mod_name);
|
|
|
|
} /* UNEXPECTED_HDLR */</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="opmIlecompare.htm" title="This topic gives an overview of how Original Program Model (OPM) APIs and Integrated Language Environment (ILE) APIs differ from each other. The ILE APIs include the UNIX-type APIs and the ILE CEE APIs, among others.">OPM and ILE API differences</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="opmLoggingCOBOL.htm" title="This program registers an OPM COBOL Error Handler. After the successful completion of the registration of the error handler, this , program creates a data decimal error. This exception causes the error handler to be called which then logs the software error.">Example in OPM COBOL: Logging software error (OPM API without pointers)</a></div>
|
|
<div><a href="opmLoggingRPG.htm" title="This program performs a divide-by-0 operation to cause an exception. This exception is caught using RPG *PSSR support, and the exception is then logged as a software error.">Example in OPM RPG: Logging software error (OPM API without pointers)</a></div>
|
|
<div><a href="opmLoggingILERPG.htm" title="This program performs a divide by 0 operation to cause an exception. This exception is caught using RPG's *PSSR support, and the exception is then logged as a software error.">Example in ILE RPG: Logging software error (OPM API without pointers)</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |