-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebugger.cpp
More file actions
90 lines (86 loc) · 2.21 KB
/
debugger.cpp
File metadata and controls
90 lines (86 loc) · 2.21 KB
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
#include "library.h"
#include "debug.h"
#include "tools.h"
extern vector<string> vect;
extern vector<string> address;
void debugger()
{
string cmd[10];
int lineNo=0,breakLine=-1;
int i=0,j,len=vect.size();
int len1;
string breakNo="";
string instr;
string command;
cout<<endl<<"START DEBUGGING"<<endl;
do{
cin>>command;
if(command=="s" || command=="step")
{
instr=vect[lineNo];
cout<<lineNo<<" : "<<instr<<endl;
step(instr,lineNo+1);
lineNo++;
}
if(command=="p" || command=="print")
{
print();
}
if(command=="b" || command=="break")
{
cin>>breakNo;
if(!validAddress(breakNo) || breakNo.size()>4)
{
cout<<"wrong line number"<<endl;
breakNo="";
breakLine=-1;
}
else
{
breakLine=findIndex(breakNo);
}
}
if(command=="r" || command=="run")
{
if(breakLine==-1)
len1=len;
else
len1=breakLine;
for(i=lineNo;i<len1;i++)
{
j=0;
instr=vect[lineNo];
cout<<lineNo<<" : "<<instr<<endl;
stringstream iss(instr);
while(iss >> instr)
cmd[j++]=instr;
runprog(cmd,j);
lineNo++;
}
i=len1;
breakLine=-1;
}
if(command=="q" || command=="quit")
{
exit(0);
}
if(command=="help" )
{
ifstream myfile;
myfile.open("help.txt");
if(!myfile.is_open())
{
cout<<"error : file not open or invalid file"<<endl;
exit(0);
}
else
{
string text;
while(getline(myfile,text))
{
cout << text << endl;
}
}
}
}while(lineNo<len);
}