| 494 | } |
| 495 | |
| 496 | TimelinePacketStatus WriteTimelineEventClassBinary(uint64_t profilingGuid, |
| 497 | uint64_t nameGuid, |
| 498 | unsigned char* buffer, |
| 499 | unsigned int remainingBufferSize, |
| 500 | unsigned int& numberOfBytesWritten) |
| 501 | { |
| 502 | // Initialize the output value |
| 503 | numberOfBytesWritten = 0; |
| 504 | |
| 505 | // Check that the given buffer is valid |
| 506 | if (buffer == nullptr || remainingBufferSize == 0) |
| 507 | { |
| 508 | return TimelinePacketStatus::BufferExhaustion; |
| 509 | } |
| 510 | |
| 511 | // Utils |
| 512 | unsigned int uint32_t_size = sizeof(uint32_t); |
| 513 | unsigned int uint64_t_size = sizeof(uint64_t); |
| 514 | |
| 515 | // decl_id of the timeline message |
| 516 | uint32_t declId = 2; |
| 517 | |
| 518 | // Calculate the length of the data (in bytes) |
| 519 | unsigned int dataSize = uint32_t_size + (uint64_t_size * 2); // decl_id + Profiling GUID + Name GUID |
| 520 | |
| 521 | // Check whether the timeline binary fits in the given buffer |
| 522 | if (dataSize > remainingBufferSize) |
| 523 | { |
| 524 | return TimelinePacketStatus::BufferExhaustion; |
| 525 | } |
| 526 | |
| 527 | // Initialize the offset for writing in the buffer |
| 528 | unsigned int offset = 0; |
| 529 | |
| 530 | // Write the timeline binary payload to the buffer |
| 531 | WriteUint32(buffer, offset, declId); // decl_id |
| 532 | offset += uint32_t_size; |
| 533 | WriteUint64(buffer, offset, profilingGuid); // Profiling GUID |
| 534 | offset += uint64_t_size; |
| 535 | WriteUint64(buffer, offset, nameGuid); // Name GUID |
| 536 | |
| 537 | // Update the number of bytes written |
| 538 | numberOfBytesWritten = dataSize; |
| 539 | |
| 540 | return TimelinePacketStatus::Ok; |
| 541 | } |
| 542 | |
| 543 | TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp, |
| 544 | int threadId, |
no test coverage detected