vfs: check userland buffers before reading them.
[haiku.git] / src / kits / debugger / jobs / Jobs.h
blob1b3148bd2bb735c9e73de5477c9d195333a6242a
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2016, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef JOBS_H
7 #define JOBS_H
9 #include <Entry.h>
10 #include <String.h>
12 #include "ImageDebugInfoLoadingState.h"
13 #include "ImageDebugInfoProvider.h"
14 #include "Types.h"
15 #include "Worker.h"
18 class Architecture;
19 class BVariant;
20 class CpuState;
21 class DebuggerInterface;
22 class ExpressionInfo;
23 class ExpressionResult;
24 class Function;
25 class FunctionInstance;
26 class Image;
27 class SourceLanguage;
28 class StackFrame;
29 class StackFrameValues;
30 class Team;
31 class TeamMemory;
32 class TeamMemoryBlock;
33 class TeamTypeInformation;
34 class Thread;
35 class Type;
36 class TypeComponentPath;
37 class Value;
38 class ValueLocation;
39 class ValueNode;
40 class ValueNodeChild;
41 class ValueNodeContainer;
42 class ValueNodeManager;
43 class Variable;
46 // job types
47 enum {
48 JOB_TYPE_GET_THREAD_STATE,
49 JOB_TYPE_GET_CPU_STATE,
50 JOB_TYPE_GET_STACK_TRACE,
51 JOB_TYPE_LOAD_IMAGE_DEBUG_INFO,
52 JOB_TYPE_LOAD_SOURCE_CODE,
53 JOB_TYPE_GET_STACK_FRAME_VALUE,
54 JOB_TYPE_RESOLVE_VALUE_NODE_VALUE,
55 JOB_TYPE_WRITE_VALUE_NODE_VALUE,
56 JOB_TYPE_GET_MEMORY_BLOCK,
57 JOB_TYPE_WRITE_MEMORY,
58 JOB_TYPE_EVALUATE_EXPRESSION,
59 JOB_TYPE_WRITE_CORE_FILE
63 class GetThreadStateJob : public Job {
64 public:
65 GetThreadStateJob(
66 DebuggerInterface* debuggerInterface,
67 Thread* thread);
68 virtual ~GetThreadStateJob();
70 virtual const JobKey& Key() const;
71 virtual status_t Do();
73 private:
74 SimpleJobKey fKey;
75 DebuggerInterface* fDebuggerInterface;
76 Thread* fThread;
80 class GetCpuStateJob : public Job {
81 public:
82 GetCpuStateJob(
83 DebuggerInterface* debuggerInterface,
84 ::Thread* thread);
85 virtual ~GetCpuStateJob();
87 virtual const JobKey& Key() const;
88 virtual status_t Do();
90 private:
91 SimpleJobKey fKey;
92 DebuggerInterface* fDebuggerInterface;
93 ::Thread* fThread;
97 class GetStackTraceJob : public Job, private ImageDebugInfoProvider {
98 public:
99 GetStackTraceJob(
100 DebuggerInterface* debuggerInterface,
101 JobListener* jobListener,
102 Architecture* architecture,
103 ::Thread* thread);
104 virtual ~GetStackTraceJob();
106 virtual const JobKey& Key() const;
107 virtual status_t Do();
109 private:
110 // ImageDebugInfoProvider
111 virtual status_t GetImageDebugInfo(Image* image,
112 ImageDebugInfo*& _info);
114 private:
115 SimpleJobKey fKey;
116 DebuggerInterface* fDebuggerInterface;
117 JobListener* fJobListener;
118 Architecture* fArchitecture;
119 ::Thread* fThread;
120 CpuState* fCpuState;
124 class LoadImageDebugInfoJob : public Job {
125 public:
126 LoadImageDebugInfoJob(Image* image);
127 virtual ~LoadImageDebugInfoJob();
129 virtual const JobKey& Key() const;
130 virtual status_t Do();
132 static status_t ScheduleIfNecessary(Worker* worker,
133 Image* image,
134 JobListener* jobListener,
135 ImageDebugInfo** _imageDebugInfo = NULL);
136 // If already loaded returns a
137 // reference, if desired. If not loaded
138 // schedules a job, but does not wait;
139 // returns B_OK and NULL. An error,
140 // if scheduling the job failed, or the
141 // debug info already failed to load
142 // earlier.
144 ImageDebugInfoLoadingState*
145 GetLoadingState()
146 { return &fState; }
148 private:
149 SimpleJobKey fKey;
150 Image* fImage;
151 ImageDebugInfoLoadingState
152 fState;
156 class LoadSourceCodeJob : public Job {
157 public:
158 LoadSourceCodeJob(
159 DebuggerInterface* debuggerInterface,
160 Architecture* architecture, Team* team,
161 FunctionInstance* functionInstance,
162 bool loadForFunction);
163 virtual ~LoadSourceCodeJob();
165 virtual const JobKey& Key() const;
166 virtual status_t Do();
168 private:
169 SimpleJobKey fKey;
170 DebuggerInterface* fDebuggerInterface;
171 Architecture* fArchitecture;
172 Team* fTeam;
173 FunctionInstance* fFunctionInstance;
174 bool fLoadForFunction;
178 class ResolveValueNodeValueJob : public Job {
179 public:
180 ResolveValueNodeValueJob(
181 DebuggerInterface* debuggerInterface,
182 Architecture* architecture,
183 CpuState* cpuState,
184 TeamTypeInformation* typeInformation,
185 ValueNodeContainer* container,
186 ValueNode* valueNode);
187 virtual ~ResolveValueNodeValueJob();
189 virtual const JobKey& Key() const;
190 virtual status_t Do();
192 private:
193 status_t _ResolveNodeValue();
194 status_t _ResolveNodeChildLocation(
195 ValueNodeChild* nodeChild);
196 status_t _ResolveParentNodeValue(ValueNode* parentNode);
199 private:
200 SimpleJobKey fKey;
201 DebuggerInterface* fDebuggerInterface;
202 Architecture* fArchitecture;
203 CpuState* fCpuState;
204 TeamTypeInformation*
205 fTypeInformation;
206 ValueNodeContainer* fContainer;
207 ValueNode* fValueNode;
211 class WriteValueNodeValueJob : public Job {
212 public:
213 WriteValueNodeValueJob(
214 DebuggerInterface* debuggerInterface,
215 Architecture* architecture,
216 CpuState* cpuState,
217 TeamTypeInformation* typeInformation,
218 ValueNode* valueNode,
219 Value* newValue);
220 virtual ~WriteValueNodeValueJob();
222 virtual const JobKey& Key() const;
223 virtual status_t Do();
225 private:
226 SimpleJobKey fKey;
227 DebuggerInterface* fDebuggerInterface;
228 Architecture* fArchitecture;
229 CpuState* fCpuState;
230 TeamTypeInformation*
231 fTypeInformation;
232 ValueNode* fValueNode;
233 Value* fNewValue;
237 class RetrieveMemoryBlockJob : public Job {
238 public:
239 RetrieveMemoryBlockJob(Team* team,
240 TeamMemory* teamMemory,
241 TeamMemoryBlock* memoryBlock);
242 virtual ~RetrieveMemoryBlockJob();
244 virtual const JobKey& Key() const;
245 virtual status_t Do();
247 private:
248 SimpleJobKey fKey;
249 Team* fTeam;
250 TeamMemory* fTeamMemory;
251 TeamMemoryBlock* fMemoryBlock;
255 class WriteMemoryJob : public Job {
256 public:
257 WriteMemoryJob(Team* team,
258 TeamMemory* teamMemory,
259 target_addr_t address, void* data,
260 target_size_t size);
261 virtual ~WriteMemoryJob();
263 virtual const JobKey& Key() const;
264 virtual status_t Do();
266 private:
267 SimpleJobKey fKey;
268 Team* fTeam;
269 TeamMemory* fTeamMemory;
270 target_addr_t fTargetAddress;
271 void* fData;
272 target_size_t fSize;
276 class ExpressionEvaluationJob : public Job {
277 public:
278 ExpressionEvaluationJob(Team* team,
279 DebuggerInterface* debuggerInterface,
280 SourceLanguage* language,
281 ExpressionInfo* info,
282 StackFrame* frame,
283 Thread* thread);
284 virtual ~ExpressionEvaluationJob();
286 virtual const JobKey& Key() const;
287 virtual status_t Do();
289 ExpressionResult* GetResult() const { return fResultValue; }
291 private:
292 status_t ResolveNodeValue(ValueNode* node);
294 private:
295 SimpleJobKey fKey;
296 Team* fTeam;
297 DebuggerInterface* fDebuggerInterface;
298 Architecture* fArchitecture;
299 TeamTypeInformation* fTypeInformation;
300 SourceLanguage* fLanguage;
301 ExpressionInfo* fExpressionInfo;
302 StackFrame* fFrame;
303 Thread* fThread;
304 ValueNodeManager* fManager;
305 ExpressionResult* fResultValue;
309 class WriteCoreFileJob : public Job {
310 public:
311 WriteCoreFileJob(Team* team,
312 DebuggerInterface* debuggerInterface,
313 const entry_ref& targetPath);
314 virtual ~WriteCoreFileJob();
316 virtual const JobKey& Key() const;
317 virtual status_t Do();
319 private:
320 SimpleJobKey fKey;
321 Team* fTeam;
322 DebuggerInterface* fDebuggerInterface;
323 entry_ref fTargetPath;
327 #endif // JOBS_H