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

Side by Side Diff: src/eh-frame.h

Issue 2023503002: Reland Implement .eh_frame writer and disassembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame-base
Patch Set: Improve disassembler, get rid of PatchProcedureBoundariesInEhFrame. Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_EH_FRAME_H_ 5 #ifndef V8_EH_FRAME_H_
6 #define V8_EH_FRAME_H_ 6 #define V8_EH_FRAME_H_
7 7
8 #include <cstdint> 8 #include "src/list.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 class Code; 13 class Code;
14 struct CodeDesc;
15
16 class EhFrameWriter {
17 public:
18 static const int kCIESize;
19
20 EhFrameWriter();
21
22 void AdvanceLocation(int pc_offset);
23 void DefineCFARegister(int code);
rmcilroy 2016/06/28 10:37:33 Could you use Register instead of "int code"? (and
Stefano Sanfilippo 2016/06/29 15:16:21 Yes, done. I added a RegisterToDwarfCode function
24 void DefineCFAOffset(int cfa_offset);
25 void IncreaseCFAOffset(int cfa_delta) {
26 DefineCFAOffset(cfa_offset_ + cfa_delta);
27 }
28 void DefineCFARegisterOffset(int code, int cfa_offset);
29 void SaveRegisterToStack(int code, int offset);
30 void SaveRegisterToStack(int code) { SaveRegisterToStack(code, cfa_offset_); }
31 void RegisterHasInitialValue(int code);
32
33 void Finish(int code_size);
34 void GetEhFrame(CodeDesc* desc);
35
36 int last_pc_offset() const { return last_pc_offset_; }
37 int cfa_register() const { return cfa_register_; }
38 int cfa_offset() const { return cfa_offset_; }
39
40 static void DisassembleToStream(std::ostream& stream, // NOLINT
41 const byte* start, const byte* end);
42
43 protected:
44 void WriteByte(byte value) { unwinding_info_.Add(value); }
45
46 void WriteBytes(const byte* value, int size) {
47 unwinding_info_.AddAll(Vector<byte>(const_cast<byte*>(value), size));
48 }
49
50 void WriteInt16(uint16_t value) {
51 unwinding_info_.AddAll(
52 Vector<byte>(reinterpret_cast<byte*>(&value), sizeof(value)));
53 }
54
55 void WriteInt32(uint32_t value) {
56 unwinding_info_.AddAll(
57 Vector<byte>(reinterpret_cast<byte*>(&value), sizeof(value)));
58 }
59
60 void WriteULEB128(uint32_t value);
61
62 void PatchInt32(int base_offset, uint32_t value) {
63 MemCopy(unwinding_info_.begin() + base_offset, &value, sizeof(value));
64 }
65
66 private:
67 void WriteFDEHeader();
68
69 int last_pc_offset_;
70 int cfa_register_;
71 int cfa_offset_;
72 List<byte> unwinding_info_;
73 };
14 74
15 class EhFrameHdr final { 75 class EhFrameHdr final {
16 public: 76 public:
17 static const int kRecordSize = 20; 77 static const int kRecordSize = 20;
18 static const int kCIESize;
19 78
20 explicit EhFrameHdr(Code* code); 79 explicit EhFrameHdr(Code* code);
21 80
22 int32_t offset_to_eh_frame() const { return offset_to_eh_frame_; } 81 int32_t offset_to_eh_frame() const { return offset_to_eh_frame_; }
23 uint32_t lut_entries_number() const { return lut_entries_number_; } 82 uint32_t lut_entries_number() const { return lut_entries_number_; }
24 int32_t offset_to_procedure() const { return offset_to_procedure_; } 83 int32_t offset_to_procedure() const { return offset_to_procedure_; }
25 int32_t offset_to_fde() const { return offset_to_fde_; } 84 int32_t offset_to_fde() const { return offset_to_fde_; }
26 85
27 private: 86 private:
28 uint8_t version_; 87 uint8_t version_;
29 uint8_t eh_frame_ptr_encoding_; 88 uint8_t eh_frame_ptr_encoding_;
30 uint8_t lut_size_encoding_; 89 uint8_t lut_size_encoding_;
31 uint8_t lut_entries_encoding_; 90 uint8_t lut_entries_encoding_;
32 int32_t offset_to_eh_frame_; 91 int32_t offset_to_eh_frame_;
33 uint32_t lut_entries_number_; 92 uint32_t lut_entries_number_;
34 int32_t offset_to_procedure_; 93 int32_t offset_to_procedure_;
35 int32_t offset_to_fde_; 94 int32_t offset_to_fde_;
36 }; 95 };
37 96
38 } // namespace internal 97 } // namespace internal
39 } // namespace v8 98 } // namespace v8
40 99
41 #endif 100 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698