Qore DebugCmdLine Module Reference  0.1
DebugCmdLine.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* DebugCmdLine.qm Copyright 2013 - 2017 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // minimum required Qore version
26 
27 
28 
41 namespace DebugCmdLine {
43 
60 class WrapperGetOpt : public GetOpt {
61 
62 public:
64  constructor(hash options) ;
65 
66 
68 
100  split(list<string> args, reference<list<string>> wrp_args, reference<*string> pgm_name, reference<list<string>> pgm_args);
101  };
102 
104  class DebugLogger {
105 
106 public:
107  public :
108  int verbose = DUV_NONE;
109 
110 public:
111  constructor() {}
112 
114 
117  log(int verbosity, string fmt);
118  };
119 
121 class DebugCommandLine : public AbstractDebugControl {
122 
123 public:
124  public :
125  string ln_prompt = 'qdbg> ';
126  hash cx;
127 
128 public:
129 
130  private :
131  Qore::Thread::RWLock rwlContext();
132 
133  hash commands = (
134  '>': (
135  'help': (
136  '**': (
137  'desc': 'help/*',
138  'enum';
139 ,
140  'action';
141 ,
142  ),
143  'desc': 'get help about command',
144  'action';
145 ,
146  ),
147  'version': (
148  'desc': 'get version info',
149  'action';
150 ,
151  ),
152  'history': (
153  '>': (
154  'load': (
155  'desc': 'load history from file',
156  'action';
157 ,
158  ),
159  'save': (
160  'desc': 'save history to file',
161  'action';
162 ,
163  ),
164 
165  ),
166  'desc': 'load or save history to file',
167  ),
168  'quit': (
169  'desc': 'quit debugger',
170  'action';
171 ,
172  ),
173 
174  'session': (
175  'desc': 'get list of debugged programs and stopped threads',
176  'action';
177 ,
178  ),
179  'pgm': (
180  '>': (
181  'load': (
182  'desc': 'load and run script, filename [args..]',
183  'action';
184 ,
185  ),
186  'search': (
187  'desc': 'regex search for a program',
188  'action';
189 ,
190  ),
191  'list': (
192  '>': (
193  'full': (
194  'desc': 'verbose program listing',
195  'action';
196 ,
197  ),
198  ),
199  'desc': 'list programs, [full] for a verbose listing',
200  'action';
201 ,
202  ),
203  'set': (
204  '*': (
205  'desc': 'set current program, arg: programId',
206  'enum';
207 ,
208  'action';
209 ,
210  ),
211  ),
212  'current': (
213  'desc': 'get current program',
214  'action';
215 ,
216  ),
217  'add': (
218  'desc': 'add current program for debugging',
219  'action';
220 ,
221  ),
222  'remove': (
223  'desc': 'remove current program from debugging',
224  'action';
225 ,
226  ),
227  'stop': (
228  'desc': 'stop current program, args: [threadId] to stop particular thread',
229  'action';
230 ,
231  ),
232  'global': (
233  '*': (
234  'desc': 'get/set global variable',
235  'enum';
236 ,
237  'action';
238 ,
239  ),
240  'desc': 'get/set global variable',
241  ),
242  'define': (
243  '*': (
244  'desc': 'get defines',
245  'enum';
246 ,
247  'action';
248 ,
249  ),
250  'action';
251 ,
252  'desc': 'get defines',
253  ),
254  'options': (
255  'desc': 'list parse options',
256  'action';
257 ,
258  ),
259  'info': (
260  'desc': 'get info about current program and list threads',
261  'action';
262 ,
263  ),
264  ),
265  'desc': 'program related commands',
266  ),
267  'break': (
268  '>': (
269  'list': (
270  'desc': 'list breakpoints',
271  'action';
272 ,
273  ),
274  'create': (
275  'desc': 'create breakpoint',
276  'action';
277 ,
278  ),
279  'delete': (
280  '*': (
281  'desc': 'delete breakpoint',
282  'enum';
283 ,
284  'action';
285 ,
286  ),
287  'desc': 'get breakpoint',
288  ),
289  'enable': (
290  '*': (
291  'desc': 'enable breakpoint',
292  'enum';
293 ,
294  'action';
295 ,
296  ),
297  'desc': 'enable breakpoint',
298  ),
299  'disable': (
300  '*': (
301  'desc': 'disable breakpoint',
302  'enum';
303 ,
304  'action';
305 ,
306  ),
307  'desc': 'disable breakpoint',
308  ),
309  'policy': (
310  '*': (
311  'desc': 'get breakpoint policy',
312  'enum';
313 ,
314  '*': (
315  'desc': 'set breakpoint policy',
316  'enum';
317 ,
318  'action';
319 ,
320  ),
321  'action';
322 ,
323  ),
324  'desc': 'breakpoint policy',
325  ),
326  'thread': (
327  '*': (
328  'desc': 'get/set threads assigned to breakpoint, args: "+"/"-" threadId | threadId ..',
329  'enum';
330 ,
331  'action';
332 ,
333  ),
334  'desc': 'get thread handled by breakpoint',
335  'action';
336 ,
337  ),
338  'statement': (
339  '*': (
340  'desc': 'get statement list assigned to breakpoint',
341  'enum';
342 ,
343  'action';
344 ,
345  ),
346  'desc': 'statement stuff',
347  ),
348  ),
349  'desc': 'breakpoint related commands',
350  ),
351  'statement': (
352  '>': (
353  'list': (
354  'desc': 'list statements', // duplicate to breakpoint/statement
355  'action';
356 ,
357  ),
358  'assign': (
359  '*': (
360  'desc': 'assign statement to breakpoint, args: breakpoint [function([args, ...]] | [file] lineno',
361  'enum';
362 ,
363  'action';
364 ,
365  ),
366  'desc': 'assign statement to breakpoint, args: breakpoint [function([args, ...]] | [file] lineno',
367  ),
368  'unassign': (
369  '*': (
370  'desc': 'unassign statement from breakpoint, args: breakpoint [function([args, ...]] | [file] lineno',
371  'enum';
372 ,
373  'action';
374 ,
375  ),
376  'desc': 'unassign statement from breakpoint, args: breakpoint [function([args, ...]] | [file] lineno',
377  ),
378  ),
379  'desc': 'statement related commands',
380  ),
381 
382  'thread': (
383  '>': (
384  'set': (
385  '*': (
386  'desc': 'set current thread, arg: threadId',
387  'enum';
388 ,
389  'action';
390 ,
391  ),
392  ),
393  'current': (
394  'desc': 'get current thread',
395  'action';
396 ,
397  ),
398  'local': (
399  '*': (
400  'desc': 'get/set local variable',
401  'enum';
402 ,
403  'action';
404 ,
405  ),
406  'desc': 'get/set global variable',
407  ),
408  'debug': (
409  '*': (
410  'desc': 'get/set special debug variable',
411  'enum';
412 ,
413  'action';
414 ,
415  ),
416  'desc': 'get/set special debug variable',
417  ),
418  ),
419  'desc': 'thread related commands',
420  ),
421  'bt': (
422  'desc': 'get stack for current thread',
423  'action';
424 ,
425  ),
426  'go': (
427  '*': (
428  'desc': 'go thread with specified runstate, arg: runstate',
429  'enum';
430 ,
431  'action';
432 ,
433  ),
434  'desc': 'go thread with default runstate',
435  'action';
436 ,
437  ),
438  ),
439  );
440 
441 public:
442 
443  constructor();
444 
445 
447  abstract *hash doCommandImpl(hash data);
448  doCommand(hash data);
449 
450  static showPrograms(hash ph);
451 
452  auto parseValue(softlist args);
453 
454  auto getContextValue(string key);
455 
456  setContextValue(string key, auto value);
457 
458  hash getStatementValue(list args);
459 
460 
461 private:
462  list splitCmd(string line);
463 public:
464 
465 
466  *hash findCmd(list args, bool findHelp = False, *reference<int> last_param) { /* because it is needed from closure */ hash result;
467  result.path = ();
468  hash c = commands;
469  last_param = 0;
470  while (args.size() > 0);
471 
472  result.args = args;
473  return result;
474  }
475 
476 
477 private:
478  list ln_callback(string line);
479 public:
480 
481 
482  runCmdLine();
483 
484  printData(auto data);
485 
486  int checkProgramId();
487 
488  int checkThreadId();
489 
490  static softlist enumBreakpointId(DebugCommandLine dcl, softlist path, softlist args);
491  };
492 };
split(list< string > args, reference< list< string >> wrp_args, reference< *string > pgm_name, reference< list< string >> pgm_args)
Parses input arguments until a standalone argument is found.
Definition: DebugCmdLine.qm.dox.h:60
debug command line class
Definition: DebugCmdLine.qm.dox.h:121
class that can be used for logging
Definition: DebugCmdLine.qm.dox.h:104
const False
the DebugCmdLine namespace contains all the definitions in the DebugCmdLine module ...
Definition: DebugCmdLine.qm.dox.h:42
list list(...)
constructor(hash options)
create the object with the given GetOpt option hash
hash hash(object obj)