|
@@ -12,15 +12,15 @@ namespace xray {
|
|
|
|
|
|
Error RecordInitializer::visit(BufferExtents &R) {
|
|
Error RecordInitializer::visit(BufferExtents &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, sizeof(uint64_t)))
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, sizeof(uint64_t)))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a buffer extent (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a buffer extent (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.Size = E.getU64(&OffsetPtr);
|
|
R.Size = E.getU64(&OffsetPtr);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read buffer extent at offset %d.",
|
|
|
|
|
|
+ "Cannot read buffer extent at offset %" PRId64 ".",
|
|
OffsetPtr);
|
|
OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
@@ -30,23 +30,25 @@ Error RecordInitializer::visit(BufferExtents &R) {
|
|
Error RecordInitializer::visit(WallclockRecord &R) {
|
|
Error RecordInitializer::visit(WallclockRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a wallclock record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a wallclock record (%" PRId64 ").", OffsetPtr);
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.Seconds = E.getU64(&OffsetPtr);
|
|
R.Seconds = E.getU64(&OffsetPtr);
|
|
if (OffsetPtr == PreReadOffset)
|
|
if (OffsetPtr == PreReadOffset)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read wall clock 'seconds' field at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read wall clock 'seconds' field at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.Nanos = E.getU32(&OffsetPtr);
|
|
R.Nanos = E.getU32(&OffsetPtr);
|
|
if (OffsetPtr == PreReadOffset)
|
|
if (OffsetPtr == PreReadOffset)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read wall clock 'nanos' field at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read wall clock 'nanos' field at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
// Align to metadata record size boundary.
|
|
// Align to metadata record size boundary.
|
|
assert(OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize);
|
|
assert(OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize);
|
|
@@ -57,21 +59,23 @@ Error RecordInitializer::visit(WallclockRecord &R) {
|
|
Error RecordInitializer::visit(NewCPUIDRecord &R) {
|
|
Error RecordInitializer::visit(NewCPUIDRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a new cpu id record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a new cpu id record (%" PRId64 ").", OffsetPtr);
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.CPUId = E.getU16(&OffsetPtr);
|
|
R.CPUId = E.getU16(&OffsetPtr);
|
|
if (OffsetPtr == PreReadOffset)
|
|
if (OffsetPtr == PreReadOffset)
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read CPU id at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read CPU id at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.TSC = E.getU64(&OffsetPtr);
|
|
R.TSC = E.getU64(&OffsetPtr);
|
|
if (OffsetPtr == PreReadOffset)
|
|
if (OffsetPtr == PreReadOffset)
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read CPU TSC at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read CPU TSC at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - BeginOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - BeginOffset);
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -80,16 +84,16 @@ Error RecordInitializer::visit(NewCPUIDRecord &R) {
|
|
Error RecordInitializer::visit(TSCWrapRecord &R) {
|
|
Error RecordInitializer::visit(TSCWrapRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a new TSC wrap record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a new TSC wrap record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.BaseTSC = E.getU64(&OffsetPtr);
|
|
R.BaseTSC = E.getU64(&OffsetPtr);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Cannot read TSC wrap record at offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Cannot read TSC wrap record at offset %" PRId64 ".", OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -98,9 +102,9 @@ Error RecordInitializer::visit(TSCWrapRecord &R) {
|
|
Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a custom event record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a custom event record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
@@ -108,20 +112,22 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a custom event record size field offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read a custom event record size field offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
if (R.Size <= 0)
|
|
if (R.Size <= 0)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Invalid size for custom event (size = %d) at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Invalid size for custom event (size = %d) at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.TSC = E.getU64(&OffsetPtr);
|
|
R.TSC = E.getU64(&OffsetPtr);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a custom event TSC field at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read a custom event TSC field at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
// For version 4 onwards, of the FDR log, we want to also capture the CPU ID
|
|
// For version 4 onwards, of the FDR log, we want to also capture the CPU ID
|
|
// of the custom event.
|
|
// of the custom event.
|
|
@@ -131,7 +137,7 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Missing CPU field at offset %d", OffsetPtr);
|
|
|
|
|
|
+ "Missing CPU field at offset %" PRId64 ".", OffsetPtr);
|
|
}
|
|
}
|
|
|
|
|
|
assert(OffsetPtr > BeginOffset &&
|
|
assert(OffsetPtr > BeginOffset &&
|
|
@@ -142,8 +148,8 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Cannot read %d bytes of custom event data from offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Cannot read %d bytes of custom event data from offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
std::vector<uint8_t> Buffer;
|
|
std::vector<uint8_t> Buffer;
|
|
Buffer.resize(R.Size);
|
|
Buffer.resize(R.Size);
|
|
@@ -151,15 +157,15 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading data into buffer of size %d at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Failed reading data into buffer of size %d at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading enough bytes for the custom event payload -- read %d "
|
|
|
|
- "expecting %d bytes at offset %d.",
|
|
|
|
|
|
+ "Failed reading enough bytes for the custom event payload -- read "
|
|
|
|
+ "%" PRId64 " expecting %d bytes at offset %" PRId64 ".",
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
|
|
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
@@ -169,9 +175,9 @@ Error RecordInitializer::visit(CustomEventRecord &R) {
|
|
Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a custom event record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a custom event record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
@@ -180,20 +186,22 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a custom event record size field offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read a custom event record size field offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
if (R.Size <= 0)
|
|
if (R.Size <= 0)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Invalid size for custom event (size = %d) at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Invalid size for custom event (size = %d) at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a custom event record TSC delta field at offset %d.",
|
|
|
|
|
|
+ "Cannot read a custom event record TSC delta field at offset "
|
|
|
|
+ "%" PRId64 ".",
|
|
OffsetPtr);
|
|
OffsetPtr);
|
|
|
|
|
|
assert(OffsetPtr > BeginOffset &&
|
|
assert(OffsetPtr > BeginOffset &&
|
|
@@ -204,8 +212,8 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Cannot read %d bytes of custom event data from offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Cannot read %d bytes of custom event data from offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
std::vector<uint8_t> Buffer;
|
|
std::vector<uint8_t> Buffer;
|
|
Buffer.resize(R.Size);
|
|
Buffer.resize(R.Size);
|
|
@@ -213,15 +221,15 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading data into buffer of size %d at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Failed reading data into buffer of size %d at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading enough bytes for the custom event payload -- read %d "
|
|
|
|
- "expecting %d bytes at offset %d.",
|
|
|
|
|
|
+ "Failed reading enough bytes for the custom event payload -- read "
|
|
|
|
+ "%" PRId64 " expecting %d bytes at offset %" PRId64 ".",
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
|
|
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
@@ -231,9 +239,9 @@ Error RecordInitializer::visit(CustomEventRecordV5 &R) {
|
|
Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a typed event record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a typed event record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
@@ -242,20 +250,22 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a typed event record size field offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read a typed event record size field offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
if (R.Size <= 0)
|
|
if (R.Size <= 0)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Invalid size for typed event (size = %d) at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Invalid size for typed event (size = %d) at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
R.Delta = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a typed event record TSC delta field at offset %d.",
|
|
|
|
|
|
+ "Cannot read a typed event record TSC delta field at offset "
|
|
|
|
+ "%" PRId64 ".",
|
|
OffsetPtr);
|
|
OffsetPtr);
|
|
|
|
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
@@ -263,7 +273,8 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Cannot read a typed event record type field at offset %d.", OffsetPtr);
|
|
|
|
|
|
+ "Cannot read a typed event record type field at offset %" PRId64 ".",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
assert(OffsetPtr > BeginOffset &&
|
|
assert(OffsetPtr > BeginOffset &&
|
|
OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize);
|
|
OffsetPtr - BeginOffset <= MetadataRecord::kMetadataBodySize);
|
|
@@ -273,8 +284,8 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr, R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::bad_address),
|
|
std::make_error_code(std::errc::bad_address),
|
|
- "Cannot read %d bytes of custom event data from offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Cannot read %d bytes of custom event data from offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
std::vector<uint8_t> Buffer;
|
|
std::vector<uint8_t> Buffer;
|
|
Buffer.resize(R.Size);
|
|
Buffer.resize(R.Size);
|
|
@@ -282,15 +293,15 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
if (E.getU8(&OffsetPtr, Buffer.data(), R.Size) != Buffer.data())
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading data into buffer of size %d at offset %d.", R.Size,
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ "Failed reading data into buffer of size %d at offset %" PRId64 ".",
|
|
|
|
+ R.Size, OffsetPtr);
|
|
|
|
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
assert(OffsetPtr >= PreReadOffset);
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
if (OffsetPtr - PreReadOffset != static_cast<uint32_t>(R.Size))
|
|
return createStringError(
|
|
return createStringError(
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
std::make_error_code(std::errc::invalid_argument),
|
|
- "Failed reading enough bytes for the typed event payload -- read %d "
|
|
|
|
- "expecting %d bytes at offset %d.",
|
|
|
|
|
|
+ "Failed reading enough bytes for the typed event payload -- read "
|
|
|
|
+ "%" PRId64 " expecting %d bytes at offset %" PRId64 ".",
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
OffsetPtr - PreReadOffset, R.Size, PreReadOffset);
|
|
|
|
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
R.Data.assign(Buffer.begin(), Buffer.end());
|
|
@@ -300,16 +311,17 @@ Error RecordInitializer::visit(TypedEventRecord &R) {
|
|
Error RecordInitializer::visit(CallArgRecord &R) {
|
|
Error RecordInitializer::visit(CallArgRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a call argument record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a call argument record (%" PRId64 ").",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.Arg = E.getU64(&OffsetPtr);
|
|
R.Arg = E.getU64(&OffsetPtr);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Cannot read a call arg record at offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Cannot read a call arg record at offset %" PRId64 ".", OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -318,16 +330,16 @@ Error RecordInitializer::visit(CallArgRecord &R) {
|
|
Error RecordInitializer::visit(PIDRecord &R) {
|
|
Error RecordInitializer::visit(PIDRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a process ID record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a process ID record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.PID = E.getSigned(&OffsetPtr, 4);
|
|
R.PID = E.getSigned(&OffsetPtr, 4);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Cannot read a process ID record at offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Cannot read a process ID record at offset %" PRId64 ".", OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -336,16 +348,16 @@ Error RecordInitializer::visit(PIDRecord &R) {
|
|
Error RecordInitializer::visit(NewBufferRecord &R) {
|
|
Error RecordInitializer::visit(NewBufferRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a new buffer record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a new buffer record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto PreReadOffset = OffsetPtr;
|
|
auto PreReadOffset = OffsetPtr;
|
|
R.TID = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
R.TID = E.getSigned(&OffsetPtr, sizeof(int32_t));
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Cannot read a new buffer record at offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Cannot read a new buffer record at offset %" PRId64 ".", OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize - (OffsetPtr - PreReadOffset);
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -354,9 +366,10 @@ Error RecordInitializer::visit(NewBufferRecord &R) {
|
|
Error RecordInitializer::visit(EndBufferRecord &R) {
|
|
Error RecordInitializer::visit(EndBufferRecord &R) {
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
if (!E.isValidOffsetForDataOfSize(OffsetPtr,
|
|
MetadataRecord::kMetadataBodySize))
|
|
MetadataRecord::kMetadataBodySize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for an end-of-buffer record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for an end-of-buffer record (%" PRId64 ").",
|
|
|
|
+ OffsetPtr);
|
|
|
|
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize;
|
|
OffsetPtr += MetadataRecord::kMetadataBodySize;
|
|
return Error::success();
|
|
return Error::success();
|
|
@@ -373,17 +386,17 @@ Error RecordInitializer::visit(FunctionRecord &R) {
|
|
//
|
|
//
|
|
if (OffsetPtr == 0 || !E.isValidOffsetForDataOfSize(
|
|
if (OffsetPtr == 0 || !E.isValidOffsetForDataOfSize(
|
|
--OffsetPtr, FunctionRecord::kFunctionRecordSize))
|
|
--OffsetPtr, FunctionRecord::kFunctionRecordSize))
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Invalid offset for a function record (%d).",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Invalid offset for a function record (%" PRId64 ").", OffsetPtr);
|
|
|
|
|
|
auto BeginOffset = OffsetPtr;
|
|
auto BeginOffset = OffsetPtr;
|
|
auto PreReadOffset = BeginOffset;
|
|
auto PreReadOffset = BeginOffset;
|
|
uint32_t Buffer = E.getU32(&OffsetPtr);
|
|
uint32_t Buffer = E.getU32(&OffsetPtr);
|
|
if (PreReadOffset == OffsetPtr)
|
|
if (PreReadOffset == OffsetPtr)
|
|
- return createStringError(std::make_error_code(std::errc::bad_address),
|
|
|
|
- "Cannot read function id field from offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::bad_address),
|
|
|
|
+ "Cannot read function id field from offset %" PRId64 ".", OffsetPtr);
|
|
|
|
|
|
// To get the function record type, we shift the buffer one to the right
|
|
// To get the function record type, we shift the buffer one to the right
|
|
// (truncating the function record indicator) then take the three bits
|
|
// (truncating the function record indicator) then take the three bits
|
|
@@ -397,18 +410,19 @@ Error RecordInitializer::visit(FunctionRecord &R) {
|
|
R.Kind = static_cast<RecordTypes>(FunctionType);
|
|
R.Kind = static_cast<RecordTypes>(FunctionType);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Unknown function record type '%d' at offset %d.",
|
|
|
|
- FunctionType, BeginOffset);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Unknown function record type '%d' at offset %" PRId64 ".",
|
|
|
|
+ FunctionType, BeginOffset);
|
|
}
|
|
}
|
|
|
|
|
|
R.FuncId = Buffer >> 4;
|
|
R.FuncId = Buffer >> 4;
|
|
PreReadOffset = OffsetPtr;
|
|
PreReadOffset = OffsetPtr;
|
|
R.Delta = E.getU32(&OffsetPtr);
|
|
R.Delta = E.getU32(&OffsetPtr);
|
|
if (OffsetPtr == PreReadOffset)
|
|
if (OffsetPtr == PreReadOffset)
|
|
- return createStringError(std::make_error_code(std::errc::invalid_argument),
|
|
|
|
- "Failed reading TSC delta from offset %d.",
|
|
|
|
- OffsetPtr);
|
|
|
|
|
|
+ return createStringError(
|
|
|
|
+ std::make_error_code(std::errc::invalid_argument),
|
|
|
|
+ "Failed reading TSC delta from offset %" PRId64 ".", OffsetPtr);
|
|
assert(FunctionRecord::kFunctionRecordSize == (OffsetPtr - BeginOffset));
|
|
assert(FunctionRecord::kFunctionRecordSize == (OffsetPtr - BeginOffset));
|
|
return Error::success();
|
|
return Error::success();
|
|
}
|
|
}
|