haiku/headers/private/debug/DebugEventStream.h
Ingo Weinhold 4d8d8c1f38 * 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
2009-04-19 23:44:20 +00:00

82 lines
1.5 KiB
C++

/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _DEBUG_EVENT_STREAM_H
#define _DEBUG_EVENT_STREAM_H
#include <SupportDefs.h>
class BDataIO;
struct debug_event_stream_header {
char signature[32];
uint32 version;
uint32 flags;
uint32 event_mask;
uint32 reserved;
};
// signature and version
#define B_DEBUG_EVENT_STREAM_SIGNATURE "Haiku debug events"
#define B_DEBUG_EVENT_STREAM_VERSION 1
// flags
enum {
B_DEBUG_EVENT_STREAM_FLAG_HOST_ENDIAN = 0x00000001,
B_DEBUG_EVENT_STREAM_FLAG_SWAPPED_ENDIAN = 0x01000000,
B_DEBUG_EVENT_STREAM_FLAG_ZIPPED = 0x00000002
};
class BDebugEventInputStream {
public:
BDebugEventInputStream();
~BDebugEventInputStream();
status_t SetTo(BDataIO* stream);
void Unset();
ssize_t ReadNextEvent(uint32* _event, uint32* _cpu,
const void** _buffer);
private:
ssize_t _Read(void* buffer, size_t size);
status_t _GetData(size_t size);
private:
BDataIO* fStream;
uint32 fFlags;
uint32 fEventMask;
uint8* fBuffer;
size_t fBufferCapacity;
size_t fBufferSize;
size_t fBufferPosition;
};
class BDebugEventOutputStream {
public:
BDebugEventOutputStream();
~BDebugEventOutputStream();
status_t SetTo(BDataIO* stream, uint32 flags,
uint32 eventMask);
void Unset();
status_t Write(const void* buffer, size_t size);
status_t Flush();
private:
BDataIO* fStream;
uint32 fFlags;
};
#endif // _DEBUG_EVENT_STREAM_H