Exemple #1
0
static int writeBinaryBufferToByteMemory(Buffer*  pBuffer, void* pvMemory, uint32_t writeByteCount)
{
    uint8_t* p = (uint8_t*) pvMemory;

    while (writeByteCount-- > 0)
    {
        char currChar;
    
        __try
        {
            __throwing_func( currChar = Buffer_ReadChar(pBuffer) );
            __throwing_func( currChar = unescapeCharIfNecessary(pBuffer, currChar) );
        }
        __catch
        {
            __rethrow_and_return(0);
        }

        Platform_MemWrite8(p++, (uint8_t)currChar);
        if (Platform_WasMemoryFaultEncountered())
            return 0;
    }

    return 1;
}
Exemple #2
0
/* 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);
}
Exemple #3
0
static void initializePlatformSpecificModulesWithDebuggerParameters(const char* pDebuggerParameters)
{
    Token    tokens;

    Token_Init(&tokens);
    __try
    {
        __throwing_func( Token_SplitString(&tokens, pDebuggerParameters) );
        __throwing_func( Platform_Init(&tokens) );
    }
    __catch
        __rethrow;
}
Exemple #4
0
void Platform_Init(Token* pParameterTokens)
{
    initModuleState();
    
    __try
    {
        __throwing_func( disableMbedInterface() );
        __throwing_func( __mriLpc176x_Init(pParameterTokens) );
    }
    __catch
    {
        __rethrow;
    }
}
Exemple #5
0
static void parseBreakpointWatchpointCommandArguments(BreakpointWatchpointArguments* pArguments)
{
    Buffer*    pBuffer = GetBuffer();
    
    __try
    {
        __throwing_func( pArguments->type = Buffer_ReadChar(pBuffer) );
        __throwing_func( ThrowIfNextCharIsNotEqualTo(pBuffer, ',') );
        __throwing_func( pArguments->address = ReadUIntegerArgument(pBuffer) );
        __throwing_func( ThrowIfNextCharIsNotEqualTo(pBuffer, ',') );
        __throwing_func( pArguments->kind = ReadUIntegerArgument(pBuffer) );
    }
    __catch
    {
        __rethrow;
    }
}
Exemple #6
0
static int readBytesFromBinaryBuffer(Buffer*  pBuffer, void* pvMemory, uint32_t writeByteCount)
{
    uint8_t* p = (uint8_t*) pvMemory;

    while (writeByteCount-- > 0)
    {
        char currChar;
        __try
        {
            __throwing_func( currChar = Buffer_ReadChar(pBuffer) );
            __throwing_func( currChar = unescapeCharIfNecessary(pBuffer, currChar) );
        }
        __catch
        {
            __rethrow_and_return(0);
        }
        *p++ = (uint8_t)currChar;
    }

    return 1;
}
Exemple #7
0
/* Handle the "qXfer:features" command used by gdb to read the target XML from the stub.

    Command Format: qXfer:features:read:target.xml:offset,length
*/
static uint32_t handleQueryTransferFeaturesCommand(void)
{
    Buffer*             pBuffer = GetBuffer();
    AnnexOffsetLength   arguments;
    
    __try
    {
        __throwing_func( readQueryTransferReadArguments(pBuffer, &arguments) );
        __throwing_func( validateAnnexIs(arguments.pAnnex, "target.xml") );
    }
    __catch
    {
        PrepareStringResponse(MRI_ERROR_INVALID_ARGUMENT);
        return 0;
    }

    arguments.pAnnex = Platform_GetTargetXml();
    arguments.annexSize = Platform_GetTargetXmlSize();
    handleQueryTransferReadCommand(&arguments);
    
    return 0;
}
Exemple #8
0
static void readQueryTransferReadArguments(Buffer* pBuffer, AnnexOffsetLength* pAnnexOffsetLength)
{
    static const char   readCommand[] = "read";

    memset(pAnnexOffsetLength, 0, sizeof(*pAnnexOffsetLength));
    if (!Buffer_IsNextCharEqualTo(pBuffer, ':') ||
        !Buffer_MatchesString(pBuffer, readCommand, sizeof(readCommand)-1) ||
        !Buffer_IsNextCharEqualTo(pBuffer, ':') )
    {
        __throw(invalidArgumentException);
    }
    
    __try
    {
        __throwing_func( pAnnexOffsetLength->pAnnex = readQueryTransferAnnexArgument(pBuffer) );
        __throwing_func( readQueryTransferOffsetLengthArguments(pBuffer, pAnnexOffsetLength) );
    }
    __catch
    {
        __rethrow;
    }
}
Exemple #9
0
/* Handle the 'c' command which is sent from gdb to tell the debugger to continue execution of the currently halted
   program.
   
    Command Format:     cAAAAAAAA
    Response Format:    Blank until the next exception, at which time a 'T' stop response packet will be sent.

    Where AAAAAAAA is an optional value to be used for the Program Counter when restarting the program.
*/
uint32_t HandleContinueCommand(void)
{
    Buffer*     pBuffer = GetBuffer();
    uint32_t    returnValue = 0;
    uint32_t    newPC;

    returnValue |= skipHardcodedBreakpoint();
    /* New program counter value is optional parameter. */
    __try
    {
        __throwing_func( newPC = ReadUIntegerArgument(pBuffer) );
        Platform_SetProgramCounter(newPC);
    }
    __catch
    {
        clearExceptionCode();
    }
    
    return (returnValue | HANDLER_RETURN_RESUME_PROGRAM | HANDLER_RETURN_RETURN_IMMEDIATELY);
}