2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef MAIN_MODEL_LOADER_H
6 #define MAIN_MODEL_LOADER_H
9 #include <util/DoublyLinkedList.h>
11 #include "AbstractModelLoader.h"
16 class BDebugEventInputStream
;
18 struct system_profiler_thread_added
;
21 class ModelLoader
: public AbstractModelLoader
{
23 ModelLoader(DataSource
* dataSource
,
24 const BMessenger
& target
,
34 virtual status_t
PrepareForLoading();
35 virtual status_t
Load();
36 virtual void FinishLoading(bool success
);
39 // shorthands for the longish structure names
40 typedef system_profiler_thread_enqueued_in_run_queue
41 thread_enqueued_in_run_queue
;
42 typedef system_profiler_thread_removed_from_run_queue
43 thread_removed_from_run_queue
;
44 typedef system_profiler_io_request_scheduled io_request_scheduled
;
45 typedef system_profiler_io_request_finished io_request_finished
;
46 typedef system_profiler_io_operation_started io_operation_started
;
47 typedef system_profiler_io_operation_finished io_operation_finished
;
52 struct IORequestHashDefinition
;
53 struct ExtendedThreadSchedulingState
;
54 struct ExtendedSchedulingState
;
56 typedef DoublyLinkedList
<ModelLoader::IOOperation
> IOOperationList
;
57 typedef DoublyLinkedList
<ModelLoader::IORequest
> IORequestList
;
58 typedef BOpenHashTable
<IORequestHashDefinition
> IORequestTable
;
62 status_t
_ReadDebugEvents(void** _eventData
,
64 status_t
_CreateDebugEventArray(void* eventData
,
66 system_profiler_event_header
**& _events
,
68 status_t
_ProcessEvent(uint32 event
, uint32 cpu
,
69 const void* buffer
, size_t size
);
70 bool _SetThreadEvents();
71 bool _SetThreadIORequests();
72 void _SetThreadIORequests(Model::Thread
* thread
,
73 Model::IORequest
** requests
,
76 inline void _UpdateLastEventTime(nanotime_t time
);
78 void _HandleTeamAdded(
79 system_profiler_team_added
* event
);
80 void _HandleTeamRemoved(
81 system_profiler_team_removed
* event
);
83 system_profiler_team_exec
* event
);
84 void _HandleThreadAdded(
85 system_profiler_thread_added
* event
);
86 void _HandleThreadRemoved(
87 system_profiler_thread_removed
* event
);
88 void _HandleThreadScheduled(uint32 cpu
,
89 system_profiler_thread_scheduled
* event
);
90 void _HandleThreadEnqueuedInRunQueue(
91 thread_enqueued_in_run_queue
* event
);
92 void _HandleThreadRemovedFromRunQueue(uint32 cpu
,
93 thread_removed_from_run_queue
* event
);
94 void _HandleWaitObjectInfo(
95 system_profiler_wait_object_info
* event
);
96 void _HandleIOSchedulerAdded(
97 system_profiler_io_scheduler_added
* event
);
98 void _HandleIORequestScheduled(
99 io_request_scheduled
* event
);
100 void _HandleIORequestFinished(
101 io_request_finished
* event
);
102 void _HandleIOOperationStarted(
103 io_operation_started
* event
);
104 void _HandleIOOperationFinished(
105 io_operation_finished
* event
);
107 ExtendedThreadSchedulingState
* _AddThread(
108 system_profiler_thread_added
* event
);
109 ExtendedThreadSchedulingState
* _AddUnknownThread(
111 Model::Team
* _AddUnknownTeam();
113 void _AddThreadWaitObject(
114 ExtendedThreadSchedulingState
* thread
,
115 uint32 type
, addr_t object
);
117 void _AddIdleTime(uint32 cpu
, nanotime_t time
);
121 DataSource
* fDataSource
;
123 nanotime_t fBaseTime
;
124 ExtendedSchedulingState
* fState
;
125 IORequestTable
* fIORequests
;
130 #endif // MAIN_MODEL_LOADER_H