CACAO
breakpoint.hpp
Go to the documentation of this file.
1 /* src/vm/breakpoint.hpp - breakpoint handling header
2 
3  Copyright (C) 2009-2013
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 #include <cassert>
32 //#include <cstdint> <- requires C++0x
33 #include <stdint.h>
34 #include <map>
35 
36 /**
37  * This structure contains information about a breakpoint. Feel
38  * free to extend it to hold all the information you need. It is
39  * the responsibility of the user to set the fields accordingly.
40  */
41 typedef struct Breakpoint {
42  bool is_oneshot; ///< Indicates a "one-shot".
43 
44 #if defined(ENABLE_JVMTI)
45  int32_t location; ///< Used for JVMTI breakpoints.
46  methodinfo* method; ///< Used for JVMTI breakpoints.
47 #endif
48 } Breakpoint;
49 
50 
51 /**
52  * This class is used to record breakpoints in the methodinfo
53  * structure. The term "location" is used to refer to the bytecode
54  * index at which the breakpoint should be placed.
55  */
57 private:
58  std::map<int32_t, Breakpoint> _breakpoints;
59 
60 public:
61  // Querying operations.
62  bool is_empty();
63  bool contains(int32_t location);
64 
65  // Modification operations.
68  void remove_breakpoint(int32_t location);
69 };
70 
71 
73 {
74  return _breakpoints.empty();
75 }
76 
77 inline bool BreakpointTable::contains(int32_t location)
78 {
79  return (_breakpoints.find(location) != _breakpoints.end());
80 }
81 
83 {
84  assert(!contains(location));
85  _breakpoints.insert(std::make_pair(location, Breakpoint()));
86  return &(_breakpoints.find(location)->second);
87 }
88 
90 {
91  assert(contains(location));
92  return &(_breakpoints.find(location)->second);
93 }
94 
96 {
97  assert(contains(location));
98  _breakpoints.erase(location);
99 }
100 
101 #endif /* _BREAKPOINT_HPP */
102 
103 
104 /*
105  * These are local overrides for various environment variables in Emacs.
106  * Please do not remove this and leave it at the end of the file, where
107  * Emacs will automagically detect them.
108  * ---------------------------------------------------------------------
109  * Local variables:
110  * mode: c++
111  * indent-tabs-mode: t
112  * c-basic-offset: 4
113  * tab-width: 4
114  * End:
115  * vim:noexpandtab:sw=4:ts=4:
116  */
Breakpoint * add_breakpoint(int32_t location)
Definition: breakpoint.hpp:82
struct Breakpoint Breakpoint
This structure contains information about a breakpoint.
This structure contains information about a breakpoint.
Definition: breakpoint.hpp:41
Breakpoint * get_breakpoint(int32_t location)
Definition: breakpoint.hpp:89
bool is_oneshot
Indicates a &quot;one-shot&quot;.
Definition: breakpoint.hpp:42
JNIEnv jthread jmethodID method
Definition: jvmti.h:207
void remove_breakpoint(int32_t location)
Definition: breakpoint.hpp:95
bool contains(int32_t location)
Definition: breakpoint.hpp:77
This class is used to record breakpoints in the methodinfo structure.
Definition: breakpoint.hpp:56
std::map< int32_t, Breakpoint > _breakpoints
Definition: breakpoint.hpp:58
JNIEnv jthread jmethodID jlocation location
Definition: jvmti.h:207