From 6ab2a3ec0443522d3a5e527ea2db147f1a7e5e04 Mon Sep 17 00:00:00 2001 From: Jeremy Bennett Date: Tue, 30 Apr 2013 12:16:16 +0200 Subject: [PATCH] Make work for GDB 7.5 and fix a bug. * src/GdbServer.cpp: Include inttypes.h, first defining __STDC_FORMAT_MACROS so we get the printf/scanf macros. Update copyright date. (rspQuery): Add qAttached and all tracepoint packets. (rspSet): Add QTDV, QTEnable, QTDisable, QTDisconnected, QTSave, QTBuffer and QTNotes to list of tracepoint packets which are ignored. (rspRemoveMatchpoint, rspInsertMatchpoint): Use correct scanf field for uint32_t. * src/RspConnection.cpp: Update copyright date. * src/SimProc.cpp: Update copyright date. (parseSpecificMemoryClause): Use wordSize when calling MemoryBlock for word array. --- ChangeLog | 25 ++++++++++++++---- src/GdbServer.cpp | 60 ++++++++++++++++++++++++++++++++++--------- src/RspConnection.cpp | 2 +- src/SimProc.cpp | 4 +-- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index db339b3..d7af9bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,25 +1,40 @@ -2009-04-12 Jeremy Bennett +2012-04-30 Jeremy Bennett + + * src/GdbServer.cpp: Include inttypes.h, first defining + __STDC_FORMAT_MACROS so we get the printf/scanf macros. Update + copyright date. + (rspQuery): Add qAttached and all tracepoint packets. + (rspSet): Add QTDV, QTEnable, QTDisable, QTDisconnected, QTSave, + QTBuffer and QTNotes to list of tracepoint packets which are ignored. + (rspRemoveMatchpoint, rspInsertMatchpoint): Use correct scanf + field for uint32_t. + * src/RspConnection.cpp: Update copyright date. + * src/SimProc.cpp: Update copyright date. + (parseSpecificMemoryClause): Use wordSize when + calling MemoryBlock for word array. + +2012-04-29 Jeremy Bennett * src/RspConnection.cpp: include unistd.h, needed for close (). -2009-04-12 Jeremy Bennett +2012-04-29 Jeremy Bennett * README: Created as a symbolic link to README.md to keep autoconf happy. * README.md: Added instructions about autoreconf. * INSTALL: Replaced with standard installation instructions. -2009-04-12 Jeremy Bennett +2012-04-29 Jeremy Bennett * README.md: Even better use of MarkDown! -2009-04-12 Jeremy Bennett +2012-04-29 Jeremy Bennett * .gitignore: New file. * README.md: Renamed from README an updated to make best use of MarkDown. -2009-04-09 Jeremy Bennett +2009-04-12 Jeremy Bennett * src/RspProxyMain.cpp, src/RspProxyMain.h: created by renaming src/RspDummyMain.cpp and src/RspDummyMain.h respectively. diff --git a/src/GdbServer.cpp b/src/GdbServer.cpp index 1ccf2b7..f42c382 100644 --- a/src/GdbServer.cpp +++ b/src/GdbServer.cpp @@ -1,6 +1,6 @@ // GDB RSP server: implementation -// Copyright (C) 2009 Embecosm Limited +// Copyright (C) 2009, 2013 Embecosm Limited // Contributor Jeremy Bennett @@ -21,11 +21,12 @@ // ---------------------------------------------------------------------------- -// $Id$ - #include #include #include +#include +#define __STDC_FORMAT_MACROS +#include #include "GdbServer.h" #include "Utils.h" @@ -35,6 +36,8 @@ using std::cerr; using std::dec; using std::endl; using std::hex; +using std::string; + //----------------------------------------------------------------------------- //! Constructor for the GDB RSP server. @@ -755,6 +758,29 @@ GdbServer::rspQuery () pkt->packStr (""); rsp->putPkt (pkt); } + else if (0 == strncmp ("qAttached", pkt->data, strlen ("qAttached"))) + { + // Assume we are attaching to an existing process + pkt->packStr ("1"); + rsp->putPkt (pkt); + } + else if ((0 == strncmp ("qTMinFTPILen", pkt->data, strlen ("qTMinFTPILen"))) + || (0 == strncmp ("qTStatus", pkt->data, strlen ("qTStatus"))) + || (0 == strncmp ("qTP:", pkt->data, strlen ("qTP:"))) + || (0 == strncmp ("qTV:", pkt->data, strlen ("qTV:"))) + || (0 == strncmp ("qTfP", pkt->data, strlen ("qTfP"))) + || (0 == strncmp ("qTsP", pkt->data, strlen ("qTsP"))) + || (0 == strncmp ("qTfV", pkt->data, strlen ("qTfV"))) + || (0 == strncmp ("qTsV", pkt->data, strlen ("qTsV"))) + || (0 == strncmp ("qTfSTM", pkt->data, strlen ("qTfSTM"))) + || (0 == strncmp ("qTsSTM", pkt->data, strlen ("qTsSTM"))) + || (0 == strncmp ("qTSTMat:", pkt->data, strlen ("qTSTMat:"))) + || (0 == strncmp ("qTBuffer:", pkt->data, strlen ("qTBuffer:")))) + { + // All tracepoint features are not supported. + pkt->packStr (""); + rsp->putPkt (pkt); + } else { cerr << "Unrecognized RSP query: ignored" << endl; @@ -800,12 +826,20 @@ GdbServer::rspSet () pkt->packStr (""); rsp->putPkt (pkt); } - else if ((0 == strncmp ("QTDP", pkt->data, strlen ("QTDP"))) || - (0 == strncmp ("QFrame", pkt->data, strlen ("QFrame"))) || - (0 == strcmp ("QTStart", pkt->data)) || - (0 == strcmp ("QTStop", pkt->data)) || - (0 == strcmp ("QTinit", pkt->data)) || - (0 == strncmp ("QTro", pkt->data, strlen ("QTro")))) + else if ((0 == strncmp ("QTDP", pkt->data, strlen ("QTDP"))) + || (0 == strncmp ("QTDV:", pkt->data, strlen ("QTDV:"))) + || (0 == strncmp ("QFrame", pkt->data, strlen ("QFrame"))) + || (0 == strcmp ("QTStart", pkt->data)) + || (0 == strcmp ("QTStop", pkt->data)) + || (0 == strncmp ("QTEnable:", pkt->data, strlen ("QTEnable:"))) + || (0 == strncmp ("QTDisable:", pkt->data, strlen ("QTDisable:"))) + || (0 == strcmp ("QTinit", pkt->data)) + || (0 == strncmp ("QTro", pkt->data, strlen ("QTro"))) + || (0 == strncmp ("QTDisconnected:", pkt->data, + strlen ("QTDisconnected:"))) + || (0 == strncmp ("QTSave:", pkt->data, strlen ("QTSave:"))) + || (0 == strncmp ("QTBuffer:", pkt->data, strlen ("QTBuffer:"))) + || (0 == strncmp ("QTNotes:", pkt->data, strlen ("QTNotes:")))) { // All tracepoint features are not supported. This reply is really only // needed to 'QTDP', since with that the others should not be @@ -994,7 +1028,8 @@ GdbServer::rspRemoveMatchpoint () uint8_t *instrVec; // Instruction as byte vector // Break out the instruction - if (3 != sscanf (pkt->data, "z%1d,%lx,%1d", (int *)&type, &addr, &len)) + if (3 != sscanf (pkt->data, "z%1d,%" SCNx32 ",%1d", (int *)&type, &addr, + &len)) { cerr << "Warning: RSP matchpoint deletion request not " << "recognized: ignored" << endl; @@ -1171,10 +1206,11 @@ GdbServer::rspInsertMatchpoint () uint8_t *instrVec; // Instruction as byte vector // Break out the instruction - if (3 != sscanf (pkt->data, "Z%1d,%lx,%1d", (int *)&type, &addr, &len)) + if (3 != sscanf (pkt->data, "Z%1d,%" SCNx32 ",%1d", (int *)&type, &addr, + &len)) { cerr << "Warning: RSP matchpoint insertion request not " - << "recognized: ignored" << endl; + << " recognized: ignored" << endl; pkt->packStr ("E01"); rsp->putPkt (pkt); return; diff --git a/src/RspConnection.cpp b/src/RspConnection.cpp index 5601c6f..cac1521 100644 --- a/src/RspConnection.cpp +++ b/src/RspConnection.cpp @@ -1,7 +1,7 @@ // ---------------------------------------------------------------------------- // Remote Serial Protocol connection: implementation -// Copyright (C) 2009 Embecosm Limited +// Copyright (C) 2009, 2013 Embecosm Limited // Contributor Jeremy Bennett diff --git a/src/SimProc.cpp b/src/SimProc.cpp index ed1e352..18ef4fd 100644 --- a/src/SimProc.cpp +++ b/src/SimProc.cpp @@ -1,7 +1,7 @@ // ---------------------------------------------------------------------------- // Simulated Processor: implementation -// Copyright (C) 2009 Embecosm Limited +// Copyright (C) 2009, 2013 Embecosm Limited // Contributor Jeremy Bennett @@ -1077,7 +1077,7 @@ SimProc::parseSpecificMemoryClause (ScannerObject memoryType) uint32_t wordSize = byteSize / BYTES_PER_WORD; uint32_t *wordArray = new uint32_t [wordSize]; parseMemoryValues (memoryType, (int)wordSize, (void *)wordArray); - memList = new MemoryBlock (memList, baseAddr, byteSize, wordArray, + memList = new MemoryBlock (memList, baseAddr, wordSize, wordArray, isLittleEndianP); delete [] wordArray; }