| 57 | } |
| 58 | |
| 59 | void StreamMetadataCommandHandler::ParseData(const arm::pipe::Packet &packet) |
| 60 | { |
| 61 | // Check that at least the packet contains the fixed-length fields |
| 62 | if (packet.GetLength() < 80) |
| 63 | { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | // Utils |
| 68 | unsigned int uint16_t_size = sizeof(uint16_t); |
| 69 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 70 | |
| 71 | const unsigned char* buffer = packet.GetData(); |
| 72 | unsigned int offset = 0; |
| 73 | |
| 74 | // Get the fixed-length fields |
| 75 | m_PipeMagic = arm::pipe::ReadUint32(buffer, offset); |
| 76 | offset += uint32_t_size; |
| 77 | m_StreamMetadataVersion = arm::pipe::ReadUint32(buffer, offset); |
| 78 | offset += uint32_t_size; |
| 79 | m_MaxDataLen = arm::pipe::ReadUint32(buffer, offset); |
| 80 | offset += uint32_t_size; |
| 81 | m_Pid = arm::pipe::ReadUint32(buffer, offset); |
| 82 | offset += uint32_t_size; |
| 83 | m_OffsetInfo = arm::pipe::ReadUint32(buffer, offset); |
| 84 | offset += uint32_t_size; |
| 85 | m_OffsetHwVersion = arm::pipe::ReadUint32(buffer, offset); |
| 86 | offset += uint32_t_size; |
| 87 | m_OffsetSwVersion = arm::pipe::ReadUint32(buffer, offset); |
| 88 | offset += uint32_t_size; |
| 89 | m_OffsetProcessName = arm::pipe::ReadUint32(buffer, offset); |
| 90 | offset += uint32_t_size; |
| 91 | m_OffsetPacketVersionTable = arm::pipe::ReadUint32(buffer, offset); |
| 92 | offset += uint32_t_size * 2; // Also skipping the reserved word (all zeros) |
| 93 | |
| 94 | // Get the string fields |
| 95 | m_SoftwareInfo = m_OffsetInfo > 0 ? ReadString(buffer, m_OffsetInfo) : ""; |
| 96 | m_HardwareVersion = m_OffsetHwVersion > 0 ? ReadString(buffer, m_OffsetHwVersion) : ""; |
| 97 | m_SoftwareVersion = m_OffsetSwVersion > 0 ? ReadString(buffer, m_OffsetSwVersion) : ""; |
| 98 | m_ProcessName = m_OffsetProcessName > 0 ? ReadString(buffer, m_OffsetProcessName) : ""; |
| 99 | |
| 100 | // Get the packet versions |
| 101 | m_PacketVersionTable.clear(); |
| 102 | if (m_OffsetPacketVersionTable > 0) |
| 103 | { |
| 104 | offset = m_OffsetPacketVersionTable; |
| 105 | uint16_t packetEntries = arm::pipe::ReadUint16(buffer, offset + uint16_t_size); |
| 106 | offset += uint32_t_size; // Also skipping the reserved bytes (all zeros) |
| 107 | for (uint16_t i = 0; i < packetEntries; i++) |
| 108 | { |
| 109 | uint16_t packetFamilyAndId = arm::pipe::ReadUint16(buffer, offset + uint16_t_size); |
| 110 | uint16_t packetFamily = (packetFamilyAndId >> 10) & 0x003F; |
| 111 | uint16_t packetId = (packetFamilyAndId >> 0) & 0x03FF; |
| 112 | offset += uint32_t_size; // Also skipping the reserved bytes (all zeros) |
| 113 | uint32_t packetVersion = arm::pipe::ReadUint32(buffer, offset); |
| 114 | offset += uint32_t_size; |
| 115 | |
| 116 | m_PacketVersionTable.push_back({ packetFamily, packetId, packetVersion }); |
nothing calls this directly
no test coverage detected