Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: src/trusted/port/thread.h

Issue 10365028: Debug stub: associate NaClAppThread with IThread (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: rebased Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/gdb_rsp/test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 7
8 // This module defines the interface for interacting with platform specific 8 // This module defines the interface for interacting with platform specific
9 // threads . This API provides a mechanism to query for a thread, by using 9 // threads . This API provides a mechanism to query for a thread, by using
10 // the acquire method with the ID of a pre-existing thread. The register 10 // the acquire method with the ID of a pre-existing thread. The register
11 // accessors are expected to return false if the thread is not in a state 11 // accessors are expected to return false if the thread is not in a state
12 // where the registers can be accessed, such RUNNING or SYSCALL. This API 12 // where the registers can be accessed, such RUNNING or SYSCALL. This API
13 // will throw: 13 // will throw:
14 // std::exception - if a unexpected OS Error is encountered. 14 // std::exception - if a unexpected OS Error is encountered.
15 // std::out_of_range - if the register index is out of range. 15 // std::out_of_range - if the register index is out of range.
16 16
17 #ifndef NATIVE_CLIENT_PORT_THREAD_H_ 17 #ifndef NATIVE_CLIENT_PORT_THREAD_H_
18 #define NATIVE_CLIENT_PORT_THREAD_H_ 1 18 #define NATIVE_CLIENT_PORT_THREAD_H_ 1
19 19
20 #include <stdlib.h> 20 #include <stdlib.h>
21 #include <map> 21 #include <map>
22 22
23 #include "native_client/src/trusted/port/std_types.h" 23 #include "native_client/src/trusted/port/std_types.h"
24 24
25 struct NaClAppThread;
26
25 namespace port { 27 namespace port {
26 28
27 class IThread { 29 class IThread {
28 public: 30 public:
29 enum State { 31 enum State {
30 DEAD =-1, // The thread has exited or been killed 32 DEAD =-1, // The thread has exited or been killed
31 RUNNING = 0, // The thread is currently running 33 RUNNING = 0, // The thread is currently running
32 SUSPENDED= 1, // The thread has been suspended 34 SUSPENDED= 1, // The thread has been suspended
33 SIGNALED = 2, // The thread is signaled 35 SIGNALED = 2, // The thread is signaled
34 SYSCALL = 3 // In a sys call, it's registers can not be modified. 36 SYSCALL = 3 // In a sys call, it's registers can not be modified.
35 }; 37 };
36 38
37 typedef void (*CatchFunc_t)(uint32_t id, int8_t sig, void *cookie); 39 typedef void (*CatchFunc_t)(uint32_t id, int8_t sig, void *cookie);
38 typedef std::map<uint32_t, IThread*> ThreadMap_t; 40 typedef std::map<uint32_t, IThread*> ThreadMap_t;
39 41
40 virtual uint32_t GetId() = 0; 42 virtual uint32_t GetId() = 0;
41 virtual State GetState() = 0; 43 virtual State GetState() = 0;
42 44
43 virtual bool SetStep(bool on) = 0; 45 virtual bool SetStep(bool on) = 0;
44 46
45 virtual bool GetRegister(uint32_t index, void *dst, uint32_t len) = 0; 47 virtual bool GetRegister(uint32_t index, void *dst, uint32_t len) = 0;
46 virtual bool SetRegister(uint32_t index, void *src, uint32_t len) = 0; 48 virtual bool SetRegister(uint32_t index, void *src, uint32_t len) = 0;
47 49
48 virtual bool Suspend() = 0; 50 virtual bool Suspend() = 0;
49 virtual bool Resume() = 0; 51 virtual bool Resume() = 0;
50 52
51 virtual void *GetContext() = 0; 53 virtual void *GetContext() = 0;
52 54
53 static IThread *Acquire(uint32_t id, bool create = true); 55 static IThread *Create(uint32_t id, struct NaClAppThread *natp);
56 static IThread *Acquire(uint32_t id);
54 static void Release(IThread *thread); 57 static void Release(IThread *thread);
55 static void SetExceptionCatch(CatchFunc_t func, void *cookie); 58 static void SetExceptionCatch(CatchFunc_t func, void *cookie);
56 59
57 protected: 60 protected:
58 virtual ~IThread() {} // Prevent delete of base pointer 61 virtual ~IThread() {} // Prevent delete of base pointer
59 }; 62 };
60 63
61 } // namespace port 64 } // namespace port
62 65
63 #endif // PORT_THREAD_H_ 66 #endif // PORT_THREAD_H_
64 67
OLDNEW
« no previous file with comments | « src/trusted/gdb_rsp/test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698