Exemplo n.º 1
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.º 2
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.º 3
0
/* Send file system level stat request to gdb.

    Data Format: Fstat,ff/nn,bb
    
    Where ff is the hex representation of the address of the filename.
          nn is the hex value of the count of characters in the filename pointed to by ff.
          bb is the hex representation of the address of the stat structure to be filled in.
*/
int IssueGdbFileStatRequest(const StatParameters* pParameters)
{
    static const char  gdbStatCommand[] = "Fstat,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbStatCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->filenameAddress);
    Buffer_WriteChar(pBuffer, '/');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->filenameLength);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, pParameters->fileStatBuffer);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
0
void WriteHexValueToGdbConsole(uint32_t Value)
{
    Buffer BufferObject;
    char   StringBuffer[11];
    
    Buffer_Init(&BufferObject, StringBuffer, sizeof(StringBuffer));
    Buffer_WriteString(&BufferObject, "0x");
    Buffer_WriteUIntegerAsHex(&BufferObject, Value);
    Buffer_WriteChar(&BufferObject, '\0');
    
    WriteStringToGdbConsole(StringBuffer);
}
Exemplo n.º 8
0
/* Send file stat request to gdb on behalf of mbed LocalFileSystem to get file length.

    Data Format: Fstat,ff,bb
    
    Where ff is the hex value of the file descriptor to be closed.
          bb is the hex representation of the address of the stat structure to be filled in.
*/
int IssueGdbFileStatRequest(uint32_t fileDescriptor, uint32_t fileStatBuffer)
{
    static const char  gdbStatCommand[] = "Ffstat,";
    Buffer*            pBuffer = GetInitializedBuffer();

    Buffer_WriteString(pBuffer, gdbStatCommand);
    Buffer_WriteUIntegerAsHex(pBuffer, fileDescriptor);
    Buffer_WriteChar(pBuffer, ',');
    Buffer_WriteUIntegerAsHex(pBuffer, fileStatBuffer);
    
    SendPacketToGdb();
    return processGdbFileResponseCommands();
}
Exemplo n.º 9
0
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);
}