annotate src/debug.h @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents cda4aa780d58
children 7dd7cccf0757
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
1 /*
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
2
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
3 Copyright (C) 2001-2011 Ben Sapp
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
4
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
6
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
10 option) any later version.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
11
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
15 for more details.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
16
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
20
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
21 */
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
22
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_debug_h)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
24 #define octave_debug_h 1
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
25
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
26 #include <map>
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
27 #include <set>
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
28 #include "ov.h"
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
29 #include "dRowVector.h"
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
30
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
31 class octave_value_list;
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7084
diff changeset
32 class octave_user_code;
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
33
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
34 // Interface to breakpoints,.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
35
9237
3c1762c7e787 Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9183
diff changeset
36 class
3c1762c7e787 Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9183
diff changeset
37 OCTINTERP_API
3c1762c7e787 Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9183
diff changeset
38 bp_table
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
39 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
40 private:
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
41
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11523
diff changeset
42 bp_table (void) : bp_set () { }
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
43
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
44 ~bp_table (void) { }
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
45
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
46 public:
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
47
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
48 typedef std::map<int, int> intmap;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
49
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
50 typedef intmap::const_iterator const_intmap_iterator;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
51 typedef intmap::iterator intmap_iterator;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
52
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
53 typedef std::map <std::string, intmap> fname_line_map;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
54
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
55 typedef fname_line_map::const_iterator const_fname_line_map_iterator;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
56 typedef fname_line_map::iterator fname_line_map_iterator;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
57
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
58 static bool instance_ok (void)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
59 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
60 bool retval = true;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
61
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
62 if (! instance)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
63 instance = new bp_table ();
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
64
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
65 if (! instance)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
66 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
67 ::error ("unable to create breakpoint table!");
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
68 retval = false;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
69 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
70
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
71 return retval;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
72 }
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
73
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
74 // Add a breakpoint at the nearest executable line.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
75 static intmap add_breakpoint (const std::string& fname = "",
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
76 const intmap& lines = intmap ())
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
77 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
78 return instance_ok ()
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
79 ? instance->do_add_breakpoint (fname, lines) : intmap ();
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
80 }
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
81
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
82 // Remove a breakpoint from a line in file.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
83 static int remove_breakpoint (const std::string& fname = "",
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
84 const intmap& lines = intmap ())
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
85 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
86 return instance_ok ()
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
87 ? instance->do_remove_breakpoint (fname, lines) : 0;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
88 }
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
89
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
90 // Remove all the breakpoints in a specified file.
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 7719
diff changeset
91 static intmap remove_all_breakpoints_in_file (const std::string& fname,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
92 bool silent = false)
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
93 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
94 return instance_ok ()
8123
eb2beef9a9ff clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents: 7719
diff changeset
95 ? instance->do_remove_all_breakpoints_in_file (fname, silent) : intmap ();
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
96 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
97
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
98 // Remove all the breakpoints registered with octave.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
99 static void remove_all_breakpoints (void)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
100 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
101 if (instance_ok ())
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
102 instance->do_remove_all_breakpoints ();
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
103 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
104
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
105 // Return all breakpoints. Each element of the map is a vector
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
106 // containing the breakpoints corresponding to a given function name.
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
107 static fname_line_map
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
108 get_breakpoint_list (const octave_value_list& fname_list)
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
109 {
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
110 return instance_ok ()
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
111 ? instance->do_get_breakpoint_list (fname_list) : fname_line_map ();
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
112 }
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
113
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
114 static bool
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
115 have_breakpoints (void)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
116 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
117 return instance_ok () ? instance->do_have_breakpoints () : 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
118 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
119
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
120 private:
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
121
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
122 typedef std::set<std::string>::const_iterator const_bp_set_iterator;
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
123 typedef std::set<std::string>::iterator bp_set_iterator;
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
124
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
125 // Set of function names containing at least one breakpoint.
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
126 std::set<std::string> bp_set;
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
127
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
128 static bp_table *instance;
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
129
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
130 intmap do_add_breakpoint (const std::string& fname, const intmap& lines);
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
131
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
132 int do_remove_breakpoint (const std::string&, const intmap& lines);
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
133
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
134 intmap do_remove_all_breakpoints_in_file (const std::string& fname,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135 bool silent);
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
136
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
137 void do_remove_all_breakpoints (void);
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
138
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
139 fname_line_map do_get_breakpoint_list (const octave_value_list& fname_list);
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
140
9183
94ae487acd1b use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents: 8920
diff changeset
141 bool do_have_breakpoints (void) { return (! bp_set.empty ()); }
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
142 };
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
143
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
144 std::string get_file_line (const std::string& fname, size_t line);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8123
diff changeset
145
7084
8ada882c7c69 [project @ 2007-10-31 14:52:08 by jwe]
jwe
parents:
diff changeset
146 #endif