/* before we run a statement, check if there's anything we have to do with the debugger here */ void DebugCheckStatement(struct ParseState *Parser) { int DoBreak = FALSE; int AddAt; Picoc *pc = Parser->pc; /* has the user manually pressed break? */ if (pc->DebugManualBreak) { PlatformPrintf(pc->CStdOut, "break\n"); DoBreak = TRUE; pc->DebugManualBreak = FALSE; } /* is this a breakpoint location? */ if (Parser->pc->BreakpointCount != 0 && DebugTableSearchBreakpoint(Parser, &AddAt) != NULL) DoBreak = TRUE; /* handle a break */ if (DoBreak) { PlatformPrintf(pc->CStdOut, "Handling a break\n"); PicocParseInteractiveNoStartPrompt(pc, FALSE); } }
/* set a breakpoint in the table */ void DebugSetBreakpoint(struct ParseState *Parser) { int AddAt; struct TableEntry *FoundEntry = DebugTableSearchBreakpoint(Parser, &AddAt); if (FoundEntry == NULL) { /* add it to the table */ struct TableEntry *NewEntry = HeapAllocMem(sizeof(struct TableEntry)); if (NewEntry == NULL) ProgramFail(NULL, "out of memory"); NewEntry->p.b.FileName = Parser->FileName; NewEntry->p.b.Line = Parser->Line; NewEntry->p.b.CharacterPos = Parser->CharacterPos; NewEntry->Next = BreakpointHashTable[AddAt]; BreakpointHashTable[AddAt] = NewEntry; BreakpointCount++; } }