101 * enablegc <expr> -- permit garbage collection of an object
102 *
103 * !! -- repeat last command
104 * <n> <command> -- repeat command n times
105 * help (or ?) -- list commands
106 * version -- print version information
107 * exit (or quit) -- exit debugger
108 *
109 * <class id>: full class name with package qualifiers or a
110 * pattern with a leading or trailing wildcard ('*').
111 * <thread id>: thread number as reported in the 'threads' command
112 * <expr>: a Java(tm) Programming Language expression.
113 * Most common syntax is supported.
114 *
115 * Startup commands can be placed in either "jdb.ini" or ".jdbrc"
116 * in user.home or user.dir
117 */
118 public class JdbCommand {
119 final String cmd;
120 boolean allowExit = false;
121
122 public JdbCommand(String cmd) {
123 this.cmd = cmd;
124 }
125
126 public JdbCommand allowExit() {
127 allowExit = true;
128 return this;
129 }
130
131
132 public static JdbCommand run(String ... params) {
133 return new JdbCommand("run " + Arrays.stream(params).collect(Collectors.joining(" ")));
134 }
135 public static JdbCommand cont() {
136 return new JdbCommand("cont");
137 }
138 public static JdbCommand dump(String what) {
139 return new JdbCommand("dump " + what);
140 }
141 public static JdbCommand quit() {
142 // the command suppose jdb terminates
143 return new JdbCommand("quit").allowExit();
144 }
145 public static JdbCommand stopAt(String targetClass, int lineNum) {
146 return new JdbCommand("stop at " + targetClass + ":" + lineNum);
147 }
148 public static JdbCommand stopIn(String targetClass, String methodName) {
149 return new JdbCommand("stop in " + targetClass + "." + methodName);
150 }
151
152 // clear <class id>:<line> -- clear a breakpoint at a line
153 public static JdbCommand clear(String targetClass, int lineNum) {
154 return new JdbCommand("clear " + targetClass + ":" + lineNum);
155 }
156
157 // exception type used by catch/ignore
158 public enum ExType{
159 uncaught,
160 caught,
161 all
162 }
163 public static JdbCommand catch_(String classId) {
164 return new JdbCommand("catch " + classId);
165 }
166 public static JdbCommand catch_(ExType eType, String classId) {
167 return catch_(eType.toString() + " " + classId);
168 }
169 public static JdbCommand ignore(String classId) {
170 return new JdbCommand("ignore " + classId);
171 }
|
101 * enablegc <expr> -- permit garbage collection of an object
102 *
103 * !! -- repeat last command
104 * <n> <command> -- repeat command n times
105 * help (or ?) -- list commands
106 * version -- print version information
107 * exit (or quit) -- exit debugger
108 *
109 * <class id>: full class name with package qualifiers or a
110 * pattern with a leading or trailing wildcard ('*').
111 * <thread id>: thread number as reported in the 'threads' command
112 * <expr>: a Java(tm) Programming Language expression.
113 * Most common syntax is supported.
114 *
115 * Startup commands can be placed in either "jdb.ini" or ".jdbrc"
116 * in user.home or user.dir
117 */
118 public class JdbCommand {
119 final String cmd;
120 boolean allowExit = false;
121 boolean replyIsSimplePrompt = false;
122
123 public JdbCommand(String cmd) {
124 this.cmd = cmd;
125 }
126
127 public JdbCommand allowExit() {
128 allowExit = true;
129 return this;
130 }
131
132 public JdbCommand replyIsSimplePrompt() {
133 replyIsSimplePrompt = true;
134 return this;
135 }
136
137
138 public static JdbCommand run(String ... params) {
139 return new JdbCommand("run " + Arrays.stream(params).collect(Collectors.joining(" ")));
140 }
141 public static JdbCommand cont() {
142 return new JdbCommand("cont");
143 }
144 public static JdbCommand dump(String what) {
145 return new JdbCommand("dump " + what);
146 }
147 public static JdbCommand quit() {
148 // the command suppose jdb terminates
149 return new JdbCommand("quit").allowExit();
150 }
151 public static JdbCommand stopAt(String targetClass, int lineNum) {
152 return new JdbCommand("stop at " + targetClass + ":" + lineNum);
153 }
154 public static JdbCommand stopThreadAt(String targetClass, int lineNum) {
155 return new JdbCommand("stop thread at " + targetClass + ":" + lineNum);
156 }
157 public static JdbCommand stopGoAt(String targetClass, int lineNum) {
158 return new JdbCommand("stop go at " + targetClass + ":" + lineNum);
159 }
160 public static JdbCommand stopIn(String targetClass, String methodName) {
161 return new JdbCommand("stop in " + targetClass + "." + methodName);
162 }
163 public static JdbCommand thread(int threadNumber) {
164 return new JdbCommand("thread " + threadNumber);
165 }
166 // clear <class id>:<line> -- clear a breakpoint at a line
167 public static JdbCommand clear(String targetClass, int lineNum) {
168 return new JdbCommand("clear " + targetClass + ":" + lineNum);
169 }
170
171 // exception type used by catch/ignore
172 public enum ExType{
173 uncaught,
174 caught,
175 all
176 }
177 public static JdbCommand catch_(String classId) {
178 return new JdbCommand("catch " + classId);
179 }
180 public static JdbCommand catch_(ExType eType, String classId) {
181 return catch_(eType.toString() + " " + classId);
182 }
183 public static JdbCommand ignore(String classId) {
184 return new JdbCommand("ignore " + classId);
185 }
|