annotate liboctave/util/quit.cc @ 27480:63b417917f5e

remove some obsolete signal handling functions * quit.h, quit.cc (octave_exception): Delete enum declaration. (octave_exception_state, octave_exit_exception_status, octave_exit_exception_safe_to_return): Delete variables and all uses. (octave_throw_interrupt_exception, octave_throw_execution_exception, octave_throw_bad_alloc, octave_throw_exit_exception, octave_rethrow_exception): Delete functions and all uses. * cquit.c: Delete * liboctave/util/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Sun, 06 Oct 2019 16:30:35 -0400
parents fd32c1a9b1bd
children 7a871724d4b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
1 /*
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
3 Copyright (C) 2002-2019 John W. Eaton
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
4
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
16
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
19 <https://www.gnu.org/licenses/>.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
20
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
21 */
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
25 #endif
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
26
4154
f10865750046 [project @ 2002-11-07 15:31:42 by jwe]
jwe
parents: 4153
diff changeset
27 #include <cstring>
f10865750046 [project @ 2002-11-07 15:31:42 by jwe]
jwe
parents: 4153
diff changeset
28
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
29 #include <ostream>
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
30 #include <sstream>
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
31 #include <new>
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
32
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
33 #include "quit.h"
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
34
27480
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
35 sig_atomic_t octave_interrupt_state = 0;
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
36
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
37 volatile sig_atomic_t octave_signal_caught = 0;
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
38
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23426
diff changeset
39 void (*octave_signal_hook) (void) = nullptr;
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23426
diff changeset
40 void (*octave_interrupt_hook) (void) = nullptr;
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
41
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
42 namespace octave
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
43 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
44 std::string execution_exception::stack_trace (void) const
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
45 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
46 size_t nframes = m_stack_info.size ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
47
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
48 if (nframes == 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
49 return std::string ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
50
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
51 std::ostringstream buf;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
52
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
53 buf << "error: called from\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
54
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
55 for (const auto& frm : m_stack_info)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
56 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
57 buf << " " << frm.fcn_name ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
58
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
59 int line = frm.line ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
60
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
61 if (line > 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
62 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
63 buf << " at line " << line;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
64
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
65 int column = frm.column ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
66
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
67 if (column > 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
68 buf << " column " << column;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
69 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
70
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
71 buf << "\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
72 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
73
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
74 return buf.str ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
75 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
76
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
77 void execution_exception::display (std::ostream& os) const
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
78 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
79 if (! m_message.empty ())
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
80 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
81 os << m_err_type << ": " << m_message;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
82
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
83 if (m_message.back () != '\n')
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
84 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
85 os << "\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
86
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
87 std::string st = stack_trace ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
88
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
89 if (! st.empty ())
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
90 os << st;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
91 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
92 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
93 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
94 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
95
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
96 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
97 octave_handle_signal (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
98 {
27480
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
99 octave_signal_caught = 0;
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
100
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
101 if (octave_signal_hook)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
102 octave_signal_hook ();
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
103
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
104 if (octave_interrupt_state > 0)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
105 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
106 octave_interrupt_state = -1;
27480
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
107
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
108 if (octave_interrupt_hook)
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
109 octave_interrupt_hook ();
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
110
63b417917f5e remove some obsolete signal handling functions
John W. Eaton <jwe@octave.org>
parents: 27471
diff changeset
111 throw octave::interrupt_exception ();
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
112 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
113 }