File: Debug.cpp.~3830~

package info (click to toggle)
freemat 4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 174,736 kB
  • ctags: 67,053
  • sloc: cpp: 351,060; ansic: 255,892; sh: 40,590; makefile: 4,323; perl: 4,058; asm: 3,313; pascal: 2,718; fortran: 1,722; ada: 1,681; ml: 1,360; cs: 879; csh: 795; python: 430; sed: 162; lisp: 160; awk: 5
file content (149 lines) | stat: -rw-r--r-- 3,685 bytes parent folder | download | duplicates (2)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "Array.hpp"
#include "Interpreter.hpp"

//!
//@Module DBUP Move Up One Debug Level
//@@Section DEBUG
//@@Usage
//The @|dbup| function moves up one level in the debug
//hierarchy.  The syntax for the @|dbup| function is
//@[
// dbup
//@]
//@@Signature
//sfunction dbup DbUpFunction
//inputs none
//outputs none
//!
ArrayVector DbUpFunction(int nargout, const ArrayVector& arg, Interpreter *eval) {
  eval->dbup();
  return ArrayVector();
}

//!
//@Module DBDown Move Down One Debug Level
//@@Section DEBUG
//@@Usage
//The @|dbup| function moves up one level in the debug
//hierarchy.  The syntax for the @|dbup| function is
//@[
// dbup
//@]
//@@Signature
//sfunction dbdown DbDownFunction
//inputs none
//outputs none
//!
ArrayVector DbDownFunction(int nargout, const ArrayVector& arg, Interpreter *eval) {
  eval->dbdown();
  return ArrayVector();
}

//!
//@Module DBDELETE Delete a Breakpoint
//@@Section DEBUG
//@@Usage
//The @|dbdelete| function deletes a breakpoint.  The syntax
//for the @|dbdelete| function is
//@[
//  dbdelete(num)
//@]
//where @|num| is the number of the breakpoint to delete.
//@@Signature
//sfunction dbdelete DbDeleteFunction
//inputs num
//outputs none
//!
ArrayVector DbDeleteFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
  if (arg.size() < 1)
    throw Exception("dbdelete requires an argument (number of breakpoint to delete)");
  eval->deleteBreakpoint(arg[0].asInteger());
  return ArrayVector();
}

//!
//@Module DBLIST List Breakpoints
//@@Section DEBUG
//@@Usage
//List the current set of breakpoints.  The syntax for the
//@|dblist| is simply
//@[
//  dblist
//@]
//@@Signature
//sfunction dblist DbListFunction
//inputs none
//outputs none
//!
ArrayVector DbListFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
  eval->listBreakpoints();
  return ArrayVector();
}

//!
//@Module DBSTEP Step N Statements
//@@Section DEBUG
//@@Usage
//Step @|N| statements during debug mode.  The synax for this is
//either
//@[
//  dbstep(N)
//@]
//to step @|N| statements, or
//@[
//  dbstep
//@]
//to step one statement.
//!

//!
//@Module DBSTOP
//@@Section DEBUG
//@@Usage
//Set a breakpoint.  The syntax for this is:
//@[
//  dbstop(funcname,linenumber)
//@]
//where @|funcname| is the name of the function where we want
//to set the breakpoint, and @|linenumber| is the line number.
//@@Signature
//sfunction dbstop DbStopFunction
//inputs funcname linenumber
//outputs none
//!
ArrayVector DbStopFunction(int nargout, const ArrayVector& arg, Interpreter* eval) {
  if (arg.size() < 2)
    throw Exception("dbstop function requires at least two arguments");
  if (!(arg[0].isString()))
    throw Exception("first argument to dbstop must be the name of routine where to stop");
  eval->addBreakpoint(arg[0].asString(),arg[1].asInteger());
  return ArrayVector();
}

//!
//@Module FDUMP Dump Information on Function
//@@Section DEBUG
//@@Usage
//Dumps information about a function (diagnostic information only)
//@[
//   fdump fname
//@]
//@@Signature
//sfunction fdump FdumpFunction
//inputs fname
//outputs none
//!
ArrayVector FdumpFunction(int nargout, const ArrayVector& arg,Interpreter* eval){
  if (arg.size() == 0)
    throw Exception("fdump function requires at least one argument");
  if (!(arg[0].isString()))
    throw Exception("first argument to fdump must be the name of a function (i.e., a string)");
  QString fname = arg[0].asString();
  Context *context = eval->getContext();
  FuncPtr funcDef;
  if (!context->lookupFunction(fname,funcDef))
    throw Exception(QString("function ") + fname + " undefined!");
  funcDef->updateCode(eval);
  funcDef->printMe(eval);
  return ArrayVector();
}