* Moved KMessage field printing from vfs_boot.cpp::get_boot_partitions() into
KMessage::Dump(). * Improved message dump output a bit (more concise). * get_boot_partitions() now simply calls KMessage::Dump() instead. * Added a KMessage::IsEmpty() method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26365 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
66058774c8
commit
a120934388
@ -55,6 +55,7 @@ public:
|
|||||||
status_t FindField(const char *name, type_code type,
|
status_t FindField(const char *name, type_code type,
|
||||||
KMessageField *field) const;
|
KMessageField *field) const;
|
||||||
status_t GetNextField(KMessageField *field) const;
|
status_t GetNextField(KMessageField *field) const;
|
||||||
|
bool IsEmpty() const;
|
||||||
|
|
||||||
status_t AddData(const char *name, type_code type, const void *data,
|
status_t AddData(const char *name, type_code type, const void *data,
|
||||||
int32 numBytes, bool isFixedSize = true);
|
int32 numBytes, bool isFixedSize = true);
|
||||||
@ -135,7 +136,7 @@ public:
|
|||||||
status_t ReceiveFrom(port_id fromPort, bigtime_t timeout = -1,
|
status_t ReceiveFrom(port_id fromPort, bigtime_t timeout = -1,
|
||||||
port_message_info* messageInfo = NULL);
|
port_message_info* messageInfo = NULL);
|
||||||
|
|
||||||
void Dump(void (*printFunc)(const char*,...)) const;
|
void Dump(void (*printFunc)(const char*, ...)) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class KMessageField;
|
friend class KMessageField;
|
||||||
|
@ -290,53 +290,7 @@ get_boot_partitions(kernel_args *args, PartitionStack &partitions)
|
|||||||
const KMessage& bootVolume = args->boot_volume;
|
const KMessage& bootVolume = args->boot_volume;
|
||||||
|
|
||||||
dprintf("get_boot_partitions(): boot volume message:\n");
|
dprintf("get_boot_partitions(): boot volume message:\n");
|
||||||
KMessageField field;
|
bootVolume.Dump(&dprintf);
|
||||||
while (bootVolume.GetNextField(&field) == B_OK) {
|
|
||||||
type_code type = field.TypeCode();
|
|
||||||
uint32 bigEndianType = B_HOST_TO_BENDIAN_INT32(type);
|
|
||||||
dprintf("field: \"%s\", type: %.4s (0x%lx):\n", field.Name(),
|
|
||||||
(char*)&bigEndianType, type);
|
|
||||||
|
|
||||||
if (field.CountElements() == 0)
|
|
||||||
dprintf("\n");
|
|
||||||
|
|
||||||
int32 size;
|
|
||||||
for (int i = 0; const void* data = field.ElementAt(i, &size); i++) {
|
|
||||||
dprintf(" [%2d] ", i);
|
|
||||||
bool isIntType = false;
|
|
||||||
int64 intData = 0;
|
|
||||||
switch (type) {
|
|
||||||
case B_BOOL_TYPE:
|
|
||||||
dprintf("%s\n", (*(bool*)data ? "true" : "false"));
|
|
||||||
break;
|
|
||||||
case B_INT8_TYPE:
|
|
||||||
isIntType = true;
|
|
||||||
intData = *(int8*)data;
|
|
||||||
break;
|
|
||||||
case B_INT16_TYPE:
|
|
||||||
isIntType = true;
|
|
||||||
intData = *(int16*)data;
|
|
||||||
break;
|
|
||||||
case B_INT32_TYPE:
|
|
||||||
isIntType = true;
|
|
||||||
intData = *(int32*)data;
|
|
||||||
break;
|
|
||||||
case B_INT64_TYPE:
|
|
||||||
isIntType = true;
|
|
||||||
intData = *(int64*)data;
|
|
||||||
break;
|
|
||||||
case B_STRING_TYPE:
|
|
||||||
dprintf("\"%s\"\n", (char*)data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dprintf("data: \"%p\", %ld bytes\n", (char*)data, size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isIntType)
|
|
||||||
dprintf("%lld (0x%llx)\n", intData, intData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// create boot method
|
// create boot method
|
||||||
int32 bootMethodType = bootVolume.GetInt32(BOOT_METHOD,
|
int32 bootMethodType = bootVolume.GetInt32(BOOT_METHOD,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <ByteOrder.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
@ -300,6 +301,14 @@ KMessage::GetNextField(KMessageField *field) const
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
KMessage::IsEmpty() const
|
||||||
|
{
|
||||||
|
return _LastFieldHeader() == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// AddData
|
// AddData
|
||||||
status_t
|
status_t
|
||||||
KMessage::AddData(const char *name, type_code type, const void *data,
|
KMessage::AddData(const char *name, type_code type, const void *data,
|
||||||
@ -601,7 +610,7 @@ KMessage::ReceiveFrom(port_id fromPort, bigtime_t timeout,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KMessage::Dump(void (*printFunc)(const char*,...)) const
|
KMessage::Dump(void (*printFunc)(const char*, ...)) const
|
||||||
{
|
{
|
||||||
Header* header = _Header();
|
Header* header = _Header();
|
||||||
printFunc("KMessage: buffer: %p (size/capacity: %ld/%ld), flags: 0x0lx\n",
|
printFunc("KMessage: buffer: %p (size/capacity: %ld/%ld), flags: 0x0lx\n",
|
||||||
@ -610,10 +619,54 @@ KMessage::Dump(void (*printFunc)(const char*,...)) const
|
|||||||
KMessageField field;
|
KMessageField field;
|
||||||
while (GetNextField(&field) == B_OK) {
|
while (GetNextField(&field) == B_OK) {
|
||||||
type_code type = field.TypeCode();
|
type_code type = field.TypeCode();
|
||||||
int32 count = field.CountElements();
|
uint32 bigEndianType = B_HOST_TO_BENDIAN_INT32(type);
|
||||||
printFunc(" field: %-20s: type: 0x%lx ('%c%c%c%c'), %ld element%s\n",
|
int nameSpacing = 17 - strlen(field.Name());
|
||||||
field.Name(), type, (char)(type >> 24), (char)(type >> 16),
|
if (nameSpacing < 0)
|
||||||
(char)(type >> 8), (char)type, count, count == 1 ? "" : "s");
|
nameSpacing = 0;
|
||||||
|
|
||||||
|
printFunc(" field: \"%s\"%*s (%.4s): ", field.Name(), nameSpacing, "",
|
||||||
|
(char*)&bigEndianType);
|
||||||
|
|
||||||
|
if (field.CountElements() != 1)
|
||||||
|
printFunc("\n");
|
||||||
|
|
||||||
|
int32 size;
|
||||||
|
for (int i = 0; const void* data = field.ElementAt(i, &size); i++) {
|
||||||
|
if (field.CountElements() != 1)
|
||||||
|
printFunc(" [%2d] ", i);
|
||||||
|
|
||||||
|
bool isIntType = false;
|
||||||
|
int64 intData = 0;
|
||||||
|
switch (type) {
|
||||||
|
case B_BOOL_TYPE:
|
||||||
|
printFunc("%s\n", (*(bool*)data ? "true" : "false"));
|
||||||
|
break;
|
||||||
|
case B_INT8_TYPE:
|
||||||
|
isIntType = true;
|
||||||
|
intData = *(int8*)data;
|
||||||
|
break;
|
||||||
|
case B_INT16_TYPE:
|
||||||
|
isIntType = true;
|
||||||
|
intData = *(int16*)data;
|
||||||
|
break;
|
||||||
|
case B_INT32_TYPE:
|
||||||
|
isIntType = true;
|
||||||
|
intData = *(int32*)data;
|
||||||
|
break;
|
||||||
|
case B_INT64_TYPE:
|
||||||
|
isIntType = true;
|
||||||
|
intData = *(int64*)data;
|
||||||
|
break;
|
||||||
|
case B_STRING_TYPE:
|
||||||
|
printFunc("\"%s\"\n", (char*)data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printFunc("data at %p, %ld bytes\n", (char*)data, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isIntType)
|
||||||
|
printFunc("%lld (0x%llx)\n", intData, intData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user