Initial Commit
[packages] / xemacs-packages / jde / java / src / jde / debugger / command / TraceExceptions.java
1 package jde.debugger.command;
2 import jde.debugger.Etc;
3 import jde.debugger.JDEException;
4 import jde.debugger.spec.EventRequestSpec;
5 import jde.debugger.spec.EventRequestSpecList;
6
7
8
9 /**
10  * 'trace_exceptions' command.
11  * <p>
12  *
13  * <b>Syntax:</b>
14  * <pre>
15  * trace_exceptions classPattern <u>type</u>
16  *      [{@link Etc#getThreadFromArgs(List) thread-restriction}]
17  *      [{@link Etc#getSuspendPolicyFromArgs(List) suspend-policy}]
18  *      [{@link Etc#getClassFiltersFromArgs(List) class-filters}]
19  *      [{@link Etc#getClassExFiltersFromArgs(List) class-exclusion-filters}]
20  * </pre>
21  *
22  * <b>Returns:</b>
23  * <pre>
24  * (jde-dbo-command-result cmd_id specID)
25  * </pre>
26  *
27  * <b>Comments:</b>
28  * <ul>
29  * <li> <u>type</u> can be "caught", "uncaught", or "both"
30  * <li> specID is a 'long', and can be used in the 'clear'
31  * command
32  * </ul>
33  *
34  * <p>
35  *
36  * @author Paul Kinnucan
37  * @version $Revision: 1.2 $
38  *
39  * Copyright (c) 2000, 2001, 2003    Paul Kinnucan
40  *
41  */
42 public class TraceExceptions extends DebugProcessCommand {
43   
44   /**
45    *
46    * @exception jde.debugger.JDEException <description>
47    */
48   public void doCommand() throws JDEException {
49     if (m_args.size() < 2) 
50       throw new JDEException("Insufficient arguments");
51         
52     String classPattern = m_args.remove(0).toString();
53     String type         = m_args.remove(0).toString().toLowerCase();
54         
55     boolean caught   = false;
56     boolean uncaught = false;
57
58     if (type.equals("both")) {
59       caught   = true;
60       uncaught = true;
61     } else if (type.equals("caught")) {
62       caught   = true;
63     } else if (type.equals("uncaught")) {
64       uncaught = true;
65     } else {
66       throw new JDEException("'"+type+"' not understood");
67     }
68         
69     EventRequestSpecList eventRequests = m_debugger.getEventRequestSpecList();
70     EventRequestSpec     er            = eventRequests.createExceptionIntercept(classPattern, caught, uncaught);
71
72     er.setThread(Etc.getThreadFromArgs(m_args));
73     er.setSuspendPolicy(Etc.getSuspendPolicyFromArgs(m_args));
74     er.setClassFilters(Etc.getClassFiltersFromArgs(m_args));
75     er.setClassExFilters(Etc.getClassExFiltersFromArgs(m_args));
76     eventRequests.install(er);
77         
78     m_debugger.signalCommandResult(m_cmdID, er.getID().toString(), CMD_OK, NOQUOTE);
79   }
80     
81   public Object clone() {return new TraceExceptions();}
82     
83 } // TraceExceptions
84
85 /*
86  * $Log: TraceExceptions.java,v $
87  * Revision 1.2  2003/01/15 05:56:26  paulk
88  * Add Petter Mahlen's changes.
89  *
90  * Revision 1.1  2001/03/24 13:35:25  paulk
91  * Initial revision.
92  *
93  *
94  */
95
96 // End of TraceExceptions.java