1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * @OSF_COPYRIGHT@
- * COPYRIGHT NOTICE
- * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
- * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
- * the full copyright text.
- */
- /*
- * HISTORY
- */
- #ifdef REV_INFO
- #ifndef lint
- static char rcsid[] = "$XConsortium: UilDiags.c /main/15 1996/10/21 11:06:46 cde-osf $"
- #endif
- #endif
- /*
- * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
- /*
- **++
- ** FACILITY:
- **
- ** User Interface Language Compiler (UIL)
- **
- ** ABSTRACT:
- **
- ** This module contains the procedures for issuing diagnostics
- ** for the UIL compiler.
- **
- **
- **--
- **/
- /*
- **
- ** INCLUDE FILES
- **
- **/
- #include <stdio.h>
- #include <signal.h>
- #include <setjmp.h>
- #include <X11/Intrinsic.h>
- #include <X11/Xos.h>
- #include <Xm/Xm.h>
- #include <stdarg.h>
- #include "UilDefI.h"
- #include "UilMessTab.h"
- /*
- **
- ** EXTERNAL Storage
- **
- */
- externaldef(uil_comp_glbl) int Uil_message_count[uil_k_max_status+1];
- /*
- **
- ** OWN Storage
- **
- */
- static boolean issuing_diagnostic;
- static int Uil_diag_status_delay_count;
- /*
- * Fix for CR 5534 - static storage for old signal handlers
- */
- static void (*bus_handler)();
- static void (*sys_handler)();
- static void (*fpe_handler)();
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** diag_store_handlers saves the signal handlers from the calling
- ** application in global variables.
- **
- ** FORMAL PARAMETERS:
- **
- ** none
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** the global signal handler variables are changed.
- **
- **--
- **/
- void diag_store_handlers
- ( void )
- {
- /*
- * Fix for CR 5534 - set the file variables for holding previous bus handlers
- * to NULL and then store the old handlers (if any) when
- * calling signal for the Uil handlers
- */
- bus_handler = signal( SIGBUS, diag_handler ); /* access violations */
- #ifdef SIGSYS
- sys_handler = signal( SIGSYS, diag_handler ); /* bad arguments to sys calls */
- #endif
- fpe_handler = signal( SIGFPE, diag_handler ); /* overflows */
- /*
- * End Fix for CR 5534
- */
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** diag_issue_diagnostic emits a diagnostic to the listing file if
- ** there is one and also sends an error to standard error file.
- **
- ** FORMAL PARAMETERS:
- **
- ** d_message_number: index of the error to issue. The indices are
- ** defined in message.h
- ** a_src_rec: pointer to the source record to issue the
- ** diagnostic against. This data structure has
- ** l_start_column: position within the source line for diagnostic.
- ** A negative value indicates no position.
- ** args: a variable length parameter list that holds the
- ** arguments to be substituted in the diagnositic
- **
- ** IMPLICIT INPUTS:
- **
- ** diag_rz_msg_table: table of messages and their severities defined
- ** in message_table.h
- ** diag_rl_external_code: Possible OS-specific external code
- **
- ** IMPLICIT OUTPUTS:
- **
- ** messages emitted
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** message counts updated
- **
- **--
- **/
- #define buf_size (src_k_max_source_line_length + 1)
- void diag_issue_diagnostic
- ( int d_message_number, src_source_record_type *az_src_rec,
- int l_start_column, ...)
- {
- va_list ap; /* ptr to variable length parameter */
- int severity; /* severity of message */
- int message_number; /* message number */
- char msg_buffer[132]; /* buffer to construct message */
- char ptr_buffer[buf_size]; /* buffer to construct pointer */
- char loc_buffer[132]; /* buffer to construct location */
- char src_buffer[buf_size]; /* buffer to hold source line */
- /*
- ** check if we are in a loop issuing errors
- */
- if (issuing_diagnostic)
- {
- _debug_output( "nested diagnostics issued" );
- Uil_message_count[ uil_k_severe_status ]++;
- uil_exit( uil_k_severe_status );
- }
- issuing_diagnostic = TRUE;
- /*
- ** determine the severity of the error. For d_submit_spr we issue
- ** the fix previous error diagnostic, if we encountered prior errors;
- ** otherwise we let it thru.
- */
- message_number = d_message_number;
- if (message_number == d_submit_spr)
- if (Uil_message_count[ uil_k_error_status ] > 0)
- message_number = d_prev_error;
- severity = diag_rz_msg_table[ message_number ].l_severity;
- /*
- ** check if messages of this severity are to be reported.
- */
- switch (severity)
- {
- case uil_k_info_status:
- if (Uil_cmd_z_command.v_report_info_msg)
- break;
- issuing_diagnostic = FALSE;
- return;
- case uil_k_warning_status:
- if (Uil_cmd_z_command.v_report_warn_msg)
- break;
- issuing_diagnostic = FALSE;
- return;
- default:
- ;
- }
- Uil_message_count[ severity ]++;
- if (severity > uil_l_compile_status)
- uil_l_compile_status = severity;
- /*
- ** Diagnostic format varies considerably
- ** 1) no source
- ** message
- ** 2) source but no column
- ** source line
- ** message
- ** location in source message
- ** 3) source and column
- ** source line
- ** column pointer
- ** message
- ** location in source message
- ** 4) source and column but no access key
- ** message
- ** location in source message
- */
- /*
- ** substitute any parameters into the error message placing the
- ** resultant string in msg_buffer
- */
- va_start(ap, l_start_column);
- #ifndef NO_MESSAGE_CATALOG
- vsprintf( msg_buffer,
- catgets(uil_catd, UIL_SET1, msg_cat_table[ message_number ],
- diag_rz_msg_table[ message_number ].ac_text),
- ap );
- #else
- vsprintf( msg_buffer,
- diag_rz_msg_table[ message_number ].ac_text,
- ap );
- #endif
- va_end(ap);
- src_buffer[ 0 ] = 0;
- loc_buffer[ 0 ] = 0;
- ptr_buffer[ 0 ] = 0;
- if (az_src_rec != diag_k_no_source)
- {
- if ( !_src_null_access_key(az_src_rec->z_access_key) )
- {
- /*
- ** create the location line line
- */
- #ifndef NO_MESSAGE_CATALOG
- sprintf( loc_buffer,
- catgets(uil_catd, UIL_SET_MISC,
- UIL_MISC_0, "\t\t line: %d file: %s"),
- az_src_rec->w_line_number,
- src_get_file_name( az_src_rec ) );
- #else
- sprintf( loc_buffer,
- "\t\t line: %d file: %s",
- az_src_rec->w_line_number,
- src_get_file_name( az_src_rec ) );
- #endif
- /*
- ** retrieve the source line
- */
- src_buffer[ 0 ] = '\t';
- src_retrieve_source( az_src_rec, &src_buffer[ 1 ] );
- /*
- ** filter the standard unprintable characters.
- */
- lex_filter_unprintable_chars
- ( (unsigned char *)src_buffer, strlen( src_buffer ), 0 );
- /*
- ** create the column pointer if a source position was given
- */
- if (l_start_column != diag_k_no_column)
- {
- int i;
- for (i=0; i < l_start_column+1; i++)
- {
- if (src_buffer[ i ] == '\t')
- ptr_buffer[ i ] = '\t';
- else
- ptr_buffer[ i ] = ' ';
- }
- ptr_buffer[ i++ ] = '*';
- ptr_buffer[ i ] = 0;
- }
- }
- else /* no access key */
- {
- /*
- ** create the location line line
- */
- if (l_start_column != diag_k_no_column)
- #ifndef NO_MESSAGE_CATALOG
- sprintf(loc_buffer,
- catgets(uil_catd, UIL_SET_MISC,
- UIL_MISC_1,
- "\t\t line: %d position: %d file: %s"),
- az_src_rec->w_line_number,
- l_start_column + 1,
- src_get_file_name( az_src_rec ) );
- #else
- sprintf(loc_buffer,
- "\t\t line: %d position: %d file: %s",
- az_src_rec->w_line_number,
- l_start_column + 1,
- src_get_file_name( az_src_rec ) );
- #endif
- else
- #ifndef NO_MESSAGE_CATALOG
- sprintf( loc_buffer, catgets(uil_catd, UIL_SET_MISC,
- UIL_MISC_0,
- "\t\t line: %d file: %s"),
- az_src_rec->w_line_number,
- src_get_file_name( az_src_rec ) );
- #else
- sprintf( loc_buffer,
- "\t\t line: %d file: %s",
- az_src_rec->w_line_number,
- src_get_file_name( az_src_rec ) );
- #endif
- }
- }
- /*
- ** issue the error to standard error file (system specific)
- */
- write_msg_to_standard_error
- ( message_number, src_buffer, ptr_buffer, msg_buffer, loc_buffer );
- /*
- ** if we have a listing, place message in the source structure
- */
- if (Uil_cmd_z_command.v_listing_file)
- src_append_diag_info
- ( az_src_rec, l_start_column, msg_buffer, message_number );
- issuing_diagnostic = FALSE;
- /*
- ** if there are fatal errors, print the listing file and exit.
- */
- if (Uil_message_count[ uil_k_severe_status] > 0)
- {
- lst_output_listing();
- uil_exit( uil_k_severe_status );
- }
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** diag_issue_summary emits a diagnostic summary if any diagnostics
- ** were issued during the compilation
- **
- ** FORMAL PARAMETERS:
- **
- ** void
- **
- ** IMPLICIT INPUTS:
- **
- ** Uil_message_count table of messages issued
- **
- ** IMPLICIT OUTPUTS:
- **
- ** messages optionally emitted
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- void diag_issue_summary()
- {
-
- if (uil_l_compile_status == uil_k_success_status)
- return;
- Uil_cmd_z_command.v_report_info_msg = TRUE;
- diag_issue_diagnostic
- ( d_summary,
- diag_k_no_source, diag_k_no_column,
- Uil_message_count[ uil_k_error_status ],
- Uil_message_count[ uil_k_warning_status ],
- Uil_message_count[ uil_k_info_status ] );
- return;
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** The major constructs in the UIL language each have a data structure
- ** and a tag value in the first byte of that data structure. Given
- ** a tag value, this routine will return a string that can be substituted
- ** in an error message to describe that construct.
- **
- ** FORMAL PARAMETERS:
- **
- ** b_tag
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** char * text corresponding to tag
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- char *diag_tag_text( b_tag )
- int XmConst b_tag;
- {
- switch (b_tag)
- {
- case sym_k_value_entry:
- return "value";
- case sym_k_widget_entry:
- return "widget";
- case sym_k_gadget_entry:
- return "gadget";
- case sym_k_child_entry:
- return "auto child";
- case sym_k_module_entry:
- return "module";
- case sym_k_proc_def_entry:
- case sym_k_proc_ref_entry:
- return "procedure";
- case sym_k_identifier_entry:
- return "identifier";
- /* These are used by the symbol table dumper. */
- case sym_k_argument_entry:
- return "argument";
- case sym_k_callback_entry:
- return "callback";
- case sym_k_control_entry:
- return "control";
- case sym_k_name_entry:
- return "name";
- case sym_k_forward_ref_entry:
- return "forward ref";
- case sym_k_external_def_entry:
- return "external def";
- case sym_k_list_entry:
- return "list";
- case sym_k_root_entry:
- return "root";
- case sym_k_include_file_entry:
- return "include file";
- case sym_k_def_obj_entry:
- return "default variant";
- case sym_k_section_entry:
- return "section";
- default:
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_1, "** unknown **"));
- #else
- return "** unknown **";
- #endif
- }
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** Each widget in the UIL language has a integer value. Given this
- ** value, this routine will return a string that can be substituted
- ** in an error message to describe that widget.
- **
- ** FORMAL PARAMETERS:
- **
- ** b_type integer rep of the widget type
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** char * text corresponding to type
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- char *diag_object_text( b_type )
- int XmConst b_type;
- {
- if ( b_type <= sym_k_error_object )
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_0, "** error **"));
- #else
- return "** error **";
- #endif
- if ( b_type <= uil_max_object )
- return uil_widget_names[b_type];
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_1, "** unknown **"));
- #else
- return "** unknown **";
- #endif
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** Each value in the UIL language has a integer value. Given this
- ** value, this routine will return a string that can be substituted
- ** in an error message to describe that value.
- **
- ** FORMAL PARAMETERS:
- **
- ** b_type integer rep of the value type
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** char * text corresponding to type
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- char *diag_value_text( b_type )
- int XmConst b_type;
- {
- if ( b_type <= sym_k_error_value )
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_0, "** error **"));
- #else
- return "** error **";
- #endif
- if ( b_type <= sym_k_max_value )
- return uil_datatype_names[b_type];
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_1, "** unknown **"));
- #else
- return "** unknown **";
- #endif
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** Each charset supported by UIL has a integer value. Given this
- ** value, this routine will return a string that can be substituted
- ** in an error message to describe that charset.
- **
- ** FORMAL PARAMETERS:
- **
- ** b_type integer rep of the charset
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** char * text corresponding to type
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- char *diag_charset_text( b_type )
- int XmConst b_type;
- {
-
- if ( b_type <= sym_k_error_charset )
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_0, "** error **"));
- #else
- return "** error **";
- #endif
- if ( b_type <= uil_max_charset )
- return uil_charset_names[b_type];
- #ifndef NO_MESSAGE_CATALOG
- return (catgets(uil_catd, UIL_VALUES, UIL_VAL_1, "** unknown **"));
- #else
- return "** unknown **";
- #endif
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** This routine initializes the diagnostic system. This includes
- ** establishes a handler for catastrophic errors and initializing
- ** error tables.
- **
- ** FORMAL PARAMETERS:
- **
- ** none
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** Uil_message_count
- ** issuing_diagnostic
- ** Uil_diag_status_delay_count
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** error handler is supplied for SIGBUS, SIGFPE and SIGSYS errors
- **
- **--
- **/
- void diag_initialize_diagnostics()
- {
- int i;
- /*
- ** Set up a handler to be invoked if access violations or
- ** bad arguments to sys calls occur.
- ** Other errors should be processed as is standard for the OS.
- */
- /*
- * Fix for CR 5534 - call diag_store_handlers to save the old signal handlers.
- */
- diag_store_handlers();
- /*
- * End Fix for CR 5534
- */
- signal( SIGBUS, diag_handler ); /* access violations */
- #ifdef SIGSYS
- signal( SIGSYS, diag_handler ); /* bad arguments to sys calls */
- #endif
- signal( SIGFPE, diag_handler ); /* overflows */
- /*
- ** Reset the message counts to zero.
- */
- for (i=0; i <= uil_k_max_status; i++)
- Uil_message_count[ i ] = 0;
- /*
- ** Clear the flag that we used to detect recursive error reporinting.
- */
- issuing_diagnostic = FALSE;
- /*
- ** Make sure there is no delay before starting to report status.
- */
- Uil_diag_status_delay_count = 0;
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** This routine resets the handler for detecting overflows.
- **
- ** FORMAL PARAMETERS:
- **
- ** none
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** error handler is supplied for SIGFPE
- **
- **--
- **/
- void diag_reset_overflow_handler()
- {
- signal( SIGFPE, diag_handler ); /* overflows */
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** This routine is the handler for internal errors.
- **
- ** FORMAL PARAMETERS:
- **
- ** l_error type of signal being raised
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** image will exit (done by diag_issue_diagnostic)
- **
- **--
- **/
- void diag_handler( l_error )
- int l_error;
- {
- /*
- ** This handler is invoked for access violations, oeverflows or bad
- ** arguments to sys calls. Other errors are processed as is standard
- ** for the OS. The handler checks on overflow to see if we are trying
- ** to catch them at the moment. Otherwise it issues an internal error.
- */
- if (l_error == SIGFPE)
- {
- if (uil_az_error_env_valid)
- {
- longjmp( uil_az_error_env_block, 1);
- }
- }
- #if debug_version
- {
- char *error_text;
-
- switch (l_error)
- {
- case SIGBUS:
- error_text = "Access Violation";
- break;
- #ifdef SIGSYS
- case SIGSYS:
- error_text = "Bad system call";
- break;
- #endif
- case SIGFPE:
- error_text = "Overflow";
- break;
- default:
- error_text = "Unknown reason";
- }
- diag_issue_internal_error( error_text );
- }
-
- #else
- diag_issue_internal_error( NULL );
- #endif
- /* we don't expect to come back */
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** This routine issues an internal error.
- **
- ** FORMAL PARAMETERS:
- **
- ** error_text In the debug version this parameter holds a
- ** description of the internal error. In the
- ** non debug version it is omitted.
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** image will exit (done by diag_issue_diagnostic)
- **
- **--
- **/
- void diag_issue_internal_error( error_text )
- char * error_text;
- {
- /*
- ** This routine is a focal point for issuing internal errors.
- ** In DEBUG mode it takes an argument that gives more information
- ** about the failure.
- */
- #if debug_version
- diag_issue_diagnostic
- ( d_bug_check, diag_k_no_source, diag_k_no_column , error_text );
- #else
- diag_issue_diagnostic( d_submit_spr, diag_k_no_source, diag_k_no_column );
- #endif
- /* we don't expect to come back */
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** this routine emits a diagnostic to stderr
- **
- ** FORMAL PARAMETERS:
- **
- ** msg_number: message number
- ** src_buffer: ptr to source buffer for the error
- ** ptr_buffer: ptr to column buffer locator for the error
- ** msg_buffer: ptr to message buffer for the error
- ** loc_buffer: ptr to location buffer for the error
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** messages emitted
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- static char XmConst success_text[1] = "";
- static char XmConst info_text[7] = "Info: ";
- static char XmConst warning_text[10] = "Warning: ";
- static char XmConst error_text[8] = "Error: ";
- static char XmConst severe_text[9] = "Severe: ";
- static char XmConst *severity_table [] =
- { success_text, info_text, warning_text, error_text, severe_text, };
- void write_msg_to_standard_error
- (message_number, src_buffer, ptr_buffer, msg_buffer, loc_buffer)
- XmConst int message_number;
- XmConst char *src_buffer;
- XmConst char *ptr_buffer;
- XmConst char *msg_buffer;
- XmConst char *loc_buffer;
- {
- /*
- ** If message callback was supplied, call it with the description of the
- ** error instead of writing it to standard output.
- */
- if (Uil_cmd_z_command.message_cb != (Uil_continue_type(*)())NULL)
- {
- Uil_status_type return_status;
- /*
- * Fix for 5534 - restore the old signal handers before calling message_cb
- * and restore the Uil signal handlers immediately afterwards
- */
- diag_restore_diagnostics();
- return_status = (*Uil_cmd_z_command.message_cb)(
- Uil_cmd_z_command.message_data,
- message_number,
- diag_rz_msg_table[ message_number ].l_severity,
- msg_buffer,
- src_buffer,
- ptr_buffer,
- loc_buffer,
- Uil_message_count);
- diag_store_handlers();
- /*
- * End Fix for 5534
- */
- /*
- ** If request is for termination, then longjmp back to main routine
- ** and set the return status to reflect user abort.
- */
- if (return_status == Uil_k_terminate)
- uil_exit (uil_k_error_status);
- else
- return;
- }
- /* print source line */
- fprintf ( stderr, "\n" );
- if (src_buffer[ 0 ] != 0)
- {
- fprintf ( stderr, "%s\n", src_buffer );
- }
- /* print the source column locator line */
- if (ptr_buffer[ 0 ] != 0)
- {
- fprintf ( stderr, "%s\n", ptr_buffer );
- }
- /* print message line */
- #ifndef NO_MESSAGE_CATALOG
- fprintf ( stderr, "%s%s\n",
- catgets(uil_catd, UIL_SET_MISC,
- diag_rz_msg_table[ message_number ].l_severity,
- severity_table
- [ diag_rz_msg_table[ message_number ].l_severity ]),
- msg_buffer );
- #else
- fprintf ( stderr, "%s%s\n",
- severity_table
- [ diag_rz_msg_table[ message_number ].l_severity ],
- msg_buffer );
- #endif
- /* print location line */
- if (loc_buffer[ 0 ] != 0)
- {
- fprintf ( stderr, "%s\n", loc_buffer );
- }
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** function to return abbreviation for a message number
- **
- ** FORMAL PARAMETERS:
- **
- ** d_message_number message number to look up
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** ptr to text for message number
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- char XmConst *diag_get_message_abbrev( d_message_number )
- int d_message_number;
- {
- return
- severity_table[ diag_rz_msg_table[ d_message_number ].l_severity ];
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** Routine to invoke the user-supplied status callback routine. If none
- ** is supplied this routine returns without error. Otherwise, the user's
- ** delay information is processed and if the requested criteria is met the
- ** user's routine is invoked. with parameters to describe the progress of
- ** the compilation.
- **
- ** FORMAL PARAMETERS:
- **
- ** none
- **
- ** IMPLICIT INPUTS:
- **
- ** Uil_cmd_z_command_line
- **
- ** IMPLICIT OUTPUTS:
- **
- ** Uil_diag_status_delay_count
- **
- ** FUNCTION VALUE:
- **
- ** none
- **
- ** SIDE EFFECTS:
- **
- ** none
- **
- **--
- **/
- void diag_report_status ( )
- {
- Uil_continue_type return_status;
- /*
- ** If no status callback was supplied, just return.
- */
- if (Uil_cmd_z_command.status_cb == (Uil_continue_type(*)())NULL) return;
- /*
- ** If delay is used up (less than or equal to zero) then invoke the
- ** callback, and reset the delay count.
- */
- if (Uil_diag_status_delay_count <= 0)
- {
- Uil_diag_status_delay_count = Uil_cmd_z_command.status_update_delay;
- /*
- * Fix for CR 5534 - restore the application signal handlers before calling
- * status_cb and then return the Uil signal handlers
- * immediately after.
- */
- diag_restore_diagnostics();
- return_status = (*Uil_cmd_z_command.status_cb)(
- Uil_cmd_z_command.status_data,
- Uil_percent_complete,
- Uil_lines_processed,
- Uil_current_file,
- Uil_message_count);
- diag_store_handlers();
- /*
- * End Fix for CR 5534
- */
- /*
- ** If request is for termination, then longjmp back to main routine
- ** and set the return status to reflect user abort.
- */
- if (return_status == Uil_k_terminate)
- {
- uil_exit (uil_k_error_status);
- }
- }
- /*
- ** Delay not used-up, so decrement by one.
- */
- else
- Uil_diag_status_delay_count--;
- }
- /*
- **++
- ** FUNCTIONAL DESCRIPTION:
- **
- ** This routine restores the old signal handlers that were replaced by
- ** Uil. This routine is only called by the callable Uil.
- **
- ** FORMAL PARAMETERS:
- **
- ** none
- **
- ** IMPLICIT INPUTS:
- **
- ** none
- **
- ** IMPLICIT OUTPUTS:
- **
- ** none
- **
- ** FUNCTION VALUE:
- **
- ** void
- **
- ** SIDE EFFECTS:
- **
- ** error handlers for SIGBUS, SIGFPE and SIGSYS errors are restored to
- ** pre-Uil condition.
- **
- **--
- **/
- void
- diag_restore_diagnostics(void)
- {
- /*
- * Fix for CR 5534 - restore the old signal handlers
- */
- signal( SIGBUS, bus_handler );
- #ifdef SIGSYS
- signal( SIGSYS, sys_handler );
- #endif
- signal( SIGFPE, fpe_handler );
- /*
- * End Fix for CR 5534
- */
- }
|