Chromium Code Reviews

Side by Side Diff: test/unittests/eh-frame-hdr-unittest.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: SaveRegisterToStack => RegisterSavedToStack. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 "testing/gtest/include/gtest/gtest.h"
7
8 namespace {
9
10 class EhFrameHdrLayout : public testing::Test {
rmcilroy 2016/07/05 10:56:13 I don't think you need this fixture - just create
Stefano Sanfilippo 2016/07/05 16:02:14 Done.
11 public:
12 EhFrameHdrLayout()
13 : eh_frame_hdr_(10, 30, 10),
14 dummy_eh_frame_hdr_(v8::internal::EhFrameHdr::CreateEmptyHeader()) {}
15
16 protected:
17 v8::internal::EhFrameHdr eh_frame_hdr_;
18 v8::internal::EhFrameHdr dummy_eh_frame_hdr_;
19 };
20
21 } // namespace
22
23 TEST_F(EhFrameHdrLayout, Real) {
24 //
25 // Plugging some numbers in the DSO layout shown in eh-frame.cc:
26 //
27 // | ... |
28 // +---------------+ <-- (E) --------
29 // | | ^
30 // | Instructions | 10 bytes | .text
31 // | | v
32 // +---------------+ <---------------
33 // |///////////////|
34 // |////Padding////| 6 bytes
35 // |///////////////|
36 // +---------------+ <---(D)---------
37 // | | ^
38 // | CIE | N bytes* |
39 // | | |
40 // +---------------+ <-- (C) | .eh_frame
41 // | | |
42 // | FDE | 30 - N bytes |
43 // | | v
44 // +---------------+ <-- (B) --------
45 // | version | ^
46 // +---------------+ 4 bytes |
47 // | encoding | |
48 // | specifiers | |
49 // +---------------+ <---(A) | .eh_frame_hdr
50 // | offset to | |
51 // | .eh_frame | |
52 // +---------------+ |
53 // | ... | ...
54 //
55 // (*) the size of the CIE is platform dependent, 10 for this test.
56 //
57 EXPECT_EQ(1, eh_frame_hdr_.lut_entries_number());
58 EXPECT_EQ(-(4 + 30), eh_frame_hdr_.offset_to_eh_frame()); // A -> D
59 EXPECT_EQ(-(30 + 6 + 10), eh_frame_hdr_.offset_to_procedure()); // B -> E
60 EXPECT_EQ(-(30 - 10), eh_frame_hdr_.offset_to_fde()); // B -> C
61 }
62
63 TEST_F(EhFrameHdrLayout, Empty) {
64 // An emtpy header has an empty LUT
65 EXPECT_EQ(0, dummy_eh_frame_hdr_.lut_entries_number());
66 // These values should be irrelevant, but check that they have been zeroed.
67 EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_eh_frame());
68 EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_procedure());
69 EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_fde());
70 }
OLDNEW

Powered by Google App Engine