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

Side by Side Diff: test/cctest/test-eh-frame-hdr.cc

Issue 2023503002: Reland Implement .eh_frame writer and disassembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame-base
Patch Set: Rebase on master. 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/unittests/eh-frame-iterator-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/eh-frame.h"
6 #include "src/objects.h"
7 #include "test/cctest/cctest.h"
8
9 using namespace v8::internal;
10
11 TEST(EhFrameHdr) {
12 CcTest::InitializeVM();
13 HandleScope handle_scope(CcTest::i_isolate());
14
15 // The content is not relevant in this test
16 byte buffer[10] = {0};
17 byte unwinding_info[30 + EhFrameHdr::kRecordSize] = {0};
18
19 CodeDesc code_desc;
20 code_desc.buffer = &buffer[0];
21 code_desc.buffer_size = sizeof(buffer);
22 code_desc.constant_pool_size = 0;
23 code_desc.instr_size = sizeof(buffer);
24 code_desc.reloc_size = 0;
25 code_desc.origin = nullptr;
26 code_desc.unwinding_info = &unwinding_info[0];
27 code_desc.unwinding_info_size = sizeof(unwinding_info);
28
29 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
30 code_desc, 0, Handle<Object>::null());
31
32 EhFrameHdr eh_frame_hdr(*code);
33 CHECK_EQ(eh_frame_hdr.lut_entries_number(), 1);
34
35 //
36 // Plugging some numbers in the DSO layout shown in eh-frame.cc:
37 //
38 // | ... |
39 // +---------------+ <-- (E) --------
40 // | | ^
41 // | Instructions | 10 bytes | .text
42 // | | v
43 // +---------------+ <---------------
44 // |///////////////|
45 // |////Padding////| 6 bytes
46 // |///////////////|
47 // +---------------+ <---(D)---------
48 // | | ^
49 // | CIE | N bytes* |
50 // | | |
51 // +---------------+ <-- (C) | .eh_frame
52 // | | |
53 // | FDE | 30 - N bytes |
54 // | | v
55 // +---------------+ <-- (B) --------
56 // | version | ^
57 // +---------------+ 4 bytes |
58 // | encoding | |
59 // | specifiers | |
60 // +---------------+ <---(A) | .eh_frame_hdr
61 // | offset to | |
62 // | .eh_frame | |
63 // +---------------+ |
64 // | ... | ...
65 //
66 // (*) the size of the CIE is platform dependent.
67 //
68 CHECK_EQ(eh_frame_hdr.offset_to_eh_frame(), -(4 + 30)); // A -> D
69 CHECK_EQ(eh_frame_hdr.offset_to_procedure(), -(30 + 6 + 10)); // B -> E
70 CHECK_EQ(eh_frame_hdr.offset_to_fde(),
71 -(30 - EhFrameHdr::kCIESize)); // B -> C
72 }
73
74 TEST(DummyEhFrameHdr) {
75 CcTest::InitializeVM();
76 HandleScope handle_scope(CcTest::i_isolate());
77
78 byte buffer[10] = {0}; // The content is not relevant in this test
79
80 CodeDesc code_desc;
81 code_desc.buffer = &buffer[0];
82 code_desc.buffer_size = sizeof(buffer);
83 code_desc.constant_pool_size = 0;
84 code_desc.instr_size = sizeof(buffer);
85 code_desc.reloc_size = 0;
86 code_desc.origin = nullptr;
87 code_desc.unwinding_info = nullptr;
88 code_desc.unwinding_info_size = 0;
89
90 Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
91 code_desc, 0, Handle<Object>::null());
92
93 EhFrameHdr eh_frame_hdr(*code);
94 // A dummy header has an empty LUT
95 CHECK_EQ(eh_frame_hdr.lut_entries_number(), 0);
96 // These values should be irrelevant, but check that they have been zeroed.
97 CHECK_EQ(eh_frame_hdr.offset_to_eh_frame(), 0);
98 CHECK_EQ(eh_frame_hdr.offset_to_procedure(), 0);
99 CHECK_EQ(eh_frame_hdr.offset_to_fde(), 0);
100 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/unittests/eh-frame-iterator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698