* 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,
|
||||
KMessageField *field) const;
|
||||
status_t GetNextField(KMessageField *field) const;
|
||||
bool IsEmpty() const;
|
||||
|
||||
status_t AddData(const char *name, type_code type, const void *data,
|
||||
int32 numBytes, bool isFixedSize = true);
|
||||
@ -135,7 +136,7 @@ public:
|
||||
status_t ReceiveFrom(port_id fromPort, bigtime_t timeout = -1,
|
||||
port_message_info* messageInfo = NULL);
|
||||
|
||||
void Dump(void (*printFunc)(const char*,...)) const;
|
||||
void Dump(void (*printFunc)(const char*, ...)) const;
|
||||
|
||||
private:
|
||||
friend class KMessageField;
|
||||
|
@ -85,7 +85,7 @@ compare_image_boot(const void *_a, const void *_b)
|
||||
if (!strncmp(b->ContentName(), "System", 6))
|
||||
return -1;
|
||||
|
||||
return compare;
|
||||
return compare;
|
||||
}
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ DiskBootMethod::SortPartitions(KPartition** partitions, int32 count)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
/*! Make the boot partition (and probably others) available.
|
||||
/*! Make the boot partition (and probably others) available.
|
||||
The partitions that are a boot candidate a put into the /a partitions
|
||||
stack. If the user selected a boot device, there is will only be one
|
||||
entry in this stack; if not, the most likely is put up first.
|
||||
@ -290,53 +290,7 @@ get_boot_partitions(kernel_args *args, PartitionStack &partitions)
|
||||
const KMessage& bootVolume = args->boot_volume;
|
||||
|
||||
dprintf("get_boot_partitions(): boot volume message:\n");
|
||||
KMessageField field;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
bootVolume.Dump(&dprintf);
|
||||
|
||||
// create boot method
|
||||
int32 bootMethodType = bootVolume.GetInt32(BOOT_METHOD,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <Debug.h>
|
||||
#include <KernelExport.h>
|
||||
#include <TypeConstants.h>
|
||||
@ -300,6 +301,14 @@ KMessage::GetNextField(KMessageField *field) const
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
KMessage::IsEmpty() const
|
||||
{
|
||||
return _LastFieldHeader() == NULL;
|
||||
}
|
||||
|
||||
|
||||
// AddData
|
||||
status_t
|
||||
KMessage::AddData(const char *name, type_code type, const void *data,
|
||||
@ -601,7 +610,7 @@ KMessage::ReceiveFrom(port_id fromPort, bigtime_t timeout,
|
||||
|
||||
|
||||
void
|
||||
KMessage::Dump(void (*printFunc)(const char*,...)) const
|
||||
KMessage::Dump(void (*printFunc)(const char*, ...)) const
|
||||
{
|
||||
Header* header = _Header();
|
||||
printFunc("KMessage: buffer: %p (size/capacity: %ld/%ld), flags: 0x0lx\n",
|
||||
@ -610,10 +619,54 @@ KMessage::Dump(void (*printFunc)(const char*,...)) const
|
||||
KMessageField field;
|
||||
while (GetNextField(&field) == B_OK) {
|
||||
type_code type = field.TypeCode();
|
||||
int32 count = field.CountElements();
|
||||
printFunc(" field: %-20s: type: 0x%lx ('%c%c%c%c'), %ld element%s\n",
|
||||
field.Name(), type, (char)(type >> 24), (char)(type >> 16),
|
||||
(char)(type >> 8), (char)type, count, count == 1 ? "" : "s");
|
||||
uint32 bigEndianType = B_HOST_TO_BENDIAN_INT32(type);
|
||||
int nameSpacing = 17 - strlen(field.Name());
|
||||
if (nameSpacing < 0)
|
||||
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