ibm-information-center/dist/eclipse/plugins/i5OS.ic.apiref_5.4.0.1/opmReportingILEC.htm

272 lines
15 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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: Report software error (ILE API with 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="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="opmReportingILEC" />
<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: Report software error (ILE API with pointers)</title>
</head>
<body id="opmReportingILEC"><a name="opmReportingILEC"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example in ILE C: Report software error (ILE API with 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 Report Software Error (QpdReportSoftwareError)
API to perform FFDC, and uses pointers. This ILE program sets a pointer, as
shown at <a href="#opmReportingILEC__SPTPTR">(2)</a>, to point to the
same location as in the <a href="opmLoggingILEC.htm">OPM program</a> at <span class="uicontrol">(1)</span>.</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: FFDCPGM2 */
/* */
/*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 */
/* qpdsrvpg */
/* qusec */
/* */
/*APIs Used: QpdReportSoftwareError */
/* */
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/* System Includes */
/*********************************************************************/
#include &lt;except.h&gt; /* from QSYSINC/H */
#include &lt;stdio.h&gt; /* from QSYSINC/H */
#include &lt;string.h&gt; /* from QSYSINC/H */
/*********************************************************************/
/* Miscellaneous Includes */
/*********************************************************************/
#include &lt;qmhchgem.h&gt;
#include &lt;qpdsrvpg.h&gt;
#include &lt;qusec.h&gt;
/*********************************************************************/
/* Definitions used for developing key information for FFDC. */
/*********************************************************************/
#define CHARACTER 'C'
#define MAX_KEYS 3
#define MESSAGE "MSG"
#define MESSAGE_LEN 7
#define MSG_SYMPTOM_LEN 3
/*********************************************************************/
/* 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)
{
int i = 0,
MsgLen = 0,
number_of_keys = 0;
char pgm_name[30],
context_name[30],
lib_name[5],
symptom_msg_data[MESSAGE_LEN],
symptom_msg_keyword[MSG_SYMPTOM_LEN];
ffdc_info_t *ffdc_info;
Qpd_Data_t data_key,
data_key2;
Qpd_Key_Pointer_t ffdc_keys[MAX_KEYS];
Qpd_Suspected_Module_t module_key;
Qpd_Symptom_t symptom_msg_key;
Qus_EC_t ErrorCode;
ErrorCode.Bytes_Provided = 0;
/*******************************************************************/
/* Getting pointer in local storage to the Communications Area. */
/*******************************************************************/
ffdc_info = (ffdc_info_t *)(errmsg-&gt;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(&amp;(errmsg-&gt;Target), /* Invocation pointer */
0, /* Call stack counter */
(char *)&amp;errmsg-&gt;Msg_Ref_Key,/* Message key */
"*HANDLE ", /* Modification option */
"", /* Reply text */
0, /* Reply text length */
&amp;ErrorCode); /* Error code */
/*******************************************************************/
/* Initialize module suspected key for FFDC. */
/*******************************************************************/
ffdc_keys[number_of_keys++].Suspected_Module = &amp;module_key;
module_key.Key = Qpd_Suspected_Module;
module_key.Module_Name_Length = ffdc_info-&gt;pgm_name_size;
module_key.Library_Name_Length = 7;
module_key.Module_Name = pgm_name;
memcpy(pgm_name, ffdc_info-&gt;pgm_name, ffdc_info-&gt;pgm_name_size);
module_key.Library_Name = lib_name;
memcpy(lib_name, "TESTLIB", 7);
/*******************************************************************/
/* Initialize symptom keys for FFDC. */
/*******************************************************************/
ffdc_keys[number_of_keys++].Symptom = &amp;symptom_msg_key;
symptom_msg_key.Key = Qpd_Symptom;
symptom_msg_key.Keyword_Length = MSG_SYMPTOM_LEN;
symptom_msg_key.Data_Length = MESSAGE_LEN;
symptom_msg_key.Data_Type = CHARACTER;
memcpy(symptom_msg_keyword, MESSAGE, MSG_SYMPTOM_LEN);
symptom_msg_key.Keyword = symptom_msg_keyword;
memcpy(symptom_msg_data, errmsg-&gt;Msg_Id, MESSAGE_LEN);
symptom_msg_key.Data = symptom_msg_data;
/*******************************************************************/
/* Parameter 1 information */
/*******************************************************************/
ffdc_keys[number_of_keys++].Data = &amp;data_key;
data_key.Key = Qpd_Data;
data_key.Data_Length = sizeof(char *);
data_key.Data_Id = 1;
data_key.Data = ffdc_info-&gt;parm1; <span class="uicontrol" id="opmReportingILEC__SPTPTR"><a name="opmReportingILEC__SPTPTR"><!-- --></a>(2)</span>
/*******************************************************************/
/* Parameter 2 information */
/*******************************************************************/
ffdc_keys[number_of_keys++].Data = &amp;data_key2;
data_key2.Key = Qpd_Data;
data_key2.Data_Length = sizeof(char *);
data_key2.Data_Id = 1;
data_key2.Data = ffdc_info-&gt;parm2;
/*******************************************************************/
/* Call QpdReportSoftwareError to perform FFDC. */
/*******************************************************************/
ErrorCode.Bytes_Provided = sizeof(ErrorCode);
QpdReportSoftwareError(ffdc_keys,
&amp;number_of_keys,
&amp;ErrorCode);
} /* 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>
</body>
</html>