================ rvDebuggerServer::Break Halt execution of the game threads and inform the debugger client that the game has been halted ================ */
| 656 | ================ |
| 657 | */ |
| 658 | void rvDebuggerServer::Break ( idInterpreter* interpreter, idProgram* program, int instructionPointer ) |
| 659 | { |
| 660 | idBitMsg msg; |
| 661 | byte buffer[MAX_MSGLEN]; |
| 662 | const char* filename; |
| 663 | |
| 664 | // Clear all the break types |
| 665 | mBreakStepOver = false; |
| 666 | mBreakStepInto = false; |
| 667 | mBreakNext = false; |
| 668 | |
| 669 | // Grab the current statement and the filename that it came from |
| 670 | filename = ((idGameEditExt*) gameEdit)->GetFilenameForStatement(program,instructionPointer); |
| 671 | int linenumber = ((idGameEditExt*) gameEdit)->GetLineNumberForStatement(program, instructionPointer); |
| 672 | idStr fileStr = filename; |
| 673 | fileStr.BackSlashesToSlashes(); |
| 674 | |
| 675 | // Give the mouse cursor back to the world |
| 676 | Sys_GrabMouseCursor( false ); |
| 677 | |
| 678 | // Set the break variable so we know the main thread is stopped |
| 679 | mBreak = true; |
| 680 | mBreakProgram = program; |
| 681 | mBreakInterpreter = interpreter; |
| 682 | mBreakInstructionPointer = instructionPointer; |
| 683 | |
| 684 | // Inform the debugger of the breakpoint hit |
| 685 | msg.Init( buffer, sizeof( buffer ) ); |
| 686 | msg.BeginWriting(); |
| 687 | msg.WriteShort ( (short)DBMSG_BREAK ); |
| 688 | msg.WriteInt ( linenumber ); |
| 689 | msg.WriteString ( fileStr.c_str() ); |
| 690 | |
| 691 | //msg.WriteInt64( (int64_t)mBreakProgram ); |
| 692 | |
| 693 | SendPacket ( msg.GetData(), msg.GetSize() ); |
| 694 | |
| 695 | // Suspend the game thread. Since this will be called from within the main game thread |
| 696 | // execution wont return until after the thread is resumed |
| 697 | // DG: the original code used Win32 SuspendThread() here, but as there is no equivalent |
| 698 | // function in SDL and as this is only called within the main game thread anyway, |
| 699 | // just use a condition variable to put this thread to sleep until Resume() has set mBreak |
| 700 | SDL_LockMutex( mGameThreadBreakLock ); |
| 701 | while ( mBreak ) { |
| 702 | SDL_CondWait( mGameThreadBreakCond, mGameThreadBreakLock ); |
| 703 | } |
| 704 | SDL_UnlockMutex( mGameThreadBreakLock ); |
| 705 | |
| 706 | // Let the debugger client know that we have started back up again |
| 707 | SendMessage ( DBMSG_RESUMED ); |
| 708 | |
| 709 | // this should be platform specific |
| 710 | // TODO: maybe replace with SDL code? or does it not matter if debugger client runs on another machine? |
| 711 | #if defined( ID_ALLOW_TOOLS ) |
| 712 | // This is to give some time between the keypress that |
| 713 | // told us to resume and the setforeground window. Otherwise the quake window |
| 714 | // would just flash |
| 715 | Sleep ( 150 ); |
nothing calls this directly
no test coverage detected