diff options
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 1303bafc1..f96cbde64 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -185,11 +185,10 @@ static u8 NibbleToHex(u8 n) { | |||
| 185 | /** | 185 | /** |
| 186 | * Converts input hex string characters into an array of equivalent of u8 bytes. | 186 | * Converts input hex string characters into an array of equivalent of u8 bytes. |
| 187 | * | 187 | * |
| 188 | * @param dest Pointer to buffer to store u8 bytes. | ||
| 189 | * @param src Pointer to array of output hex string characters. | 188 | * @param src Pointer to array of output hex string characters. |
| 190 | * @param len Length of src array. | 189 | * @param len Length of src array. |
| 191 | */ | 190 | */ |
| 192 | static u32 HexToInt(u8* src, u32 len) { | 191 | static u32 HexToInt(const u8* src, size_t len) { |
| 193 | u32 output = 0; | 192 | u32 output = 0; |
| 194 | while (len-- > 0) { | 193 | while (len-- > 0) { |
| 195 | output = (output << 4) | HexCharToValue(src[0]); | 194 | output = (output << 4) | HexCharToValue(src[0]); |
| @@ -205,7 +204,7 @@ static u32 HexToInt(u8* src, u32 len) { | |||
| 205 | * @param src Pointer to array of u8 bytes. | 204 | * @param src Pointer to array of u8 bytes. |
| 206 | * @param len Length of src array. | 205 | * @param len Length of src array. |
| 207 | */ | 206 | */ |
| 208 | static void MemToGdbHex(u8* dest, u8* src, u32 len) { | 207 | static void MemToGdbHex(u8* dest, const u8* src, size_t len) { |
| 209 | while (len-- > 0) { | 208 | while (len-- > 0) { |
| 210 | u8 tmp = *src++; | 209 | u8 tmp = *src++; |
| 211 | *dest++ = NibbleToHex(tmp >> 4); | 210 | *dest++ = NibbleToHex(tmp >> 4); |
| @@ -220,7 +219,7 @@ static void MemToGdbHex(u8* dest, u8* src, u32 len) { | |||
| 220 | * @param src Pointer to array of output hex string characters. | 219 | * @param src Pointer to array of output hex string characters. |
| 221 | * @param len Length of src array. | 220 | * @param len Length of src array. |
| 222 | */ | 221 | */ |
| 223 | static void GdbHexToMem(u8* dest, u8* src, u32 len) { | 222 | static void GdbHexToMem(u8* dest, const u8* src, size_t len) { |
| 224 | while (len-- > 0) { | 223 | while (len-- > 0) { |
| 225 | *dest++ = (HexCharToValue(src[0]) << 4) | HexCharToValue(src[1]); | 224 | *dest++ = (HexCharToValue(src[0]) << 4) | HexCharToValue(src[1]); |
| 226 | src += 2; | 225 | src += 2; |
| @@ -244,7 +243,7 @@ static void IntToGdbHex(u8* dest, u32 v) { | |||
| 244 | * | 243 | * |
| 245 | * @param src Pointer to hex string. | 244 | * @param src Pointer to hex string. |
| 246 | */ | 245 | */ |
| 247 | static u32 GdbHexToInt(u8* src) { | 246 | static u32 GdbHexToInt(const u8* src) { |
| 248 | u32 output = 0; | 247 | u32 output = 0; |
| 249 | 248 | ||
| 250 | for (int i = 0; i < 8; i += 2) { | 249 | for (int i = 0; i < 8; i += 2) { |
| @@ -268,7 +267,7 @@ static u8 ReadByte() { | |||
| 268 | } | 267 | } |
| 269 | 268 | ||
| 270 | /// Calculate the checksum of the current command buffer. | 269 | /// Calculate the checksum of the current command buffer. |
| 271 | static u8 CalculateChecksum(u8* buffer, u32 length) { | 270 | static u8 CalculateChecksum(const u8* buffer, size_t length) { |
| 272 | return static_cast<u8>(std::accumulate(buffer, buffer + length, 0, std::plus<u8>())); | 271 | return static_cast<u8>(std::accumulate(buffer, buffer + length, 0, std::plus<u8>())); |
| 273 | } | 272 | } |
| 274 | 273 | ||
| @@ -586,7 +585,7 @@ static void ReadRegisters() { | |||
| 586 | 585 | ||
| 587 | /// Modify data of register specified by gdb client. | 586 | /// Modify data of register specified by gdb client. |
| 588 | static void WriteRegister() { | 587 | static void WriteRegister() { |
| 589 | u8* buffer_ptr = command_buffer + 3; | 588 | const u8* buffer_ptr = command_buffer + 3; |
| 590 | 589 | ||
| 591 | u32 id = HexCharToValue(command_buffer[1]); | 590 | u32 id = HexCharToValue(command_buffer[1]); |
| 592 | if (command_buffer[2] != '=') { | 591 | if (command_buffer[2] != '=') { |
| @@ -612,7 +611,7 @@ static void WriteRegister() { | |||
| 612 | 611 | ||
| 613 | /// Modify all registers with data received from the client. | 612 | /// Modify all registers with data received from the client. |
| 614 | static void WriteRegisters() { | 613 | static void WriteRegisters() { |
| 615 | u8* buffer_ptr = command_buffer + 1; | 614 | const u8* buffer_ptr = command_buffer + 1; |
| 616 | 615 | ||
| 617 | if (command_buffer[0] != 'G') | 616 | if (command_buffer[0] != 'G') |
| 618 | return SendReply("E01"); | 617 | return SendReply("E01"); |
| @@ -657,7 +656,7 @@ static void ReadMemory() { | |||
| 657 | SendReply("E01"); | 656 | SendReply("E01"); |
| 658 | } | 657 | } |
| 659 | 658 | ||
| 660 | u8* data = Memory::GetPointer(addr); | 659 | const u8* data = Memory::GetPointer(addr); |
| 661 | if (!data) { | 660 | if (!data) { |
| 662 | return SendReply("E00"); | 661 | return SendReply("E00"); |
| 663 | } | 662 | } |