Added optional BDebugEventStream::ReadNextEvent() return parameter for the
stream position of the event header. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30504 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,7 +45,8 @@ public:
|
|||||||
void Unset();
|
void Unset();
|
||||||
|
|
||||||
ssize_t ReadNextEvent(uint32* _event, uint32* _cpu,
|
ssize_t ReadNextEvent(uint32* _event, uint32* _cpu,
|
||||||
const void** _buffer);
|
const void** _buffer,
|
||||||
|
off_t* _streamOffset = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _Init();
|
status_t _Init();
|
||||||
@@ -60,6 +61,7 @@ private:
|
|||||||
size_t fBufferCapacity;
|
size_t fBufferCapacity;
|
||||||
size_t fBufferSize;
|
size_t fBufferSize;
|
||||||
size_t fBufferPosition;
|
size_t fBufferPosition;
|
||||||
|
off_t fStreamPosition;
|
||||||
bool fOwnsBuffer;
|
bool fOwnsBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ BDebugEventInputStream::BDebugEventInputStream()
|
|||||||
fBufferCapacity(0),
|
fBufferCapacity(0),
|
||||||
fBufferSize(0),
|
fBufferSize(0),
|
||||||
fBufferPosition(0),
|
fBufferPosition(0),
|
||||||
|
fStreamPosition(0),
|
||||||
fOwnsBuffer(false)
|
fOwnsBuffer(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -127,12 +128,15 @@ BDebugEventInputStream::Unset()
|
|||||||
be stored.
|
be stored.
|
||||||
\param _buffer Pointer to a pre-allocated location where the pointer to the
|
\param _buffer Pointer to a pre-allocated location where the pointer to the
|
||||||
event data shall be stored.
|
event data shall be stored.
|
||||||
|
\param _streamOffset Pointer to a pre-allocated location where the event
|
||||||
|
header's offset relative to the beginning of the stream shall be stored.
|
||||||
|
May be \c NULL.
|
||||||
\return A negative error code in case an error occurred while trying to read
|
\return A negative error code in case an error occurred while trying to read
|
||||||
the info, the size of the data associated with the event otherwise.
|
the info, the size of the data associated with the event otherwise.
|
||||||
*/
|
*/
|
||||||
ssize_t
|
ssize_t
|
||||||
BDebugEventInputStream::ReadNextEvent(uint32* _event, uint32* _cpu,
|
BDebugEventInputStream::ReadNextEvent(uint32* _event, uint32* _cpu,
|
||||||
const void** _buffer)
|
const void** _buffer, off_t* _streamOffset)
|
||||||
{
|
{
|
||||||
// get the next header
|
// get the next header
|
||||||
status_t error = _GetData(sizeof(system_profiler_event_header));
|
status_t error = _GetData(sizeof(system_profiler_event_header));
|
||||||
@@ -147,6 +151,8 @@ BDebugEventInputStream::ReadNextEvent(uint32* _event, uint32* _cpu,
|
|||||||
system_profiler_event_header header
|
system_profiler_event_header header
|
||||||
= *(system_profiler_event_header*)(fBuffer + fBufferPosition);
|
= *(system_profiler_event_header*)(fBuffer + fBufferPosition);
|
||||||
|
|
||||||
|
off_t streamOffset = fStreamPosition + fBufferPosition;
|
||||||
|
|
||||||
// skip the header in the buffer
|
// skip the header in the buffer
|
||||||
fBufferSize -= sizeof(system_profiler_event_header);
|
fBufferSize -= sizeof(system_profiler_event_header);
|
||||||
fBufferPosition += sizeof(system_profiler_event_header);
|
fBufferPosition += sizeof(system_profiler_event_header);
|
||||||
@@ -161,6 +167,8 @@ BDebugEventInputStream::ReadNextEvent(uint32* _event, uint32* _cpu,
|
|||||||
*_event = header.event;
|
*_event = header.event;
|
||||||
*_cpu = header.cpu;
|
*_cpu = header.cpu;
|
||||||
*_buffer = fBuffer + fBufferPosition;
|
*_buffer = fBuffer + fBufferPosition;
|
||||||
|
if (_streamOffset)
|
||||||
|
*_streamOffset = streamOffset;
|
||||||
|
|
||||||
// skip the event in the buffer
|
// skip the event in the buffer
|
||||||
fBufferSize -= header.size;
|
fBufferSize -= header.size;
|
||||||
@@ -173,6 +181,7 @@ BDebugEventInputStream::ReadNextEvent(uint32* _event, uint32* _cpu,
|
|||||||
status_t
|
status_t
|
||||||
BDebugEventInputStream::_Init()
|
BDebugEventInputStream::_Init()
|
||||||
{
|
{
|
||||||
|
fStreamPosition = 0;
|
||||||
fBufferPosition = 0;
|
fBufferPosition = 0;
|
||||||
|
|
||||||
// get the header
|
// get the header
|
||||||
@@ -236,6 +245,7 @@ BDebugEventInputStream::_GetData(size_t size)
|
|||||||
// 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);
|
||||||
|
fStreamPosition += fBufferPosition;
|
||||||
fBufferPosition = 0;
|
fBufferPosition = 0;
|
||||||
|
|
||||||
// read more data
|
// read more data
|
||||||
|
|||||||
Reference in New Issue
Block a user