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"
//#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();
}

View File

@ -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);
}

View File

@ -5,14 +5,20 @@
#include "PartitionDelegate.h"
#include <stdio.h>
#include <DiskSystemAddOn.h>
#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);