* Added a "reserved" field to the debug event file header to align it to 8

bytes.
* strlcpy() isn't a particularly good string compare function.
* BDebugEventInputStream::_GetData():
  - Also need to reset fBufferPosition to 0 when the buffer is empty.
  - Fixed read position.

BDebugEventInputStream does now actually read the files written by
BDebugEventOutputStream.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-04-19 23:44:20 +00:00
parent 1cdc2fb608
commit 4d8d8c1f38
2 changed files with 5 additions and 5 deletions

View File

@ -16,6 +16,7 @@ struct debug_event_stream_header {
uint32 version; uint32 version;
uint32 flags; uint32 flags;
uint32 event_mask; uint32 event_mask;
uint32 reserved;
}; };

View File

@ -75,7 +75,7 @@ BDebugEventInputStream::SetTo(BDataIO* stream)
} }
// check the header // check the header
if (strlcpy(header.signature, B_DEBUG_EVENT_STREAM_SIGNATURE, if (strncmp(header.signature, B_DEBUG_EVENT_STREAM_SIGNATURE,
sizeof(header.signature)) != 0 sizeof(header.signature)) != 0
|| header.version != B_DEBUG_EVENT_STREAM_VERSION || header.version != B_DEBUG_EVENT_STREAM_VERSION
|| (header.flags & B_DEBUG_EVENT_STREAM_FLAG_HOST_ENDIAN) == 0) { || (header.flags & B_DEBUG_EVENT_STREAM_FLAG_HOST_ENDIAN) == 0) {
@ -185,13 +185,12 @@ BDebugEventInputStream::_GetData(size_t size)
return B_BUFFER_OVERFLOW; return B_BUFFER_OVERFLOW;
// move remaining data to the start of the buffer // move remaining data to the start of the buffer
if (fBufferSize > 0 && fBufferPosition > 0) { if (fBufferSize > 0 && fBufferPosition > 0)
memmove(fBuffer, fBuffer + fBufferPosition, fBufferSize); memmove(fBuffer, fBuffer + fBufferPosition, fBufferSize);
fBufferPosition = 0; fBufferPosition = 0;
}
// read more data // read more data
ssize_t bytesRead = _Read(fBuffer + fBufferPosition, ssize_t bytesRead = _Read(fBuffer + fBufferSize,
fBufferCapacity - fBufferSize); fBufferCapacity - fBufferSize);
if (bytesRead < 0) if (bytesRead < 0)
return bytesRead; return bytesRead;