Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4edaeb908e401b1938b9401684ee046d6c7f045a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*******************************************************************************
 * Copyright (c) 2000, 2004 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;

import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
import org.eclipse.cdt.debug.mi.core.cdi.Condition;
import org.eclipse.cdt.debug.mi.core.cdi.Location;
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;

/**
 */
public class Breakpoint extends CObject implements ICDILocationBreakpoint {

	ICDILocation location;
	ICDICondition condition;
	MIBreakpoint miBreakpoint;
	BreakpointManager mgr;
	int type;
	String tid;
	boolean enable;

	public Breakpoint(BreakpointManager m, int kind, ICDILocation loc, ICDICondition cond, String threadId) {
		super(m.getSession().getCurrentTarget());
		mgr = m;
		type = kind;
		location = loc;
		condition = cond;
		tid = threadId;
		enable = true;
	}

	public Breakpoint(BreakpointManager m, MIBreakpoint miBreak) {
		super(m.getSession().getCurrentTarget());
		miBreakpoint = miBreak;
		mgr = m;
	}

	public MIBreakpoint getMIBreakpoint() {
		return miBreakpoint;
	}

	public void setMIBreakpoint(MIBreakpoint newMIBreakpoint) {
		miBreakpoint = newMIBreakpoint;
		// Force the reset to use GDB's values.
		condition = null;
		location = null;
	}

	public boolean isDeferred() {
		return (miBreakpoint == null);
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getCondition()
	 */
	public ICDICondition getCondition() throws CDIException {
		if (condition == null) {
			if (miBreakpoint != null) {
				condition =  new Condition(miBreakpoint.getIgnoreCount(), miBreakpoint.getCondition());
			}
		}
		return condition;
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getThreadId()
	 */
	public String getThreadId() throws CDIException {
		if (miBreakpoint != null) {
			return miBreakpoint.getThreadId();
		}
		return tid;
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isEnabled()
	 */
	public boolean isEnabled() throws CDIException {
		if (miBreakpoint != null) {
			return miBreakpoint.isEnabled();
		}
		return enable;
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isHardware()
	 */
	public boolean isHardware() {
		if (miBreakpoint != null) {
			return miBreakpoint.isHardware();
		}
		return (type == ICDIBreakpoint.HARDWARE);
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isTemporary()
	 */
	public boolean isTemporary() {
		if (miBreakpoint != null) {
			return miBreakpoint.isTemporary();
		}
		return (type == ICDIBreakpoint.TEMPORARY);
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#setCondition(ICDICondition)
	 */
	public void setCondition(ICDICondition condition) throws CDIException {
		if (isEnabled()) {
			mgr.setCondition(this, condition);
		}
		this.condition = condition;
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#setEnabled(boolean)
	 */
	public void setEnabled(boolean on) throws CDIException {
		if (miBreakpoint != null) {
			if (on == false && isEnabled() == true) { 
				mgr.disableBreakpoint(this);
			} else if (on == true && isEnabled() == false) {
				mgr.enableBreakpoint(this);
			}
		}
		enable = on;
	}

	/**
	 * @see org.eclipse.cdt.debug.core.cdi.ICDILocationBreakpoint#getLocation()
	 */
	public ICDILocation getLocation() throws CDIException {
		if (location == null) {
			if (miBreakpoint != null) {
				location = new Location (miBreakpoint.getFile(),
					miBreakpoint.getFunction(),
					miBreakpoint.getLine(),
					miBreakpoint.getAddress());
			}
		}
		return location;
	}

	public void setLocation(ICDILocation loc) {
		location = loc;
	}
}

Back to the top