OLD | NEW |
1 // -*- mode: c++ -*- | 1 // -*- mode: c++ -*- |
2 | 2 |
3 // Copyright (c) 2010 Google Inc. All Rights Reserved. | 3 // Copyright (c) 2010 Google Inc. All Rights Reserved. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... |
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> | 31 // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> |
32 | 32 |
33 // dwarf2diehander_unittest.cc: Unit tests for google_breakpad::DIEDispatcher. | 33 // dwarf2diehander_unittest.cc: Unit tests for google_breakpad::DIEDispatcher. |
34 | 34 |
| 35 #include <stdint.h> |
| 36 |
35 #include <string> | 37 #include <string> |
36 #include <utility> | 38 #include <utility> |
37 | 39 |
38 #include "breakpad_googletest_includes.h" | 40 #include "breakpad_googletest_includes.h" |
39 | 41 |
40 #include "common/dwarf/dwarf2diehandler.h" | 42 #include "common/dwarf/dwarf2diehandler.h" |
41 #include "common/using_std_string.h" | 43 #include "common/using_std_string.h" |
42 | 44 |
43 using std::make_pair; | 45 using std::make_pair; |
44 | 46 |
(...skipping 15 matching lines...) Expand all Loading... |
60 | 62 |
61 class MockDIEHandler: public DIEHandler { | 63 class MockDIEHandler: public DIEHandler { |
62 public: | 64 public: |
63 MOCK_METHOD3(ProcessAttributeUnsigned, | 65 MOCK_METHOD3(ProcessAttributeUnsigned, |
64 void(DwarfAttribute, DwarfForm, uint64)); | 66 void(DwarfAttribute, DwarfForm, uint64)); |
65 MOCK_METHOD3(ProcessAttributeSigned, | 67 MOCK_METHOD3(ProcessAttributeSigned, |
66 void(DwarfAttribute, DwarfForm, int64)); | 68 void(DwarfAttribute, DwarfForm, int64)); |
67 MOCK_METHOD3(ProcessAttributeReference, | 69 MOCK_METHOD3(ProcessAttributeReference, |
68 void(DwarfAttribute, DwarfForm, uint64)); | 70 void(DwarfAttribute, DwarfForm, uint64)); |
69 MOCK_METHOD4(ProcessAttributeBuffer, | 71 MOCK_METHOD4(ProcessAttributeBuffer, |
70 void(DwarfAttribute, DwarfForm, const char *, uint64)); | 72 void(DwarfAttribute, DwarfForm, const uint8_t *, uint64)); |
71 MOCK_METHOD3(ProcessAttributeString, | 73 MOCK_METHOD3(ProcessAttributeString, |
72 void(DwarfAttribute, DwarfForm, const string &)); | 74 void(DwarfAttribute, DwarfForm, const string &)); |
73 MOCK_METHOD3(ProcessAttributeSignature, | 75 MOCK_METHOD3(ProcessAttributeSignature, |
74 void(DwarfAttribute, DwarfForm, uint64)); | 76 void(DwarfAttribute, DwarfForm, uint64)); |
75 MOCK_METHOD0(EndAttributes, bool()); | 77 MOCK_METHOD0(EndAttributes, bool()); |
76 MOCK_METHOD2(FindChildHandler, DIEHandler *(uint64, DwarfTag)); | 78 MOCK_METHOD2(FindChildHandler, DIEHandler *(uint64, DwarfTag)); |
77 MOCK_METHOD0(Finish, void()); | 79 MOCK_METHOD0(Finish, void()); |
78 }; | 80 }; |
79 | 81 |
80 class MockRootDIEHandler: public RootDIEHandler { | 82 class MockRootDIEHandler: public RootDIEHandler { |
81 public: | 83 public: |
82 MOCK_METHOD3(ProcessAttributeUnsigned, | 84 MOCK_METHOD3(ProcessAttributeUnsigned, |
83 void(DwarfAttribute, DwarfForm, uint64)); | 85 void(DwarfAttribute, DwarfForm, uint64)); |
84 MOCK_METHOD3(ProcessAttributeSigned, | 86 MOCK_METHOD3(ProcessAttributeSigned, |
85 void(DwarfAttribute, DwarfForm, int64)); | 87 void(DwarfAttribute, DwarfForm, int64)); |
86 MOCK_METHOD3(ProcessAttributeReference, | 88 MOCK_METHOD3(ProcessAttributeReference, |
87 void(DwarfAttribute, DwarfForm, uint64)); | 89 void(DwarfAttribute, DwarfForm, uint64)); |
88 MOCK_METHOD4(ProcessAttributeBuffer, | 90 MOCK_METHOD4(ProcessAttributeBuffer, |
89 void(DwarfAttribute, DwarfForm, const char *, uint64)); | 91 void(DwarfAttribute, DwarfForm, const uint8_t *, uint64)); |
90 MOCK_METHOD3(ProcessAttributeString, | 92 MOCK_METHOD3(ProcessAttributeString, |
91 void(DwarfAttribute, DwarfForm, const string &)); | 93 void(DwarfAttribute, DwarfForm, const string &)); |
92 MOCK_METHOD3(ProcessAttributeSignature, | 94 MOCK_METHOD3(ProcessAttributeSignature, |
93 void(DwarfAttribute, DwarfForm, uint64)); | 95 void(DwarfAttribute, DwarfForm, uint64)); |
94 MOCK_METHOD0(EndAttributes, bool()); | 96 MOCK_METHOD0(EndAttributes, bool()); |
95 MOCK_METHOD2(FindChildHandler, DIEHandler *(uint64, DwarfTag)); | 97 MOCK_METHOD2(FindChildHandler, DIEHandler *(uint64, DwarfTag)); |
96 MOCK_METHOD0(Finish, void()); | 98 MOCK_METHOD0(Finish, void()); |
97 MOCK_METHOD5(StartCompilationUnit, bool(uint64, uint8, uint8, uint64, uint8)); | 99 MOCK_METHOD5(StartCompilationUnit, bool(uint64, uint8, uint8, uint64, uint8)); |
98 MOCK_METHOD2(StartRootDIE, bool(uint64, DwarfTag)); | 100 MOCK_METHOD2(StartRootDIE, bool(uint64, DwarfTag)); |
99 }; | 101 }; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 die_dispatcher.EndDIE(0x435150ceedccda18LL); | 180 die_dispatcher.EndDIE(0x435150ceedccda18LL); |
179 die_dispatcher.EndDIE(0x7d08242b4b510cf2LL); | 181 die_dispatcher.EndDIE(0x7d08242b4b510cf2LL); |
180 } | 182 } |
181 | 183 |
182 // The dispatcher should pass attribute values through to the die | 184 // The dispatcher should pass attribute values through to the die |
183 // handler accurately. | 185 // handler accurately. |
184 TEST(Dwarf2DIEHandler, PassAttributeValues) { | 186 TEST(Dwarf2DIEHandler, PassAttributeValues) { |
185 MockRootDIEHandler mock_root_handler; | 187 MockRootDIEHandler mock_root_handler; |
186 DIEDispatcher die_dispatcher(&mock_root_handler); | 188 DIEDispatcher die_dispatcher(&mock_root_handler); |
187 | 189 |
188 const char buffer[10] = { 0x24, 0x24, 0x35, 0x9a, 0xca, | 190 const uint8_t buffer[10] = { |
189 0xcf, 0xa8, 0x84, 0xa7, 0x18 }; | 191 0x24, 0x24, 0x35, 0x9a, 0xca, 0xcf, 0xa8, 0x84, 0xa7, 0x18 |
| 192 }; |
190 string str = "\xc8\x26\x2e\x0d\xa4\x9c\x37\xd6\xfb\x1d"; | 193 string str = "\xc8\x26\x2e\x0d\xa4\x9c\x37\xd6\xfb\x1d"; |
191 | 194 |
192 // Set expectations. | 195 // Set expectations. |
193 { | 196 { |
194 InSequence s; | 197 InSequence s; |
195 | 198 |
196 // We'll like the compilation unit header. | 199 // We'll like the compilation unit header. |
197 EXPECT_CALL(mock_root_handler, | 200 EXPECT_CALL(mock_root_handler, |
198 StartCompilationUnit(0x8d42aed77cfccf3eLL, 0x89, 0xdc, | 201 StartCompilationUnit(0x8d42aed77cfccf3eLL, 0x89, 0xdc, |
199 0x2ecb4dc778a80f21LL, 0x66)) | 202 0x2ecb4dc778a80f21LL, 0x66)) |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Stop the traversal abruptly, so that there will still be | 518 // Stop the traversal abruptly, so that there will still be |
516 // handlers on the stack when the dispatcher is destructed. | 519 // handlers on the stack when the dispatcher is destructed. |
517 | 520 |
518 // No EndDIE call... | 521 // No EndDIE call... |
519 } | 522 } |
520 // No EndDIE call... | 523 // No EndDIE call... |
521 } | 524 } |
522 // No EndDIE call... | 525 // No EndDIE call... |
523 } | 526 } |
524 } | 527 } |
OLD | NEW |