Package: Stoppoint

Stoppoint

nameinstructionbranchcomplexitylinemethod
Stoppoint(ILexLocation, int, String)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
check(ILexLocation, Context)
M: 96 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 25 C: 0
0%
M: 1 C: 0
0%
toString()
M: 38 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (C) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.interpreter.runtime;
25:
26: import org.overture.ast.intf.lex.ILexLocation;
27: import org.overture.interpreter.debug.BreakpointManager;
28: import org.overture.parser.lex.LexException;
29: import org.overture.parser.syntax.ParserException;
30:
31: /**
32: * A breakpoint where execution must stop.
33: */
34:
35: public class Stoppoint extends Breakpoint
36: {
37:         private static final long serialVersionUID = 1L;
38:
39:         public Stoppoint(ILexLocation location, int number, String trace)
40:                         throws ParserException, LexException
41:         {
42:                 super(location, number, trace);
43:         }
44:
45:         @Override
46:         public void check(ILexLocation execl, Context ctxt)
47:         {
48:                 // skips if breakpoint is disabled
49:•                if (!enabled)
50:                 {
51:                         return;
52:                 }
53:
54:                 location.hit();
55:                 hits++;
56:
57:                 try
58:                 {
59:•                        boolean shouldBreak = parsed == null;
60:
61:•                        if (!shouldBreak)
62:                         {
63:                                 try
64:                                 {
65:                                         // Clear thread state while evaluating the expression and set
66:                                         // the state back after. Done to prevent the debugger from stopping
67:                                         // in the expression
68:                                         Context outctxt = ctxt.threadState.outctxt;
69:                                         RootContext rootContext = ctxt.threadState.nextctxt;
70:                                         ILexLocation stepline = ctxt.threadState.stepline;
71:                                         ctxt.threadState.init();
72:                                         ctxt.threadState.setAtomic(true);
73:                                         shouldBreak = BreakpointManager.shouldStop(parsed, ctxt);
74:                                         ctxt.threadState.setBreaks(stepline, rootContext, outctxt);
75:                                         
76:                                 } catch (Exception e)
77:                                 {
78:                                         String message = e.getMessage();
79:                                         
80:•                                        if(message == null)
81:                                         {
82:                                                 message = "breakpoint condition could not be evaluated";
83:                                         }
84:                                         
85:                                         println("Breakpoint [" + number + "]: " + message
86:                                                         + " \"" + trace + "\"");
87:                                 }
88:                                 finally
89:                                 {
90:                                         ctxt.threadState.setAtomic(false);
91:                                 }
92:                         }
93:
94:•                        if (shouldBreak)
95:                         {
96:                                 enterDebugger(ctxt);
97:                         }
98:                 }
99:                 catch (DebuggerException e)
100:                 {
101:                         throw e;
102:                 }
103:         }
104:
105:         @Override
106:         public String toString()
107:         {
108:•                if (number == 0)
109:                 {
110:                         return super.toString();
111:                 } else
112:                 {
113:•                        return "break [" + number + "] "
114:                                         + (trace == null ? "" : "when \"" + trace + "\" ")
115:                                         + super.toString();
116:                 }
117:         }
118: }