1% BEGIN LICENSE BLOCK 2% Version: CMPL 1.1 3% 4% The contents of this file are subject to the Cisco-style Mozilla Public 5% License Version 1.1 (the "License"); you may not use this file except 6% in compliance with the License. You may obtain a copy of the License 7% at www.eclipse-clp.org/license. 8% 9% Software distributed under the License is distributed on an "AS IS" 10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11% the License for the specific language governing rights and limitations 12% under the License. 13% 14% The Original Code is The ECLiPSe Constraint Logic Programming System. 15% The Initial Developer of the Original Code is Cisco Systems, Inc. 16% Portions created by the Initial Developer are 17% Copyright (C) 1996 - 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22% 23% @(#)umserrors.tex 1.10 96/01/08 24% 25%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26% {\eclipse} Documentation 27% 28% umserrors.tex 29% 30% REL DATE AUTHOR DESCRIPTION 31% 2.10 060490 Eamon Falvey Update for latex.. 32% 3.0 160590 Joachim Schimpf Update for 3.0 33% 3.0 020690 Micha Meier Including the generated errors 34% 35% Use the gen_errors/0 procedure in the file gen_error.pl 36% to generate the input files. 37% 38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39\chapter{Events} 40%HEVEA\cutdef[1]{section} 41\label{errors} 42\label{chaperrors} 43 44We list here the {\eclipse} event types together with the default 45event handlers and their description. 46\index{event handlers}\index{handler!event} 47\index{error handlers}\index{handler!error} 48Unless otherwise specified, the arguments that the system passes 49to the event handler are 50 51\vspace{0.3cm} 52\noindent 53\begin{tabular}{p{4cm}p{4cm}p{4cm}} 54\heading{First Argument} & \heading{Second Argument} 55 & \heading{Third Argument} \\ 56\hline 57Event number & Culprit goal & Caller Module \\ 58\end{tabular} 59 60\vspace{0.3cm} 61\noindent 62If the caller module is unknown, a free variable is passed. 63 64%%%%%%%%%% 65\section{Event Types} 66%The types of events can be classified into the following sections: 67%\begin{itemize} 68%\item Argument Types and Values, Arithmetic 69%\item Data and Memory Areas, Predicates, Modules, Operators 70%\item Run-Time System, Compilation, Execution, Top-Level 71%\item Macro transformation errors. 72%\item I/O, Operating System, External Interface 73%\item Advanced Features, Extensions, Debugging 74%\item User-Defined Events 75%\end{itemize} 76 77\subsection{Argument Types and Values} 78\begin{tabular}{|p{1.2cm}p{8cm}p{5cm}|} 79\hline 80\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 81\hline 82\input{err0.tex} 83\hline 84\end{tabular} 85 86\vfill %<<<<<<<<<<< 87 88\subsection{Arithmetic, Environment} 89\begin{tabular}{|p{1.2cm}p{8cm}p{5cm}|} 90\hline 91\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 92\hline 93\input{err1.tex} 94\hline 95\end{tabular} 96 97\vspace*{\fill} 98 99 100\subsection{Data and Memory Areas, Predicates, Operators} 101\begin{tabular}{|p{1.2cm}p{8cm}p{5.4cm}|} 102\hline 103\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 104\hline 105\input{err2.tex} 106\hline 107\end{tabular} 108 109\subsection{Modules, Visibility} 110\begin{tabular}{|p{1.2cm}p{8cm}p{5.4cm}|} 111\hline 112\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 113\hline 114\input{err3.tex} 115\hline 116\end{tabular} 117\vspace{0.5cm} 118 119\vfill %<<<<<<<<<<<<<<<<<<<<<< 120 121\subsection{Syntax Errors, Parsing} 122\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 123\hline 124\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 125\hline 126\input{err4.tex} 127\hline 128\end{tabular} 129 130\vfill %<<<<<<<<<<<<<<<<<<<<<< 131 132 133\subsection{Compilation, Run-Time System, Execution} 134\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 135\hline 136\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 137\hline 138\input{err5.tex} 139\hline 140\end{tabular} 141\vspace{0.5cm} 142 143\noindent 144The handlers for these events receive the following arguments: 145 146\noindent 147\begin{tabular}{p{1.2cm}p{8cm}p{4.5cm}} 148\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 149\hline 150130 & Culprit clause & Module \\ 151131 & Culprit clause & Module \\ 152132 & Culprit clause & Module \\ 153133 & Library name (string) & undefined \\ 154134 & Procedure Name/Arity & Module \\ 155135 & Procedure Name/Arity & Module \\ 156136 & Procedure Name/Arity & Module \\ 157137 & Procedure Name/Arity & Module \\ 158138 & Variable name (atom) & undefined \\ 159139 & (File, Size, Time), see below & Module\\ 160140 & 'Emulate' & undefined \\ 161141 & Goal & Module \\ 162142 & Goal & Module \\ 163143 & Goal & Module \\ 164144 & Goal (if an execution error) or Culprit clause (if compiler error) & 165 Module \\ 166145 & (Name/Arity, OldFile, NewFile) & Module \\ 167146 & File & Module \\ 168147 & File\\ 169148 & Clause & Module \\ 170\hline 171\end{tabular} 172 173\newpage 174\noindent 175The second argument for the event 139 depends on the predicate 176where it was raised: 177\begin{itemize} 178\item 179 \biprefni{compile/1,2}{../bips/kernel/compiler/compile-1.html}% 180\indextt{compile/1}\indextt{compile/2} 181 - (file name, code size, compile time) 182\item 183 \bipref{compile_stream/1}{../bips/kernel/compiler/compile_stream-1.html} - 184 ('string', code size, compile time) with a string stream 185\item 186 \bipref{compile_stream/1}{../bips/kernel/compiler/compile_stream-1.html} - 187 (file name, code size, compile time) with a stream associated to a file 188\end{itemize} 189 190\subsection{Top-Level} 191\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 192\hline 193\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 194\hline 195\input{err6.tex} 196\hline 197\end{tabular} 198 199\vspace{0.5cm} 200These events are not errors but rather hooks to allow users to modify 201the behaviour of the {\eclipse} toplevel. 202Therefore the arguments that are passed to the handler are not the 203erroneous goal and the caller module but defined as follows: 204 205\noindent 206\begin{tabular}{p{1.2cm}p{8.5cm}p{4.5cm}} 207\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 208\hline 209150 & A free variable. If the handler binds the variable 210to an atom, this name is used as the toplevel module name 211& undefined \\ 212151 & undefined & undefined \\ 213152 & The argument is the number that {\eclipse} will return to the 214operating system & undefined \\ 215153 & current toplevel module & current toplevel module \\ 216154 & a structure of the form 217\begin{center} 218\notation{goal(\pattern{Goal},% 219~\pattern{VarList},~\pattern{NewGoal},~\pattern{NewVarList})}, 220\end{center} 221where \about{Goal} is the goal that is about to be executed and \about{VarList} 222is the list 223that associates the variables in \about{Goal} with their names 224(like in \bipref{readvar/3}{../bips/kernel/ioterm/readvar-3.html}). 225\about{NewGoal} and \about{NewVarList} are free variables. If the handler binds 226\about{NewVarList} 227then the toplevel will use \about{NewGoal} and \about{NewVarList} to replace 228\about{Goal} and \about{VarList} 229in the current query. 230& current toplevel module \\ 231\hline 232\end{tabular} 233\newpage 234\begin{tabular}{p{1.2cm}p{8cm}p{4.5cm}} 235\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 236\hline 237155 & A list associating the variable names with their values after the 238query has been executed. 239& current toplevel module \\ 240156 & An atom stating the answer to the query that was just executed. 241The possible values are: \notation{yes}, \notation{last_yes} or \notation{no} 242if the query had no variables, 243\notation{more_answers}, \notation{last_answer} if the query contained 244variables and 245bindings were printed, \notation{no_answer} if a query containing variables 246failed. 247& current toplevel module \\ 248157 & undefined & undefined \\ 249158 & break level & current toplevel module \\ 250159 & break level & current toplevel module \\ 251\hline 252\end{tabular} 253\medskip 254 255When the handler for event 152 (``end of eclipse execution'') calls 256\bipref{throw/1}{../bips/kernel/control/throw-1.html}, 257{\eclipse} 258is not exited. This is a way to prevent 259accidental exits from the system. Failure of the handler is ignored. 260 261\subsection{Macro Transformation Errors, Lexical Analyser} 262\begin{tabular}{|p{1.2cm}p{8cm}p{5.4cm}|} 263\hline 264\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 265\hline 266\input{err7.tex} 267\hline 268\end{tabular} 269 270\medskip 271The event 164 is raised whenever the toplevel loop is restarted. 272\medskip 273 274\noindent 275\begin{tabular}{p{1.2cm}p{8cm}p{4.5cm}} 276\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 277\hline 278164 & the banner string \\ 279\hline 280\end{tabular} 281\vspace*{\fill} 282 283\subsection{I/O, Operating System, External Interface} 284\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 285\hline 286\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 287\hline 288\input{err8.tex} 289\hline 290\end{tabular} 291 292\vfill %<<<<<<<<<<<<<<<<<<<<<< 293 294\subsection{Debugging, Object Files} 295\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 296\hline 297\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 298\hline 299\input{err9.tex} 300\hline 301\end{tabular} 302\vspace{0.5cm} 303 304These handlers receive special arguments: 305 306\noindent 307\begin{tabular}{p{1.2cm}p{8cm}p{4.5cm}} 308\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 309\hline 310252 & trace_line\{port:Port,frame:Frame\} & undefined \\ 311264 & (File, [], []) & undefined \\ 312265 & (File, [], []) & undefined \\ 313\hline 314\end{tabular} 315\vspace*{\fill} 316 317\subsection{Extensions} 318\begin{tabular}{|p{1.2cm}p{8cm}p{4.5cm}|} 319\hline 320\heading{Event} & \heading{Event Type} & \heading{Default Event Handler}\\ 321\hline 322\input{err10.tex} 323\hline 324\end{tabular} 325 326\vspace{0.5cm} 327 328The handlers for these events receive the following arguments: 329 330\noindent 331\begin{tabular}{p{1.2cm}p{8cm}p{4.5cm}} 332\heading{Event} & \heading{Second Argument} & \heading{Third Argument}\\ 333\hline 334272 & Culprit clause & Module \\ 335273 & list of sleeping suspensions & undefined \\ 336280 & Cost, Goal & undefined \\ 337\hline 338\end{tabular} 339 340\section{Stack Overflows} 341\index{stack!overflow} 342\index{overflow, stack} 343When a stack overflows, the system performs a 344\bipref{throw/1}{../bips/kernel/control/throw-1.html} 345with an appropriate exit tag, i.e., 346\begin{description} 347\item[global_trail_overflow] for overflows of the global/trail stack 348 that holds all the program's data structures. 349\item[local_control_overflow] for overflows of the local/control stack 350 that holds information related to the control flow. 351\end{description} 352These exits can be caught by wrapping a goal that is likely 353to overflow the stacks into an appropriate 354\bipref{catch/3}{../bips/kernel/control/catch-3.html}, e.g., 355\begin{quote} 356\begin{verbatim} 357..., catch(big_goal(X), global_trail_overflow, react_to_overflow), ... 358\end{verbatim} 359\end{quote} 360In the debugger, you can locate the overflow by jumping to a LEAVE port 361(z command). 362See chapter \ref{chapmemory} for more details on memory usage. 363 364 365\section{{\eclipse} Fatal Errors} 366 367\index{fatal errors}\index{error!fatal} 368A fatal error cannot be caught by the user. 369When they occur, the system performs a warm restart. 370The following fatal errors may be generated by {\eclipse}: 371\begin{description} 372\item[*** Fatal error: Out of memory - no more swap space] 373The available memory (usually swap space) on the computer has been used up 374either by the application or some external process. 375 376\item[*** Fatal error: Internal error - memory corrupted] 377This signals an inconsistency in the system's internal data structures. 378The reason can be either a bug in the {\eclipse} system itself or in an 379external predicate provided by the user. 380 381\end{description} 382 383\section{User-Defined Events} 384User-defined events should use atomic event names rather than numbers. 385See the description of 386\bipref{set_event_handler/2}{../bips/kernel/event/set_event_handler-2.html}. 387 388 389%\section{System Event Handlers} 390%\index{error handlers} 391%In the tables above the default event handlers for all the events are 392%given. Here follows a short description of these handlers. 393%Some of them only print error massages. Those can easily be redefined 394%by the user. 395%Others do more complex things to achieve a certain behaviour of 396%the {\eclipse} system. If those are redefined by the user, this may have 397%unexpected results. 398%Note that the default handler can always be called (even while the active 399%handler is redefined) by using 400%\begin{verbatim} 401% error(default(Number), Goal [, Module]) 402%\end{verbatim} 403%It is therefore not necessary to know the names of the default handlers. 404%Moreover, most of them are not accessible for the user. 405%\begin{description} 406%\item[close_handler/2] 407%\index{close_handler/2} 408%prevents system stream from being closed. 409%If an attempt is made to close a stream that a system stream 410%is redirected to, the system stream is first reset to its standard value. 411% 412%\item[autoload_handler/3] 413%\index{autoload_handler/3} 414%Load the appropriate library and recall the autoloaded goal. 415% 416%\item[compare_handler/3] 417%\index{compare_handler/3} 418%applies arithmetic evaluation to the first two arguments of the goal, 419%then re-calls the culprit goal with the evaluated arguments. 420% 421%\item[compiler_error_handler/2] 422%\index{compiler_error_handler/2} 423%prints error message with relevant line, then fails. 424% 425%\item[compiled_file_handler/2] 426%\index{compiled_file_handler/2} 427%prints the message about compiled or dumped file, 428%possible with size and time indication 429% 430%\item[compiler_abort_handler/2] 431%\index{compiler_abort_handler/2} 432%prints the error message with the file name. 433%If it can find out the line number, it is printed as well. 434% 435%\item[compiler_warning_handler/2] 436%\index{compiler_warning_handler/2} 437%prints error message with relevant line, then succeeds. 438% 439%\item[delayed_goals_handler/3] 440%\index{delayed_goals_handler/3} 441%prints a list of delayed goals and succeeds. 442% 443%\item[dynamic_handler/3] 444%\index{dynamic_handler/3} 445%retracts all clauses of the predicate that is already dynamic and succeeds. 446% 447%\item[eof_handler/2] 448%\index{eof_handler/2} 449%takes the appropriate action for reaching end of file, 450%depending on the culprit goal, e.g., binding the result to {\bf end_of_file} 451%if the goal was \bipref{read/1}{../bips/kernel/ioterm/read-1.html}. 452%The handler fails for unknown goals. 453% 454%\item[error_handler/2] 455%\index{error_handler/2} 456%prints the error message and the culprit. 457%Then it raises the event 157 (error exit) which by default 458%aborts via {\bf throw(abort)}. 459% 460%\item[error_handler/3] 461%\index{error_handler/3} 462%used for errors inside tools. 463%It is like {\bf error_handler/2} but it also prints the module 464%used by the culprit. 465% 466%\item[integer_overflow_handler/2] 467%\index{integer_overflow_handler/2} 468%redo an overflowed word-sized-integer arithmetic operation with bignums. 469% 470%\item[locked_access_handler/2] 471%\index{locked_access_handler/2} 472%allows certain goals to be executed in spite of the module lock. 473% 474%\item[macro_handler/3] 475%\index{macro_handler/3} 476%prints a warning and redefines a macro. 477% 478%\item[make_array_handler/3] 479%\index{make_array_handler/3} 480%If the 481%error number is 42 (redefining an existing array), it prints the warning, 482%erases the existing array and replaces it by a new one. 483%Otherwise, it calls the default handler. 484% 485%\item[message_handler/2] 486%\index{message_handler/2} 487%prints the error message followed by the second argument onto toplevel_output 488%and succeeds. 489%Note that the second argument is not necessarily the culprit goal, 490%but rather just a string to be printed. 491%This handler is used for events which are not errors. 492% 493%\item[output_error_handler/2] 494%\index{output_error_handler/2} 495%closes a related stream if necessary and calls {\bf system_error_handler/2}. 496% 497%\item[parser_error_handler/1] 498%\index{parser_error_handler/1} 499%prints the faulty input line and the corresponding error message, then fails. 500%Used when the culprit is not important and when no abort should occur. 501% 502%\item[past_eof_handler/2] 503%\index{past_eof_handler/2} 504%closes the stream that has been read past end of file, then calls 505%{\bf error_handler/2}. 506% 507%\item[system_error_handler/2] 508%\index{system_error_handler/2} 509%gets the operating system error number (from {\tt errno}) 510%and prints the corresponding 511%error message. 512%Then it raises the event 157 (error exit) which by default 513%aborts via {\bf throw(abort)}. 514% 515%\item[undef_array_handler/3] 516%\index{undef_array_handler/3} 517%If the culprit was 518%\bipref{setval/2}{../bips/kernel/storage/setval-2.html} with an atom as 519%first argument, a local non-logical variable of that name is created using 520%\bipref{variable/1}{../bips/kernel/storage/variable-1.html} and 521%the culprit is re-called. Otherwise like {\bf error_handler/2}. 522% 523%\item[undef_dynamic_handler/3] 524%\index{undef_dynamic_handler/2} 525%when a non-dynamic clause has been asserted, it makes it dynamic 526%(if possible), then asserts it. 527% 528%\item[warning_handler/2] 529%\index{warning_handler/2} 530%prints the error message and the culprit and succeeds. 531% 532%\end{description} 533% 534%\section{System Interrupt Handlers} 535%\index{interrupt handlers} 536%Some of the signals (interrupts) are handled by built-in predicates 537%\bipref{halt/0}{../bips/kernel/opsys/halt-0.html}, \bipref{abort/0}{../bips/kernel/control/abort-0.html} and \bipref{true/0}{../bips/kernel/control/true-0.html}, 538%others have special handlers: 539% 540%\begin{description} 541%\item[interrupt_prolog/0] 542%\index{interrupt_prolog/0} 543%asks the user what to do - abort, start a break level, debug, continue or exit. 544% 545%\item[it_handler/0] 546%\index{it_handler/0} 547%only prints the signal number to the {\tt error} stream. 548% 549%\item[it_overflow/0] 550%\index{it_overflow/0} 551%prints the message "Segmentation violation - maybe machine stack overflow" 552%and makes a warm restart. 553% 554%\item[it_reset/0] 555%\index{it_reset/0} 556%makes a warm restart. 557%\end{description} 558 559%HEVEA\cutend 560