1 package jde.debugger.command;
3 import jde.debugger.Etc;
4 import jde.debugger.JDEException;
5 import jde.debugger.spec.EventRequestSpecList;
6 import jde.debugger.spec.WatchpointSpec;
15 * watch classPattern fieldName <u>type</u>
16 * [{@link Etc#getThreadFromArgs(List) thread-restriction}]
17 * [{@link Etc#getExprFromArgs(List) expression-restriction}]
18 * [{@link Etc#getObjectIDFromArgs(List) object-id-restriction}]
19 * [{@link Etc#getSuspendPolicyFromArgs(List) suspend-policy}]
20 * [{@link Etc#getClassFiltersFromArgs(List) class-filters}]
21 * [{@link Etc#getClassExFiltersFromArgs(List) class-exclusion-filters}]
26 * (jde-dbo-command-result cmd_id specID)
31 * <li> <u>type</u> can be "for_access" or "for_modification"
32 * <li> 'classPattern' can be a string pattern of the type *.Test
33 * <li> objectID is used when, for example, when you already know the
34 * object id of the object, the access/modification of which's field
35 * you're interested in.
36 * <li> specID is a 'long', that can be used in 'clear' commands.
40 * @see jde.debugger.EventHandler#watchpointEvent(WatchpointEvent)
42 * @author Paul Kinnucan
43 * @version $Revision: 1.2 $
45 * Copyright (c) 2000, 2001, 2003 Paul Kinnucan
48 public class Watch extends DebugProcessCommand {
52 * @exception jde.debugger.JDEException <description>
54 public void doCommand() throws JDEException {
56 if (m_args.size() < 3)
57 throw new JDEException("Insufficient arguments");
59 String classPattern = m_args.remove(0).toString();
60 String methodName = m_args.remove(0).toString();
61 String typeString = m_args.remove(0).toString().toLowerCase();
63 EventRequestSpecList eventRequests = m_debugger.getEventRequestSpecList();
65 WatchpointSpec er = null;
66 if (typeString.equals("for_access")) {
67 if (!m_debugger.getVM().canWatchFieldAccess())
68 throw new JDEException("This VM implementation cannot watch field accesses");
69 er = eventRequests.createAccessWatchpoint(classPattern, methodName);
70 } else if (typeString.equals("for_modification")) {
71 if (!m_debugger.getVM().canWatchFieldModification())
72 throw new JDEException("This VM implementation cannot watch field modifications");
73 er = eventRequests.createModificationWatchpoint(classPattern, methodName);
75 throw new JDEException("'"+typeString+"' not understood: use either 'for_access' or 'for_modification'");
77 er.setThread(Etc.getThreadFromArgs(m_args));
78 er.setExpression(Etc.getExprFromArgs(m_args));
79 er.setObjectID(Etc.getObjectIDFromArgs(m_args));
80 er.setSuspendPolicy(Etc.getSuspendPolicyFromArgs(m_args));
81 er.setClassFilters(Etc.getClassFiltersFromArgs(m_args));
82 er.setClassExFilters(Etc.getClassExFiltersFromArgs(m_args));
83 eventRequests.install(er);
85 m_debugger.signalCommandResult(m_cmdID, er.getID().toString(), CMD_OK, NOQUOTE);
88 public Object clone() {return new Watch();}
93 * $Log: Watch.java,v $
94 * Revision 1.2 2003/01/15 05:56:25 paulk
95 * Add Petter Mahlen's changes.
97 * Revision 1.1 2001/03/24 13:35:26 paulk