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 | |
5 // This file contains the interface for processing DWARF Virtual Machine | |
6 | |
7 #ifndef DWARF_READER_DWARF_VM_H_ | |
8 #define DWARF_READER_DWARF_VM_H_ | |
9 | |
10 #include "common/types.h" | |
11 | |
12 namespace dwarf2reader { | |
13 class ByteReader; | |
14 } | |
15 | |
16 namespace dwarf_reader { | |
17 | |
18 // A virtual machine that operates on 32 bit addresses. | |
19 class IDwarfVM { | |
20 | |
21 public: | |
22 virtual uint32_t BitWidth() = 0; | |
23 virtual bool IsLSB() = 0; | |
24 virtual void ErrorString(const char *str) = 0; | |
25 | |
26 virtual uint64_t ReadRegister(int reg_number) = 0; | |
27 virtual uint64_t ReadMemory(uint64_t address, int count) = 0; | |
28 virtual uint64_t ReadFrameBase() = 0; | |
29 }; | |
30 | |
31 // Basic LSB implementations which can handle static structure decoding | |
32 class DwarfStaticVM32 : public IDwarfVM { | |
33 uint32_t BitWidth() { return 32; } | |
34 bool IsLSB() { return true; } | |
35 void ErrorString(const char *str) {}; | |
36 | |
37 uint64_t ReadRegister(int reg_number) { return 0; } | |
38 uint64_t ReadMemory(uint64_t address, int count) { return 0; } | |
39 uint64_t ReadFrameBase() { return 0; } | |
40 }; | |
41 | |
42 class DwarfStaticVM64 : public IDwarfVM { | |
43 uint32_t BitWidth() { return 64; } | |
44 bool IsLSB() { return true; } | |
45 void ErrorString(const char *str) {}; | |
46 | |
47 uint64_t ReadRegister(int reg_number) { return 0; } | |
48 uint64_t ReadMemory(uint64_t address, int count) { return 0; } | |
49 uint64_t ReadFrameBase() { return 0; } | |
50 }; | |
51 | |
52 uint32_t DwarfRun32(IDwarfVM *vm, | |
53 dwarf2reader::ByteReader *reader, | |
54 const char *program, | |
55 int length); | |
56 uint64_t DwarfRun64(IDwarfVM *vm, | |
57 dwarf2reader::ByteReader *reader, | |
58 const char *program, | |
59 int length); | |
60 } | |
61 | |
62 #endif // DWARF_READER_DWARF_VM_H_ | |
OLD | NEW |