This file is indexed.

/usr/share/yacas/scripts/debug.rep/code.ys is in yacas 1.3.6-2+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
LocalSymbols(TraceStart,TraceEnter,TraceLeave,DebugStart,DebugEnter, 
             DebugLeave,ProfileStart,ProfileEnter,result,
             WriteLines,ClearScreenString,Debug'FileLoaded, Debug'FileLines, Debug'NrLines,
             debugstepoverfile, debugstepoverline) [

TraceStart() := [indent := 0;];
TraceEnter() :=
[
    indent++;
    Space(2*indent);
    Echo("Enter ",CustomEval'Expression());
];
TraceLeave() :=
[
    Space(2*indent);
    Echo("Leave ",CustomEval'Result());
    indent--;
];
Macro(TraceExp,{expression})
[
    TraceStart();
    CustomEval(TraceEnter(),TraceLeave(),CustomEval'Stop(),@expression);
];



DebugStart():=
[
   debugging:=True;
   debugstopdepth := -1;
   breakpoints:={};
   filebreakpoints := {};
   debugstopped:=False;
   debugverbose:=False;
   debugcallstack:={};
   breakpredicate:=False;
];
DebugRun():= [debugging:=False;True;];
DebugStep():=[debugging:=False;nextdebugging:=True;];

DebugStepOver():=
[
  debugging:=False;
  debugstepoverfile := DebugFile(CustomEval'Expression());
  debugstepoverline := DebugLine(CustomEval'Expression());
  debugstopdepth := Length(debugcallstack);
];
DebugBreakAt(file,line):=
[
  Check(InDebugMode(),"DebugBreakAt only supported in the debug build of Yacas");
  If(filebreakpoints[file] = Empty,filebreakpoints[file]:={});
  DestructiveAppend(filebreakpoints[file],line);
];
DebugRemoveBreakAt(file,line):=
[
  Check(InDebugMode(),"DebugRemoveBreakAt only supported in the debug build of Yacas");
  If(filebreakpoints[file] = Empty,filebreakpoints[file]:={});
  filebreakpoints[file] := Difference(filebreakpoints[file],{line});
];


DebugStop():=[debugging:=False;debugstopped:=True;CustomEval'Stop();];
DebugVerbose(verbose):=[debugverbose:=verbose;];
DebugAddBreakpoint(fname_IsString) <-- [ breakpoints := fname:breakpoints;];
Macro(DebugBreakIf,{predicate})
[
  breakpredicate:= Hold(@predicate);
];

BreakpointsClear() <--
[
  breakpredicate:=False;
  breakpoints := {};
];
Macro(DebugLocals,{})
[
  Echo("");
  Echo("*************** Current locals on the stack ****************");
  ForEach(item,CustomEval'Locals())
  [
    Echo("      ",item," : ",Eval(item));
  ];
  Echo("");
];
DebugCallstack() <--
[
  Echo("");
  Echo("*************** Function call stack ****************");
  ForEach(item,debugcallstack)
  [
    if(IsFunction(item))
      Echo("      Function ",Type(item)," : ",item)
    else
      Echo("      Variable ",item);
  ];
  Echo("");
];

Macro(DebugEnter,{})
[
  debugcallstack := CustomEval'Expression():debugcallstack;
  // custom breakpoint (custom predicate thought up by the programmer)
  If(debugging = False And
      Eval(breakpredicate) = True,
      [
        breakpredicate:=False;
        debugging:=True;
      ]);

  If(debugging = False And InDebugMode(),
  [  
    Local(file,line);
    file := DebugFile(CustomEval'Expression());
    If(filebreakpoints[file] != Empty,
    [
      line := DebugLine(CustomEval'Expression());
      If(Not(file = debugstepoverfile And line = debugstepoverline) And
         Contains(filebreakpoints[file],line),
         [
           debugging:=True;
         ]
        );
    ]);
  ]);


  // the standard breakpoint
  If(debugging = False And
      IsFunction(CustomEval'Expression()) And
      Contains(breakpoints,Type(CustomEval'Expression())),   debugging:=True);
   nextdebugging:=False;
   If (debugging,
   [
     If(InDebugMode(),DebugShowCode());
     Echo(">>> ",CustomEval'Expression());
     While(debugging)
     [
        Echo("DebugOut> ",Eval(FromString(ReadCmdLineString("Debug> "):";")Read()));
    //      If(debugging,Echo("DebugOut> ",debugRes));
       If(IsExitRequested(),debugging:=False);
     ];
    ]);
   debugging:=nextdebugging;

   If(IsExitRequested(),debugstopped:=True);

];
Macro(DebugLeave,{})
[
  If(debugging = False And debugstopdepth >= 0 And Length(debugcallstack) = debugstopdepth,
  [
    debugstepoverline := -1;
    debugging := True;
    debugstopdepth := -1;
  ]);

  debugcallstack := Tail(debugcallstack);
  If(debugverbose,Echo(CustomEval'Result()," <-- ",CustomEval'Expression()));
];
Macro(Debug,{expression})
ToStdout()
[
   DebugStart();
   CustomEval(DebugEnter(),DebugLeave(),If(debugstopped,Check(False,""),[debugging:=True;debugcallstack := Tail(debugcallstack);]),@expression);
];


ProfileStart():=
[
    profilefn:={};
];
10 # ProfileEnter()_(IsFunction(CustomEval'Expression())) <--
[
    Local(fname);
    fname:=Type(CustomEval'Expression());
    If(profilefn[fname]=Empty,profilefn[fname]:=0);
    profilefn[fname] := profilefn[fname]+1;
];
Macro(Profile,{expression})
[
    ProfileStart();
    CustomEval(ProfileEnter(),True,CustomEval'Stop(),@expression);
    ForEach(item,profilefn)
      Echo("Function ",item[1]," called ",item[2]," times");
];

/// Measure the time taken by evaluation and print results.
Macro(Time,{expression})
[
	Local(result);
	Echo(GetTime(Set(result, @expression)), "seconds taken");
	result;
];




// ClearScreenString : the ascii escape codes to clear the screen
ClearScreenString := CharString(27):"[2J":CharString(27):"[1;1H";

// WriteLines: do the actual outputting of lines of a file to screen
WriteLines(filename,lines,from,nrlines,breakpoints,current):=
[
  Local(i,nr);
  nr:=Length(lines);
  WriteString(ClearScreenString);
  Echo("File ",filename," at line ",current);
  For(i:=from,i<from+nrlines And i<nr,i++)
  [

    if (current = i) 
      WriteString(">")
    else
      WriteString(" ");
    if (Contains(breakpoints,i)) 
      WriteString("*")
    else
      WriteString(" ");
    WriteString("| ");
    Echo(lines[i][1]);
  ];
];
Debug'FileLoaded := "";
Debug'FileLines := {};
Debug'NrLines:=20;

//
// DebugShowCode: show the part of the file we are currently executing (based on the 
// value returned by CustomEval'Expression() ).
//
// Currently unimplemented, should we remove?
//
DebugShowCode():=
[
  False;
];

]; //LocalSymbols