OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 #ifndef DEBUGGER_CORE_DEBUG_BREAKPOINT_H_ | |
5 #define DEBUGGER_CORE_DEBUG_BREAKPOINT_H_ | |
6 | |
7 namespace debug { | |
8 class IDebuggeeProcess; | |
9 | |
10 /// This class represents a physical breakpoint. | |
11 | |
12 /// Breakpoint is identified by flat address in debuggee process. | |
13 /// Breakpoint is implemented by writing 'int 3' (0xCC) in the specified | |
14 /// location in debuggee memory. | |
15 /// | |
16 /// Class diagram (and more) is here: | |
17 /// https://docs.google.com/a/google.com/document/d/1lTN-IYqDd_oy9XQg9-zlNc_vbg-
qyr4q2MKNEjhSA84/edit?hl=en&authkey=CJyJlOgF# | |
18 class Breakpoint { | |
19 public: | |
20 Breakpoint(); | |
21 Breakpoint(void* address, IDebuggeeProcess* process); | |
22 ~Breakpoint() {} | |
23 | |
24 void* address() const; | |
25 unsigned char original_code_byte() const; | |
26 | |
27 /// @return true iff |Init| operation succeeded. | |
28 bool is_valid() const; | |
29 | |
30 /// Copies original byte at breakpoint address into original_code_byte_. | |
31 /// Writes a breakpoint instruction code (0xCC) in memory position | |
32 /// specified by breakpoint address. | |
33 /// Should be called once. | |
34 /// @return true if read and write succeeded. | |
35 bool Init(); | |
36 | |
37 /// Writes a breakpoint instruction code (0xCC) in memory position | |
38 /// specified by breakpoint address. | |
39 /// @return true if write succeeded. | |
40 bool WriteBreakpointCode(); | |
41 | |
42 /// Writes an original code in memory position specified | |
43 /// by breakpoint address. | |
44 /// @return true if write succeeded. | |
45 bool RecoverCodeAtBreakpoint(); | |
46 | |
47 private: | |
48 void* address_; | |
49 unsigned char original_code_byte_; | |
50 bool is_valid_; | |
51 IDebuggeeProcess* process_; | |
52 | |
53 Breakpoint(const Breakpoint&); // DISALLOW_COPY_AND_ASSIGN | |
54 void operator=(const Breakpoint&); | |
55 }; | |
56 } // namespace debug | |
57 #endif // DEBUGGER_CORE_DEBUG_BREAKPOINT_H_ | |
58 | |
OLD | NEW |