now breakpoints are possible
This commit is contained in:
parent
b6320ecba7
commit
9155216fd2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11
debugMenu.c
11
debugMenu.c
@ -29,11 +29,14 @@ void inspect(struct stack s, int fp){
|
||||
void list(void){
|
||||
//todo
|
||||
}
|
||||
void breakpoint(void){
|
||||
//todo
|
||||
void breakpoint(int *bp){
|
||||
printf("BREAKPOINT: ");
|
||||
char input[20];
|
||||
fgets(input,20,stdin);
|
||||
*bp = atoi(input);
|
||||
}
|
||||
|
||||
void debugMenu(int fp, struct stack stack, int* debug, int point){
|
||||
void debugMenu(int fp, struct stack stack, int* debug, int point, int* bp){
|
||||
char input[20];
|
||||
while (true) {
|
||||
printf("DEBUG(%i): inspect, list, breakpoint, run, step, quit?",point);
|
||||
@ -41,7 +44,7 @@ void debugMenu(int fp, struct stack stack, int* debug, int point){
|
||||
printf("%s",input);
|
||||
if(input[0] == 'i') {inspect(stack,fp);}
|
||||
if(input[0] == 'l') list();
|
||||
if(input[0] == 'b') breakpoint();
|
||||
if(input[0] == 'b') breakpoint(bp);
|
||||
if(input[0] == 's') break;
|
||||
if(input[0] == 'r') {*debug = 0; break;};
|
||||
if(input[0] == 'q') exit(0);
|
||||
|
||||
4
njvm.c
4
njvm.c
@ -28,6 +28,7 @@ void help(void) {
|
||||
}
|
||||
|
||||
void execute(struct program program) {
|
||||
int bp = -1;
|
||||
int i;
|
||||
char charInput;
|
||||
StackSlot tempSlot;
|
||||
@ -35,7 +36,8 @@ void execute(struct program program) {
|
||||
ObjRef tempObj2;
|
||||
int tempInt;
|
||||
for (i = 0; i < *program.size; ++i) {
|
||||
// if (debug == 1) debugMenu(fp, stack, &debug, i);
|
||||
if (debug == 1 || bp == i) debugMenu(fp, stack, &debug, i, &bp);
|
||||
if(debug == 1) printf("(%i)",i);
|
||||
switch (program.program[i] >> 24) {
|
||||
case HALT:
|
||||
if (debug == 1) printf("halt\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user