Exemplo n.º 1
0
/* Send the 'O' command to gdb to output text to its console.

    Command Format: OXX...
    Where XX is the hexadecimal representation of each character in the string to be sent to the gdb console.
*/
static void writeStringToExclusiveGdbCommChannel(const char* pString)
{
    Buffer* pBuffer = GetInitializedBuffer();

    Buffer_WriteChar(pBuffer, 'O');
    while (*pString)
        Buffer_WriteByteAsHex(pBuffer, *pString++);
    if (!Buffer_OverrunDetected(pBuffer))
        SendPacketToGdb();
}
Exemplo n.º 2
0
/* Sent when an exception occurs while program is executing because of previous 'c' (Continue) or 's' (Step) commands.

    Data Format: Tssii:xxxxxxxx;ii:xxxxxxxx;...
    
    Where ss is the hex value of the signal which caused the exception.
          ii is the hex offset of the 32-bit register value following the ':'  The offset is relative to the register
             contents in the g response packet and the SContext structure.
          xxxxxxxx is the 32-bit value of the specified register in hex format.
          The above ii:xxxxxxxx; patterns can be repeated for whichever register values should be sent with T repsonse.
*/
uint32_t Send_T_StopResponse(void)
{
    Buffer* pBuffer = GetInitializedBuffer();
    
    Buffer_WriteChar(pBuffer, 'T');
    Buffer_WriteByteAsHex(pBuffer, GetSignalValue());
    Platform_WriteTResponseRegistersToBuffer(pBuffer);

    SendPacketToGdb();
    return HANDLER_RETURN_RETURN_IMMEDIATELY;
}
Exemplo n.º 3
0
/* Send file close request to gdb on behalf of mbed LocalFileSystem.

    Data Format: Fclose,ff
    
    Where ff is the hex value of the file descriptor to be closed.
*/
int IssueGdbFileCloseRequest(uint32_t fileDescriptor)
{
    static const char  gdbCloseCommand[] = "Fclose,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbCloseCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, fileDescriptor);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 4
0
Arquivo: mri.c Projeto: adamgreen/mri
static int handleGDBCommand(void)
{
    Buffer*         pBuffer = GetBuffer();
    uint32_t        handlerResult = 0;
    char            commandChar;
    size_t          i;
    static const struct
    {
        uint32_t     (*Handler)(void);
        char         commandChar;
    } commandTable[] =
    {
        {Send_T_StopResponse,                       '?'},
        {HandleContinueCommand,                     'c'},
        {HandleContinueWithSignalCommand,           'C'},
        {HandleFileIOCommand,                       'F'},
        {HandleRegisterReadCommand,                 'g'},
        {HandleRegisterWriteCommand,                'G'},
        {HandleMemoryReadCommand,                   'm'},
        {HandleMemoryWriteCommand,                  'M'},
        {HandleQueryCommand,                        'q'},
        {HandleSingleStepCommand,                   's'},
        {HandleSingleStepWithSignalCommand,         'S'},
        {HandleBinaryMemoryWriteCommand,            'X'},
        {HandleBreakpointWatchpointRemoveCommand,   'z'},
        {HandleBreakpointWatchpointSetCommand,      'Z'}
    };
    
    getPacketFromGDB();
    
    commandChar = Buffer_ReadChar(pBuffer);
    for (i = 0 ; i < ARRAY_SIZE(commandTable) ; i++)
    {
        if (commandTable[i].commandChar == commandChar)
        {
            handlerResult = commandTable[i].Handler();
            if (handlerResult & HANDLER_RETURN_RETURN_IMMEDIATELY)
            {
                return handlerResult & HANDLER_RETURN_RESUME_PROGRAM;
            }
            else
            {
                break;
            }
        }
    }
    if (ARRAY_SIZE(commandTable) == i)
        PrepareEmptyResponseForUnknownCommand();

    SendPacketToGdb();
    return (handlerResult & HANDLER_RETURN_RESUME_PROGRAM);
}
Exemplo n.º 5
0
/* Send file unlink request to gdb on behalf of mbed LocalFileSystem.

    Data Format: Funlink,ff/nn
    
    Where ff is the hex representation of the address of the filename to be deleted.
          nn is the hex value of the count of characters in the filename pointed to by ff.
*/
int IssueGdbFileUnlinkRequest(const RemoveParameters* pParameters)
{
    static const char  gdbUnlinkCommand[] = "Funlink,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbUnlinkCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->filenameAddress);
    Buffer_WriteChar(pBuffer, '/');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->filenameLength + 1);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 6
0
/* Send file read request to gdb on behalf of mbed LocalFileSystem or stdin.

    Data Format: Fread,ff,pp,cc
    
    Where ff is the hex value of the file descriptor of the file from which the data should be read.
          pp is the hex representation of the buffer to be read into.
          cc is the hex value of the count of bytes in the buffer to be read from the specified file.
*/
int IssueGdbFileReadRequest(const TransferParameters* pParameters)
{
    static const char  gdbReadCommand[] = "Fread,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbReadCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->fileDescriptor);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->bufferAddress);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->bufferSize);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 7
0
/* Send file seek request to gdb on behalf of mbed LocalFileSystem.

    Data Format: Flseek,ff,oo,ww
    
    Where ff is the hex value of the file descriptor to be seeked within.
          oo is the hex value of the signed offset for the seek.
          ww is the hex value of the flag indicating from where the seek should be conducted (whence.)
*/
int IssueGdbFileSeekRequest(const SeekParameters* pParameters)
{
    static const char  gdbSeekCommand[] = "Flseek,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbSeekCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->fileDescriptor);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteIntegerAsHex(pBuffer, pParameters->offsetFromStart);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteIntegerAsHex(pBuffer, SEEK_SET);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 8
0
/* Send file open request to gdb on behalf of mbed LocalFileSystem.

    Data Format: Fopen,ff/nn,mm
    
    Where ff is the hex representation of the address of the filename to be opened.
          nn is the hex value of the count of characters in the filename pointed to by ff.
          mm is the hex value of the mode to be used for the file open.
*/
int IssueGdbFileOpenRequest(const OpenParameters* pParameters)
{
    static const char  gdbOpenCommand[] = "Fopen,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbOpenCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, (uint32_t)(size_t)pParameters->pFilename);
    Buffer_WriteChar(pBuffer, '/');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->filenameLength + 1);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->flags);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->mode);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 9
0
/* Send file rename request to gdb.

    Data Format: Frename,oo/aa,nn/bb
    
    Where oo is the hex representation of the address of the original filename.
          aa is the hex value of the count of characters in the original filename pointed to by oo.
          nn is the hex representation of the address of the new filename.
          bb is the hex value of the count of characters in the new filename pointed to by nn.
*/
int IssueGdbFileRenameRequest(const RenameParameters* pParameters)
{
    static const char  gdbCommand[] = "Frename,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->origFilenameAddress);
    Buffer_WriteChar(pBuffer, '/');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->origFilenameLength);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->newFilenameAddress);
    Buffer_WriteChar(pBuffer, '/');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->newFilenameLength);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}