BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / debuganalyzer / model_loader / ModelLoader.h
blob877320eab12660d607fabe7b9af987d68e2077c1
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef MAIN_MODEL_LOADER_H
6 #define MAIN_MODEL_LOADER_H
9 #include <util/DoublyLinkedList.h>
11 #include "AbstractModelLoader.h"
12 #include "Model.h"
15 class BDataIO;
16 class BDebugEventInputStream;
17 class DataSource;
18 struct system_profiler_thread_added;
21 class ModelLoader : public AbstractModelLoader {
22 public:
23 ModelLoader(DataSource* dataSource,
24 const BMessenger& target,
25 void* targetCookie);
27 protected:
28 ~ModelLoader();
30 public:
31 Model* DetachModel();
33 protected:
34 virtual status_t PrepareForLoading();
35 virtual status_t Load();
36 virtual void FinishLoading(bool success);
38 private:
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;
49 struct CPUInfo;
50 struct IOOperation;
51 struct IORequest;
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;
60 private:
61 status_t _Load();
62 status_t _ReadDebugEvents(void** _eventData,
63 size_t* _size);
64 status_t _CreateDebugEventArray(void* eventData,
65 size_t eventDataSize,
66 system_profiler_event_header**& _events,
67 size_t& _eventCount);
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,
74 size_t requestCount);
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);
82 void _HandleTeamExec(
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(
110 thread_id threadID);
111 Model::Team* _AddUnknownTeam();
113 void _AddThreadWaitObject(
114 ExtendedThreadSchedulingState* thread,
115 uint32 type, addr_t object);
117 void _AddIdleTime(uint32 cpu, nanotime_t time);
119 private:
120 Model* fModel;
121 DataSource* fDataSource;
122 CPUInfo* fCPUInfos;
123 nanotime_t fBaseTime;
124 ExtendedSchedulingState* fState;
125 IORequestTable* fIORequests;
126 uint32 fMaxCPUIndex;
130 #endif // MAIN_MODEL_LOADER_H