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){
|
void list(void){
|
||||||
//todo
|
//todo
|
||||||
}
|
}
|
||||||
void breakpoint(void){
|
void breakpoint(int *bp){
|
||||||
//todo
|
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];
|
char input[20];
|
||||||
while (true) {
|
while (true) {
|
||||||
printf("DEBUG(%i): inspect, list, breakpoint, run, step, quit?",point);
|
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);
|
printf("%s",input);
|
||||||
if(input[0] == 'i') {inspect(stack,fp);}
|
if(input[0] == 'i') {inspect(stack,fp);}
|
||||||
if(input[0] == 'l') list();
|
if(input[0] == 'l') list();
|
||||||
if(input[0] == 'b') breakpoint();
|
if(input[0] == 'b') breakpoint(bp);
|
||||||
if(input[0] == 's') break;
|
if(input[0] == 's') break;
|
||||||
if(input[0] == 'r') {*debug = 0; break;};
|
if(input[0] == 'r') {*debug = 0; break;};
|
||||||
if(input[0] == 'q') exit(0);
|
if(input[0] == 'q') exit(0);
|
||||||
|
|||||||
4
njvm.c
4
njvm.c
@ -28,6 +28,7 @@ void help(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void execute(struct program program) {
|
void execute(struct program program) {
|
||||||
|
int bp = -1;
|
||||||
int i;
|
int i;
|
||||||
char charInput;
|
char charInput;
|
||||||
StackSlot tempSlot;
|
StackSlot tempSlot;
|
||||||
@ -35,7 +36,8 @@ void execute(struct program program) {
|
|||||||
ObjRef tempObj2;
|
ObjRef tempObj2;
|
||||||
int tempInt;
|
int tempInt;
|
||||||
for (i = 0; i < *program.size; ++i) {
|
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) {
|
switch (program.program[i] >> 24) {
|
||||||
case HALT:
|
case HALT:
|
||||||
if (debug == 1) printf("halt\n");
|
if (debug == 1) printf("halt\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user