* Moved the TableColumn subclasses to TableColumns.{cpp,h}.
* Added Int32TableColumn and BigtimeTableColumn classes. * Evaluate the timestamps of the events that have one and maintain the fLastEventTime field, so we get estimated team/thread creation/deletion times. * Added some columns to the threads table (ID, creation and deletion time). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30343 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b623e81cf7
commit
9d7f0c336a
@ -11,6 +11,7 @@ Application DebugAnalyzer
|
||||
Model.cpp
|
||||
ModelLoader.cpp
|
||||
Table.cpp
|
||||
TableColumns.cpp
|
||||
ThreadsPage.cpp
|
||||
Variant.cpp
|
||||
|
||||
|
@ -21,6 +21,16 @@
|
||||
#include "Model.h"
|
||||
|
||||
|
||||
inline void
|
||||
ModelLoader::_UpdateLastEventTime(bigtime_t time)
|
||||
{
|
||||
if (fBaseTime < 0)
|
||||
fBaseTime = time;
|
||||
|
||||
fLastEventTime = time - fBaseTime;
|
||||
}
|
||||
|
||||
|
||||
ModelLoader::ModelLoader(DataSource* dataSource,
|
||||
const BMessenger& target, void* targetCookie)
|
||||
:
|
||||
@ -172,6 +182,7 @@ ModelLoader::_Load()
|
||||
return error;
|
||||
|
||||
// process the events
|
||||
fBaseTime = -1;
|
||||
fLastEventTime = -1;
|
||||
uint32 count = 0;
|
||||
|
||||
@ -284,7 +295,6 @@ ModelLoader::_ProcessEvent(uint32 event, uint32 cpu, const void* buffer,
|
||||
switch (event) {
|
||||
case B_SYSTEM_PROFILER_TEAM_ADDED:
|
||||
{
|
||||
//printf("B_SYSTEM_PROFILER_TEAM_ADDED: %lu\n", size);
|
||||
system_profiler_team_added* event
|
||||
= (system_profiler_team_added*)buffer;
|
||||
|
||||
@ -295,7 +305,6 @@ ModelLoader::_ProcessEvent(uint32 event, uint32 cpu, const void* buffer,
|
||||
|
||||
case B_SYSTEM_PROFILER_TEAM_REMOVED:
|
||||
{
|
||||
//printf("B_SYSTEM_PROFILER_TEAM_REMOVED: %lu\n", size);
|
||||
system_profiler_team_removed* event
|
||||
= (system_profiler_team_removed*)buffer;
|
||||
|
||||
@ -308,12 +317,10 @@ ModelLoader::_ProcessEvent(uint32 event, uint32 cpu, const void* buffer,
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_TEAM_EXEC:
|
||||
printf("B_SYSTEM_PROFILER_TEAM_EXEC: %lu\n", size);
|
||||
break;
|
||||
|
||||
case B_SYSTEM_PROFILER_THREAD_ADDED:
|
||||
{
|
||||
//printf("B_SYSTEM_PROFILER_THREAD_ADDED: %lu\n", size);
|
||||
system_profiler_thread_added* event
|
||||
= (system_profiler_thread_added*)buffer;
|
||||
|
||||
@ -325,7 +332,6 @@ printf("B_SYSTEM_PROFILER_TEAM_EXEC: %lu\n", size);
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_THREAD_REMOVED:
|
||||
//printf("B_SYSTEM_PROFILER_THREAD_REMOVED: %lu\n", size);
|
||||
{
|
||||
system_profiler_thread_removed* event
|
||||
= (system_profiler_thread_removed*)buffer;
|
||||
@ -339,16 +345,39 @@ printf("B_SYSTEM_PROFILER_TEAM_EXEC: %lu\n", size);
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_THREAD_SCHEDULED:
|
||||
printf("B_SYSTEM_PROFILER_THREAD_SCHEDULED: %lu\n", size);
|
||||
{
|
||||
system_profiler_thread_scheduled* event
|
||||
= (system_profiler_thread_scheduled*)buffer;
|
||||
|
||||
_UpdateLastEventTime(event->time);
|
||||
|
||||
// TODO:...
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE:
|
||||
printf("B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE: %lu\n", size);
|
||||
{
|
||||
system_profiler_thread_enqueued_in_run_queue* event
|
||||
= (system_profiler_thread_enqueued_in_run_queue*)buffer;
|
||||
|
||||
_UpdateLastEventTime(event->time);
|
||||
|
||||
// TODO:...
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE:
|
||||
printf("B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE: %lu\n", size);
|
||||
{
|
||||
system_profiler_thread_removed_from_run_queue* event
|
||||
= (system_profiler_thread_removed_from_run_queue*)buffer;
|
||||
|
||||
_UpdateLastEventTime(event->time);
|
||||
|
||||
// TODO:...
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SYSTEM_PROFILER_WAIT_OBJECT_INFO:
|
||||
printf("B_SYSTEM_PROFILER_WAIT_OBJECT_INFO: %lu\n", size);
|
||||
break;
|
||||
default:
|
||||
printf("unsupported event type %lu, size: %lu\n", event, size);
|
||||
|
@ -37,6 +37,8 @@ private:
|
||||
status_t _ProcessEvent(uint32 event, uint32 cpu,
|
||||
const void* buffer, size_t size);
|
||||
|
||||
inline void _UpdateLastEventTime(bigtime_t time);
|
||||
|
||||
private:
|
||||
BLocker fLock;
|
||||
Model* fModel;
|
||||
@ -46,6 +48,7 @@ private:
|
||||
thread_id fLoaderThread;
|
||||
bool fLoading;
|
||||
bool fAborted;
|
||||
bigtime_t fBaseTime;
|
||||
bigtime_t fLastEventTime;
|
||||
};
|
||||
|
||||
|
@ -137,90 +137,6 @@ TableColumn::GetPreferredWidth(BField* _field, BView* parent) const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - DelagateBasedTableColumn
|
||||
|
||||
|
||||
DelagateBasedTableColumn::DelagateBasedTableColumn(BColumn* columnDelegate,
|
||||
int32 modelIndex, float width, float minWidth, float maxWidth,
|
||||
alignment align)
|
||||
:
|
||||
TableColumn(modelIndex, width, minWidth, maxWidth, align),
|
||||
fColumnDelegate(columnDelegate)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DelagateBasedTableColumn::~DelagateBasedTableColumn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::DrawTitle(BRect rect, BView* targetView)
|
||||
{
|
||||
fColumnDelegate->DrawTitle(rect, targetView);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::GetColumnName(BString* into) const
|
||||
{
|
||||
fColumnDelegate->GetColumnName(into);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::DrawValue(const Variant& value, BRect rect,
|
||||
BView* targetView)
|
||||
{
|
||||
fColumnDelegate->DrawField(PrepareField(value), rect, targetView);
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
DelagateBasedTableColumn::GetPreferredValueWidth(const Variant& value,
|
||||
BView* parent) const
|
||||
{
|
||||
return fColumnDelegate->GetPreferredWidth(PrepareField(value), parent);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - StringTableColumn
|
||||
|
||||
|
||||
StringTableColumn::StringTableColumn(int32 modelIndex, const char* title,
|
||||
float width, float minWidth, float maxWidth, uint32 truncate,
|
||||
alignment align)
|
||||
:
|
||||
DelagateBasedTableColumn(&fColumn, modelIndex, width, minWidth, maxWidth,
|
||||
align),
|
||||
fColumn(title, width, minWidth, maxWidth, truncate, align),
|
||||
fField("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
StringTableColumn::~StringTableColumn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BField*
|
||||
StringTableColumn::PrepareField(const Variant& value) const
|
||||
{
|
||||
fField.SetString(value.ToString());
|
||||
fField.SetWidth(Width());
|
||||
return &fField;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
StringTableColumn::CompareValues(const Variant& a, const Variant& b)
|
||||
{
|
||||
return strcmp(a.ToString(), b.ToString());
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Table
|
||||
|
||||
|
||||
|
@ -66,52 +66,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class DelagateBasedTableColumn : public TableColumn {
|
||||
public:
|
||||
DelagateBasedTableColumn(
|
||||
BColumn* columnDelegate,
|
||||
int32 modelIndex, float width,
|
||||
float minWidth, float maxWidth,
|
||||
alignment align);
|
||||
virtual ~DelagateBasedTableColumn();
|
||||
|
||||
protected:
|
||||
virtual void DrawTitle(BRect rect, BView* targetView);
|
||||
virtual void GetColumnName(BString* into) const;
|
||||
|
||||
virtual void DrawValue(const Variant& value, BRect rect,
|
||||
BView* targetView);
|
||||
virtual float GetPreferredValueWidth(const Variant& value,
|
||||
BView* parent) const;
|
||||
|
||||
virtual BField* PrepareField(const Variant& value) const = 0;
|
||||
|
||||
protected:
|
||||
BColumn* fColumnDelegate;
|
||||
};
|
||||
|
||||
|
||||
class StringTableColumn : public DelagateBasedTableColumn {
|
||||
public:
|
||||
StringTableColumn(int32 modelIndex,
|
||||
const char* title, float width,
|
||||
float minWidth, float maxWidth,
|
||||
uint32 truncate,
|
||||
alignment align = B_ALIGN_LEFT);
|
||||
virtual ~StringTableColumn();
|
||||
|
||||
protected:
|
||||
virtual BField* PrepareField(const Variant& value) const;
|
||||
|
||||
virtual int CompareValues(const Variant& a,
|
||||
const Variant& b);
|
||||
|
||||
private:
|
||||
BStringColumn fColumn;
|
||||
mutable BStringField fField;
|
||||
};
|
||||
|
||||
|
||||
class Table : private BColumnListView {
|
||||
public:
|
||||
Table(const char* name, uint32 flags,
|
||||
@ -139,5 +93,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // TABLE_H
|
||||
|
178
src/apps/debuganalyzer/TableColumns.cpp
Normal file
178
src/apps/debuganalyzer/TableColumns.cpp
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "TableColumns.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// #pragma mark - DelagateBasedTableColumn
|
||||
|
||||
|
||||
DelagateBasedTableColumn::DelagateBasedTableColumn(BColumn* columnDelegate,
|
||||
int32 modelIndex, float width, float minWidth, float maxWidth,
|
||||
alignment align)
|
||||
:
|
||||
TableColumn(modelIndex, width, minWidth, maxWidth, align),
|
||||
fColumnDelegate(columnDelegate)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DelagateBasedTableColumn::~DelagateBasedTableColumn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::DrawTitle(BRect rect, BView* targetView)
|
||||
{
|
||||
fColumnDelegate->DrawTitle(rect, targetView);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::GetColumnName(BString* into) const
|
||||
{
|
||||
fColumnDelegate->GetColumnName(into);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DelagateBasedTableColumn::DrawValue(const Variant& value, BRect rect,
|
||||
BView* targetView)
|
||||
{
|
||||
fColumnDelegate->DrawField(PrepareField(value), rect, targetView);
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
DelagateBasedTableColumn::GetPreferredValueWidth(const Variant& value,
|
||||
BView* parent) const
|
||||
{
|
||||
return fColumnDelegate->GetPreferredWidth(PrepareField(value), parent);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - StringTableColumn
|
||||
|
||||
|
||||
StringTableColumn::StringTableColumn(int32 modelIndex, const char* title,
|
||||
float width, float minWidth, float maxWidth, uint32 truncate,
|
||||
alignment align)
|
||||
:
|
||||
DelagateBasedTableColumn(&fColumn, modelIndex, width, minWidth, maxWidth,
|
||||
align),
|
||||
fColumn(title, width, minWidth, maxWidth, truncate, align),
|
||||
fField("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
StringTableColumn::~StringTableColumn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BField*
|
||||
StringTableColumn::PrepareField(const Variant& value) const
|
||||
{
|
||||
fField.SetString(value.ToString());
|
||||
fField.SetWidth(Width());
|
||||
return &fField;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
StringTableColumn::CompareValues(const Variant& a, const Variant& b)
|
||||
{
|
||||
return strcasecmp(a.ToString(), b.ToString());
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Int32TableColumn
|
||||
|
||||
|
||||
Int32TableColumn::Int32TableColumn(int32 modelIndex, const char* title,
|
||||
float width, float minWidth, float maxWidth, uint32 truncate,
|
||||
alignment align)
|
||||
:
|
||||
StringTableColumn(modelIndex, title, width, minWidth, maxWidth, truncate,
|
||||
align)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BField*
|
||||
Int32TableColumn::PrepareField(const Variant& value) const
|
||||
{
|
||||
char buffer[16];
|
||||
snprintf(buffer, sizeof(buffer), "%ld", value.ToInt32());
|
||||
return StringTableColumn::PrepareField(
|
||||
Variant(buffer, VARIANT_DONT_COPY_DATA));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Int32TableColumn::CompareValues(const Variant& a, const Variant& b)
|
||||
{
|
||||
return a.ToInt32() - b.ToInt32();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BigtimeTableColumn
|
||||
|
||||
|
||||
BigtimeTableColumn::BigtimeTableColumn(int32 modelIndex, const char* title,
|
||||
float width, float minWidth, float maxWidth, bool invalidFirst,
|
||||
uint32 truncate, alignment align)
|
||||
:
|
||||
StringTableColumn(modelIndex, title, width, minWidth, maxWidth, truncate,
|
||||
align),
|
||||
fInvalidFirst(invalidFirst)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BField*
|
||||
BigtimeTableColumn::PrepareField(const Variant& value) const
|
||||
{
|
||||
bigtime_t time = value.ToInt64();
|
||||
if (time < 0) {
|
||||
return StringTableColumn::PrepareField(
|
||||
Variant("-", VARIANT_DONT_COPY_DATA));
|
||||
}
|
||||
|
||||
int micros = int(time % 1000000);
|
||||
time /= 1000000;
|
||||
int seconds = int(time % 60);
|
||||
time /= 60;
|
||||
int minutes = int(time % 60);
|
||||
time /= 60;
|
||||
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "%02lld:%02d:%02d:%06d", time, minutes,
|
||||
seconds, micros);
|
||||
return StringTableColumn::PrepareField(
|
||||
Variant(buffer, VARIANT_DONT_COPY_DATA));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
BigtimeTableColumn::CompareValues(const Variant& _a, const Variant& _b)
|
||||
{
|
||||
bigtime_t a = _a.ToInt64();
|
||||
bigtime_t b = _b.ToInt64();
|
||||
|
||||
if (a == b)
|
||||
return 0;
|
||||
|
||||
if (a < 0)
|
||||
return fInvalidFirst ? -1 : 1;
|
||||
if (b < 0)
|
||||
return fInvalidFirst ? 1 : -1;
|
||||
|
||||
return a - b < 0 ? -1 : 1;
|
||||
}
|
95
src/apps/debuganalyzer/TableColumns.h
Normal file
95
src/apps/debuganalyzer/TableColumns.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TABLE_COLUMNS_H
|
||||
#define TABLE_COLUMNS_H
|
||||
|
||||
#include <ColumnTypes.h>
|
||||
|
||||
#include "Table.h"
|
||||
|
||||
|
||||
class DelagateBasedTableColumn : public TableColumn {
|
||||
public:
|
||||
DelagateBasedTableColumn(
|
||||
BColumn* columnDelegate,
|
||||
int32 modelIndex, float width,
|
||||
float minWidth, float maxWidth,
|
||||
alignment align);
|
||||
virtual ~DelagateBasedTableColumn();
|
||||
|
||||
protected:
|
||||
virtual void DrawTitle(BRect rect, BView* targetView);
|
||||
virtual void GetColumnName(BString* into) const;
|
||||
|
||||
virtual void DrawValue(const Variant& value, BRect rect,
|
||||
BView* targetView);
|
||||
virtual float GetPreferredValueWidth(const Variant& value,
|
||||
BView* parent) const;
|
||||
|
||||
virtual BField* PrepareField(const Variant& value) const = 0;
|
||||
|
||||
protected:
|
||||
BColumn* fColumnDelegate;
|
||||
};
|
||||
|
||||
|
||||
class StringTableColumn : public DelagateBasedTableColumn {
|
||||
public:
|
||||
StringTableColumn(int32 modelIndex,
|
||||
const char* title, float width,
|
||||
float minWidth, float maxWidth,
|
||||
uint32 truncate,
|
||||
alignment align = B_ALIGN_LEFT);
|
||||
virtual ~StringTableColumn();
|
||||
|
||||
protected:
|
||||
virtual BField* PrepareField(const Variant& value) const;
|
||||
|
||||
virtual int CompareValues(const Variant& a,
|
||||
const Variant& b);
|
||||
|
||||
private:
|
||||
BStringColumn fColumn;
|
||||
mutable BStringField fField;
|
||||
};
|
||||
|
||||
|
||||
class Int32TableColumn : public StringTableColumn {
|
||||
public:
|
||||
Int32TableColumn(int32 modelIndex,
|
||||
const char* title, float width,
|
||||
float minWidth, float maxWidth,
|
||||
uint32 truncate = B_TRUNCATE_MIDDLE,
|
||||
alignment align = B_ALIGN_RIGHT);
|
||||
|
||||
protected:
|
||||
virtual BField* PrepareField(const Variant& value) const;
|
||||
|
||||
virtual int CompareValues(const Variant& a,
|
||||
const Variant& b);
|
||||
};
|
||||
|
||||
|
||||
class BigtimeTableColumn : public StringTableColumn {
|
||||
public:
|
||||
BigtimeTableColumn(int32 modelIndex,
|
||||
const char* title, float width,
|
||||
float minWidth, float maxWidth,
|
||||
bool invalidFirst,
|
||||
uint32 truncate = B_TRUNCATE_MIDDLE,
|
||||
alignment align = B_ALIGN_RIGHT);
|
||||
|
||||
protected:
|
||||
virtual BField* PrepareField(const Variant& value) const;
|
||||
|
||||
virtual int CompareValues(const Variant& a,
|
||||
const Variant& b);
|
||||
|
||||
private:
|
||||
bool fInvalidFirst;
|
||||
};
|
||||
|
||||
|
||||
#endif // TABLE_COLUMNS_H
|
@ -10,7 +10,7 @@
|
||||
#include <new>
|
||||
|
||||
#include "Model.h"
|
||||
#include "Table.h"
|
||||
#include "TableColumns.h"
|
||||
|
||||
|
||||
// #pragma mark - ThreadsTableModel
|
||||
@ -41,9 +41,18 @@ public:
|
||||
return false;
|
||||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
value.SetTo(thread->ID());
|
||||
return true;
|
||||
case 1:
|
||||
value.SetTo(thread->Name(), VARIANT_DONT_COPY_DATA);
|
||||
return true;
|
||||
case 2:
|
||||
value.SetTo(thread->CreationTime());
|
||||
return true;
|
||||
case 3:
|
||||
value.SetTo(thread->DeletionTime());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -70,10 +79,14 @@ ThreadsPage::ThreadsPage()
|
||||
fThreadsTable = new Table("threads list", 0);
|
||||
AddChild(fThreadsTable->ToView());
|
||||
|
||||
// fThreadsTable->AddColumn(new StringTableColumn(0, "Thread", 40, 20, 1000,
|
||||
// B_TRUNCATE_END, B_ALIGN_RIGHT));
|
||||
fThreadsTable->AddColumn(new Int32TableColumn(0, "Thread", 40, 20, 1000,
|
||||
B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT));
|
||||
fThreadsTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000,
|
||||
B_TRUNCATE_END, B_ALIGN_LEFT));
|
||||
fThreadsTable->AddColumn(new BigtimeTableColumn(2, "Creation", 80, 40, 1000,
|
||||
true, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT));
|
||||
fThreadsTable->AddColumn(new BigtimeTableColumn(3, "Deletion", 80, 40, 1000,
|
||||
false, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT));
|
||||
// fThreadsTable->AddColumn(new StringTableColumn(2, "Run Time", 80, 20, 1000,
|
||||
// B_TRUNCATE_END, B_ALIGN_RIGHT));
|
||||
// fThreadsTable->AddColumn(new StringTableColumn(3, "Wait Time", 80, 20, 1000,
|
||||
|
Loading…
Reference in New Issue
Block a user