| 60 | } |
| 61 | |
| 62 | void DebugInterface::Send(BackendToDebugger const & msg) |
| 63 | { |
| 64 | if (clientSocket_ == 0) { |
| 65 | Debug("DebugInterface::Send(): Not connected to debugger frontend"); |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | uint32_t size = (uint32_t)msg.ByteSizeLong(); |
| 70 | uint32_t packetSize = size + 4; |
| 71 | Send((uint8_t *)&packetSize, 4); |
| 72 | |
| 73 | if (size < 0x100) { |
| 74 | uint8_t buf[0x100]; |
| 75 | if (!msg.SerializeToArray(buf, size)) { |
| 76 | Fail("Unable to serialize message"); |
| 77 | } |
| 78 | |
| 79 | Send(buf, size); |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | uint8_t * buf = new uint8_t[size]; |
| 84 | if (!msg.SerializeToArray(buf, size)) { |
| 85 | Fail("Unable to serialize message"); |
| 86 | } |
| 87 | |
| 88 | Send(buf, size); |
| 89 | delete[] buf; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | void DebugInterface::Send(uint8_t * buf, uint32_t length) |
| 94 | { |