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
This commit is contained in:
Stephan Aßmus 2009-05-10 09:12:49 +00:00
parent 874f5afe32
commit 270b97c8ab
3 changed files with 66 additions and 13 deletions

View File

@ -29,6 +29,15 @@
#include "DiskSystemAddOnManager.h" #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 /*! \class BDiskDevice
\brief A BDiskDevice object represents a storage device. \brief A BDiskDevice object represents a storage device.
*/ */
@ -241,17 +250,25 @@ BDiskDevice::IsModified() const
status_t status_t
BDiskDevice::PrepareModifications() BDiskDevice::PrepareModifications()
{ {
TRACE("%p->BDiskDevice::PrepareModifications()\n", this);
// check initialization // check initialization
status_t error = InitCheck(); status_t error = InitCheck();
if (error != B_OK) if (error != B_OK) {
TRACE(" InitCheck() failed\n");
return error; return error;
if (fDelegate) }
if (fDelegate) {
TRACE(" already prepared!\n");
return B_BAD_VALUE; return B_BAD_VALUE;
}
// make sure the disk system add-ons are loaded // make sure the disk system add-ons are loaded
error = DiskSystemAddOnManager::Default()->LoadDiskSystems(); error = DiskSystemAddOnManager::Default()->LoadDiskSystems();
if (error != B_OK) if (error != B_OK) {
TRACE(" failed to load disk systems\n");
return error; return error;
}
// recursively create the delegates // recursively create the delegates
error = _CreateDelegates(); error = _CreateDelegates();
@ -259,9 +276,12 @@ BDiskDevice::PrepareModifications()
// init them // init them
if (error == B_OK) if (error == B_OK)
error = _InitDelegates(); error = _InitDelegates();
else
TRACE(" failed to create delegates\n");
// delete all of them, if something went wrong // delete all of them, if something went wrong
if (error != B_OK) { if (error != B_OK) {
TRACE(" failed to init delegates\n");
_DeleteDelegates(); _DeleteDelegates();
DiskSystemAddOnManager::Default()->UnloadDiskSystems(); DiskSystemAddOnManager::Default()->UnloadDiskSystems();
} }

View File

@ -30,6 +30,15 @@
#include "PartitionDelegate.h" #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; using std::nothrow;
@ -1103,9 +1112,14 @@ BPartition::SetContentParameters(const char* parameters)
status_t status_t
BPartition::GetNextSupportedType(int32 *cookie, BString* type) const BPartition::GetNextSupportedType(int32 *cookie, BString* type) const
{ {
TRACE("%p->BPartition::GetNextSupportedType(%ld)\n", this, *cookie);
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate) {
TRACE(" not prepared (parent: %p, fDelegate: %p)!\n", parent,
fDelegate);
return B_NO_INIT; return B_NO_INIT;
}
return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie, return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie,
type); type);
@ -1116,8 +1130,12 @@ BPartition::GetNextSupportedType(int32 *cookie, BString* type) const
status_t status_t
BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const 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 B_NO_INIT;
}
return fDelegate->GetNextSupportedChildType(NULL, cookie, type); return fDelegate->GetNextSupportedChildType(NULL, cookie, type);
} }

View File

@ -5,14 +5,20 @@
#include "PartitionDelegate.h" #include "PartitionDelegate.h"
#include <stdio.h>
#include <DiskSystemAddOn.h> #include <DiskSystemAddOn.h>
#include "DiskSystemAddOnManager.h" #include "DiskSystemAddOnManager.h"
//#define TRACE_PARTITION_DELEGATE
#undef TRACE #undef TRACE
#define TRACE(format...) #ifdef TRACE_PARTITION_DELEGATE
//#define TRACE(format...) printf(format) # define TRACE(x...) printf(x)
#else
# define TRACE(x...) do {} while (false)
#endif
// constructor // constructor
@ -61,24 +67,28 @@ BPartition::Delegate::InitHierarchy(
status_t status_t
BPartition::Delegate::InitAfterHierarchy() BPartition::Delegate::InitAfterHierarchy()
{ {
if (!fMutablePartition.ContentType()) TRACE("%p->BPartition::Delegate::InitAfterHierarchy()\n", this);
if (!fMutablePartition.ContentType()) {
TRACE(" no content type\n");
return B_OK; return B_OK;
}
// init disk system and handle // init disk system and handle
DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default(); DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default();
BDiskSystemAddOn* addOn = manager->GetAddOn( BDiskSystemAddOn* addOn = manager->GetAddOn(
fMutablePartition.ContentType()); fMutablePartition.ContentType());
if (!addOn) { if (!addOn) {
TRACE("BPartition::Delegate::InitAfterHierarchy(): add-on for disk " TRACE(" add-on for disk system \"%s\" not found\n",
"system \"%s\" not found\n", fMutablePartition.ContentType()); fMutablePartition.ContentType());
return B_OK; return B_OK;
} }
BPartitionHandle* handle; BPartitionHandle* handle;
status_t error = addOn->CreatePartitionHandle(&fMutablePartition, &handle); status_t error = addOn->CreatePartitionHandle(&fMutablePartition, &handle);
if (error != B_OK) { if (error != B_OK) {
TRACE("BPartition::Delegate::InitAfterHierarchy(): Failed to create " TRACE(" failed to create partition handle for partition %ld, disk "
"partition handle for partition %ld, disk system: \"%s\": %s\n", "system: \"%s\": %s\n",
Partition()->ID(), addOn->Name(), strerror(error)); Partition()->ID(), addOn->Name(), strerror(error));
manager->PutAddOn(addOn); manager->PutAddOn(addOn);
return error; return error;
@ -379,8 +389,13 @@ status_t
BPartition::Delegate::GetNextSupportedChildType(Delegate* child, int32 *cookie, BPartition::Delegate::GetNextSupportedChildType(Delegate* child, int32 *cookie,
BString* type) const 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 B_NO_INIT;
}
return fPartitionHandle->GetNextSupportedType( return fPartitionHandle->GetNextSupportedType(
child ? &child->fMutablePartition : NULL, cookie, type); child ? &child->fMutablePartition : NULL, cookie, type);