From 270b97c8ab4daa09ecd2284e65a8f651f5f60364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 10 May 2009 09:12:49 +0000 Subject: [PATCH] Added tracing facilities and more tracing in some error code paths. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30693 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/disk_device/DiskDevice.cpp | 26 ++++++++++++++-- src/kits/storage/disk_device/Partition.cpp | 22 +++++++++++-- .../storage/disk_device/PartitionDelegate.cpp | 31 ++++++++++++++----- 3 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/kits/storage/disk_device/DiskDevice.cpp b/src/kits/storage/disk_device/DiskDevice.cpp index 75dee71ef0..0d2634c134 100644 --- a/src/kits/storage/disk_device/DiskDevice.cpp +++ b/src/kits/storage/disk_device/DiskDevice.cpp @@ -29,6 +29,15 @@ #include "DiskSystemAddOnManager.h" +//#define TRACE_DISK_DEVICE +#undef TRACE +#ifdef TRACE_DISK_DEVICE +# define TRACE(x...) printf(x) +#else +# define TRACE(x...) do {} while (false) +#endif + + /*! \class BDiskDevice \brief A BDiskDevice object represents a storage device. */ @@ -241,17 +250,25 @@ BDiskDevice::IsModified() const status_t BDiskDevice::PrepareModifications() { + TRACE("%p->BDiskDevice::PrepareModifications()\n", this); + // check initialization status_t error = InitCheck(); - if (error != B_OK) + if (error != B_OK) { + TRACE(" InitCheck() failed\n"); return error; - if (fDelegate) + } + if (fDelegate) { + TRACE(" already prepared!\n"); return B_BAD_VALUE; + } // make sure the disk system add-ons are loaded error = DiskSystemAddOnManager::Default()->LoadDiskSystems(); - if (error != B_OK) + if (error != B_OK) { + TRACE(" failed to load disk systems\n"); return error; + } // recursively create the delegates error = _CreateDelegates(); @@ -259,9 +276,12 @@ BDiskDevice::PrepareModifications() // init them if (error == B_OK) error = _InitDelegates(); + else + TRACE(" failed to create delegates\n"); // delete all of them, if something went wrong if (error != B_OK) { + TRACE(" failed to init delegates\n"); _DeleteDelegates(); DiskSystemAddOnManager::Default()->UnloadDiskSystems(); } diff --git a/src/kits/storage/disk_device/Partition.cpp b/src/kits/storage/disk_device/Partition.cpp index 6a11404152..d35301fd4d 100644 --- a/src/kits/storage/disk_device/Partition.cpp +++ b/src/kits/storage/disk_device/Partition.cpp @@ -30,6 +30,15 @@ #include "PartitionDelegate.h" +//#define TRACE_PARTITION +#undef TRACE +#ifdef TRACE_PARTITION +# define TRACE(x...) printf(x) +#else +# define TRACE(x...) do {} while (false) +#endif + + using std::nothrow; @@ -1103,9 +1112,14 @@ BPartition::SetContentParameters(const char* parameters) status_t BPartition::GetNextSupportedType(int32 *cookie, BString* type) const { + TRACE("%p->BPartition::GetNextSupportedType(%ld)\n", this, *cookie); + BPartition* parent = Parent(); - if (!parent || !fDelegate) + if (!parent || !fDelegate) { + TRACE(" not prepared (parent: %p, fDelegate: %p)!\n", parent, + fDelegate); return B_NO_INIT; + } return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie, type); @@ -1116,8 +1130,12 @@ BPartition::GetNextSupportedType(int32 *cookie, BString* type) const status_t BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const { - if (!fDelegate) + TRACE("%p->BPartition::GetNextSupportedChildType(%ld)\n", this, *cookie); + + if (!fDelegate) { + TRACE(" not prepared!\n"); return B_NO_INIT; + } return fDelegate->GetNextSupportedChildType(NULL, cookie, type); } diff --git a/src/kits/storage/disk_device/PartitionDelegate.cpp b/src/kits/storage/disk_device/PartitionDelegate.cpp index bf41f86321..39eea05fd9 100644 --- a/src/kits/storage/disk_device/PartitionDelegate.cpp +++ b/src/kits/storage/disk_device/PartitionDelegate.cpp @@ -5,14 +5,20 @@ #include "PartitionDelegate.h" +#include + #include #include "DiskSystemAddOnManager.h" +//#define TRACE_PARTITION_DELEGATE #undef TRACE -#define TRACE(format...) -//#define TRACE(format...) printf(format) +#ifdef TRACE_PARTITION_DELEGATE +# define TRACE(x...) printf(x) +#else +# define TRACE(x...) do {} while (false) +#endif // constructor @@ -61,24 +67,28 @@ BPartition::Delegate::InitHierarchy( status_t BPartition::Delegate::InitAfterHierarchy() { - if (!fMutablePartition.ContentType()) + TRACE("%p->BPartition::Delegate::InitAfterHierarchy()\n", this); + + if (!fMutablePartition.ContentType()) { + TRACE(" no content type\n"); return B_OK; + } // init disk system and handle DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default(); BDiskSystemAddOn* addOn = manager->GetAddOn( fMutablePartition.ContentType()); if (!addOn) { - TRACE("BPartition::Delegate::InitAfterHierarchy(): add-on for disk " - "system \"%s\" not found\n", fMutablePartition.ContentType()); + TRACE(" add-on for disk system \"%s\" not found\n", + fMutablePartition.ContentType()); return B_OK; } BPartitionHandle* handle; status_t error = addOn->CreatePartitionHandle(&fMutablePartition, &handle); if (error != B_OK) { - TRACE("BPartition::Delegate::InitAfterHierarchy(): Failed to create " - "partition handle for partition %ld, disk system: \"%s\": %s\n", + TRACE(" failed to create partition handle for partition %ld, disk " + "system: \"%s\": %s\n", Partition()->ID(), addOn->Name(), strerror(error)); manager->PutAddOn(addOn); return error; @@ -379,8 +389,13 @@ status_t BPartition::Delegate::GetNextSupportedChildType(Delegate* child, int32 *cookie, BString* type) const { - if (!fPartitionHandle) + TRACE("%p->BPartition::Delegate::GetNextSupportedChildType(child: %p, " + "cookie: %ld)\n", this, child, *cookie); + + if (!fPartitionHandle) { + TRACE(" no partition handle!\n"); return B_NO_INIT; + } return fPartitionHandle->GetNextSupportedType( child ? &child->fMutablePartition : NULL, cookie, type);