Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f90509fd80f78f4748c3394c7543ea7d7d32dac5 (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
/*******************************************************************************
 * Copyright (c) 2004, 2012 QNX Software Systems and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * QNX Software Systems - Initial API and implementation
 * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
 *******************************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints;

import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.Map;

import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;

/**
 * A watchpoint specific to the C/C++ debug model.
 */
public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 {

	/**
	 * Constructor for CWatchpoint.
	 */
	public CWatchpoint() {
	}

	/**
	 * Constructor for CWatchpoint.
	 */
	public CWatchpoint(IResource resource, Map<String, Object> attributes, boolean add) throws CoreException {
		super(resource, attributes, add);
	}

	@Override
	public String getMarkerType() {
		return C_WATCHPOINT_MARKER;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isWriteType()
	 */
	@Override
	public boolean isWriteType() throws CoreException {
		return ensureMarker().getAttribute(WRITE, true);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isReadType()
	 */
	@Override
	public boolean isReadType() throws CoreException {
		return ensureMarker().getAttribute(READ, false);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.ICWatchpoint#getExpression()
	 */
	@Override
	public String getExpression() throws CoreException {
		return ensureMarker().getAttribute(EXPRESSION, ""); //$NON-NLS-1$
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
	 */
	@Override
	protected String getMarkerMessage() throws CoreException {
		String format = BreakpointMessages.getString("CWatchpoint.3"); //$NON-NLS-1$
		if (isWriteType() && !isReadType())
			format = BreakpointMessages.getString("CWatchpoint.0"); //$NON-NLS-1$
		else if (!isWriteType() && isReadType())
			format = BreakpointMessages.getString("CWatchpoint.1"); //$NON-NLS-1$
		else if (isWriteType() && isReadType())
			format = BreakpointMessages.getString("CWatchpoint.2"); //$NON-NLS-1$
		return MessageFormat.format(format, CDebugUtils.getBreakpointText(this, false));
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
	 */
	@Override
	public int getLineNumber() throws CoreException {
		return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
	 */
	@Override
	public int getCharStart() throws CoreException {
		return ensureMarker().getAttribute(IMarker.CHAR_START, -1);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
	 */
	@Override
	public int getCharEnd() throws CoreException {
		return ensureMarker().getAttribute(IMarker.CHAR_END, -1);
	}

	@Override
	public String getMemorySpace() throws CoreException {
		return ensureMarker().getAttribute(MEMORYSPACE, ""); //$NON-NLS-1$
	}

	@Override
	public BigInteger getRange() throws CoreException {
		String attr = ensureMarker().getAttribute(RANGE, "0"); //$NON-NLS-1$
		return new BigInteger(attr.length() > 0 ? attr : "0"); //$NON-NLS-1$
	}

}

Back to the top