/* Handle the 'C' command which is sent from gdb to tell the debugger to continue execution of the currently halted program. It is similar to the 'c' command but it also provides a signal level, which MRI ignores. Command Format: cAA;BBBBBBBB Response Format: Blank until the next exception, at which time a 'T' stop response packet will be sent. Where AA is the signal to be set, and BBBBBBBB is an optional value to be used for the Program Counter when restarting the program. */ uint32_t HandleContinueWithSignalCommand(void) { Buffer* pBuffer = GetBuffer(); uint32_t returnValue = 0; uint32_t newPC; returnValue |= skipHardcodedBreakpoint(); __try { /* Fetch signal value but ignore it. */ __throwing_func( ReadUIntegerArgument(pBuffer) ); if (Buffer_BytesLeft(pBuffer) && Buffer_IsNextCharEqualTo(pBuffer, ';')) { __throwing_func( newPC = ReadUIntegerArgument(pBuffer) ); Platform_SetProgramCounter(newPC); } } __catch { PrepareStringResponse(MRI_ERROR_INVALID_ARGUMENT); return 0; } return (returnValue | HANDLER_RETURN_RESUME_PROGRAM | HANDLER_RETURN_RETURN_IMMEDIATELY); }
static void handleQueryTransferReadCommand(AnnexOffsetLength* pArguments) { Buffer* pBuffer = GetBuffer(); char dataPrefixChar = 'm'; uint32_t offset = pArguments->offset; uint32_t length = pArguments->length; uint32_t outputBufferSize; uint32_t validMemoryMapBytes; if (offset >= pArguments->annexSize) { /* Attempt to read past end of XML content so flag with a l only packet. */ dataPrefixChar = 'l'; length = 0; validMemoryMapBytes = 0; } else { validMemoryMapBytes = pArguments->annexSize - offset; } InitBuffer(); outputBufferSize = Buffer_BytesLeft(pBuffer); if (length > outputBufferSize) length = outputBufferSize; if (length > validMemoryMapBytes) { dataPrefixChar = 'l'; length = validMemoryMapBytes; } Buffer_WriteChar(pBuffer, dataPrefixChar); Buffer_WriteSizedString(pBuffer, pArguments->pAnnex + offset, length); }
static uint32_t isReceiveBufferEmpty() { return (uint32_t)(Buffer_BytesLeft(&g_receiveBuffer) == 0); }