Removed return value from descriptor_params_from_paramtypes.
[cacao.git] / src / vm / breakpoint.hpp
1 /* src/vm/breakpoint.hpp - breakpoint handling header
2
3    Copyright (C) 2009
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23  */
24
25
26 #ifndef _BREAKPOINT_HPP
27 #define _BREAKPOINT_HPP
28
29 #include "config.h"
30
31 #ifdef __cplusplus
32 #include <map>
33
34
35 /**
36  * This structure contains information about a breakpoint. Feel
37  * free to extend it to hold all the information you need. It is
38  * the responsibility of the user to set the fields accordingly.
39  */
40 typedef struct Breakpoint {
41         bool        is_oneshot;             ///< Indicates a "one-shot".
42
43 #if defined(ENABLE_JVMTI)
44         int32_t     location;               ///< Used for JVMTI breakpoints.
45         methodinfo* method;                 ///< Used for JVMTI breakpoints.
46 #endif
47 } Breakpoint;
48
49
50 /**
51  * This class is used to record breakpoints in the methodinfo
52  * structure. The term "location" is used to refer to the bytecode
53  * index at which the breakpoint should be placed.
54  */
55 class BreakpointTable {
56 private:
57         std::map<int32_t, Breakpoint> _breakpoints;
58
59 public:
60         // Querying operations.
61         bool is_empty();
62         bool contains(int32_t location);
63
64         // Modification operations.
65         Breakpoint* add_breakpoint   (int32_t location);
66         Breakpoint* get_breakpoint   (int32_t location);
67         void        remove_breakpoint(int32_t location);
68 };
69
70
71 inline bool BreakpointTable::is_empty()
72 {
73         return _breakpoints.empty();
74 }
75
76 inline bool BreakpointTable::contains(int32_t location)
77 {
78         return (_breakpoints.find(location) != _breakpoints.end());
79 }
80
81 inline Breakpoint* BreakpointTable::add_breakpoint(int32_t location)
82 {
83         assert(!contains(location));
84         _breakpoints.insert(std::make_pair(location, Breakpoint()));
85         return &(_breakpoints.find(location)->second);
86 }
87
88 inline Breakpoint* BreakpointTable::get_breakpoint(int32_t location)
89 {
90         assert(contains(location));
91         return &(_breakpoints.find(location)->second);
92 }
93
94 inline void BreakpointTable::remove_breakpoint(int32_t location)
95 {
96         assert(contains(location));
97         _breakpoints.erase(location);
98 }
99
100
101 #else // __cplusplus
102 typedef struct BreakpointTable BreakpointTable;
103 #endif // __cplusplus
104
105 #endif /* _BREAKPOINT_HPP */
106
107
108 /*
109  * These are local overrides for various environment variables in Emacs.
110  * Please do not remove this and leave it at the end of the file, where
111  * Emacs will automagically detect them.
112  * ---------------------------------------------------------------------
113  * Local variables:
114  * mode: c++
115  * indent-tabs-mode: t
116  * c-basic-offset: 4
117  * tab-width: 4
118  * End:
119  * vim:noexpandtab:sw=4:ts=4:
120  */