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

Side by Side Diff: src/common/dwarf_cu_to_module_unittest.cc

Issue 1605153004: unittests: fix -Wnarrowing build errors (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: fix one more long line Created 4 years, 11 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 (c) 2010 Google Inc. 1 // Copyright (c) 2010 Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 using ::testing::Test; 58 using ::testing::Test;
59 using ::testing::TestWithParam; 59 using ::testing::TestWithParam;
60 using ::testing::Values; 60 using ::testing::Values;
61 using ::testing::ValuesIn; 61 using ::testing::ValuesIn;
62 62
63 // Mock classes. 63 // Mock classes.
64 64
65 class MockLineToModuleHandler: public DwarfCUToModule::LineToModuleHandler { 65 class MockLineToModuleHandler: public DwarfCUToModule::LineToModuleHandler {
66 public: 66 public:
67 MOCK_METHOD1(StartCompilationUnit, void(const string& compilation_dir)); 67 MOCK_METHOD1(StartCompilationUnit, void(const string& compilation_dir));
68 MOCK_METHOD4(ReadProgram, void(const char* program, uint64 length, 68 MOCK_METHOD4(ReadProgram, void(const uint8_t *program, uint64 length,
69 Module *module, vector<Module::Line> *lines)); 69 Module *module, vector<Module::Line> *lines));
70 }; 70 };
71 71
72 class MockWarningReporter: public DwarfCUToModule::WarningReporter { 72 class MockWarningReporter: public DwarfCUToModule::WarningReporter {
73 public: 73 public:
74 MockWarningReporter(const string &filename, uint64 cu_offset) 74 MockWarningReporter(const string &filename, uint64 cu_offset)
75 : DwarfCUToModule::WarningReporter(filename, cu_offset) { } 75 : DwarfCUToModule::WarningReporter(filename, cu_offset) { }
76 MOCK_METHOD1(SetCUName, void(const string &name)); 76 MOCK_METHOD1(SetCUName, void(const string &name));
77 MOCK_METHOD2(UnknownSpecification, void(uint64 offset, uint64 target)); 77 MOCK_METHOD2(UnknownSpecification, void(uint64 offset, uint64 target));
78 MOCK_METHOD2(UnknownAbstractOrigin, void(uint64 offset, uint64 target)); 78 MOCK_METHOD2(UnknownAbstractOrigin, void(uint64 offset, uint64 target));
(...skipping 25 matching lines...) Expand all
104 // 104 //
105 // MockLineToModuleHandler l2m; 105 // MockLineToModuleHandler l2m;
106 // EXPECT_CALL(l2m, ReadProgram(_,_,_,_)) 106 // EXPECT_CALL(l2m, ReadProgram(_,_,_,_))
107 // .WillOnce(DoAll(Invoke(appender), Return())); 107 // .WillOnce(DoAll(Invoke(appender), Return()));
108 // 108 //
109 // in which case calling l2m with some line vector will append lines. 109 // in which case calling l2m with some line vector will append lines.
110 class AppendLinesFunctor { 110 class AppendLinesFunctor {
111 public: 111 public:
112 explicit AppendLinesFunctor( 112 explicit AppendLinesFunctor(
113 const vector<Module::Line> *lines) : lines_(lines) { } 113 const vector<Module::Line> *lines) : lines_(lines) { }
114 void operator()(const char *program, uint64 length, 114 void operator()(const uint8_t *program, uint64 length,
115 Module *module, vector<Module::Line> *lines) { 115 Module *module, vector<Module::Line> *lines) {
116 lines->insert(lines->end(), lines_->begin(), lines_->end()); 116 lines->insert(lines->end(), lines_->begin(), lines_->end());
117 } 117 }
118 private: 118 private:
119 const vector<Module::Line> *lines_; 119 const vector<Module::Line> *lines_;
120 }; 120 };
121 121
122 CUFixtureBase() 122 CUFixtureBase()
123 : module_("module-name", "module-os", "module-arch", "module-id"), 123 : module_("module-name", "module-os", "module-arch", "module-id"),
124 file_context_("dwarf-filename", &module_, true), 124 file_context_("dwarf-filename", &module_, true),
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 string compilation_dir_; 278 string compilation_dir_;
279 279
280 // If this is not empty, we'll give the CU a DW_AT_stmt_list 280 // If this is not empty, we'll give the CU a DW_AT_stmt_list
281 // attribute that, when passed to line_reader_, adds these lines to the 281 // attribute that, when passed to line_reader_, adds these lines to the
282 // provided lines array. 282 // provided lines array.
283 vector<Module::Line> lines_; 283 vector<Module::Line> lines_;
284 284
285 // Mock line program reader. 285 // Mock line program reader.
286 MockLineToModuleHandler line_reader_; 286 MockLineToModuleHandler line_reader_;
287 AppendLinesFunctor appender_; 287 AppendLinesFunctor appender_;
288 static const char dummy_line_program_[]; 288 static const uint8_t dummy_line_program_[];
289 static const size_t dummy_line_size_; 289 static const size_t dummy_line_size_;
290 290
291 MockWarningReporter reporter_; 291 MockWarningReporter reporter_;
292 DwarfCUToModule root_handler_; 292 DwarfCUToModule root_handler_;
293 293
294 private: 294 private:
295 // Fill functions_, if we haven't already. 295 // Fill functions_, if we haven't already.
296 void FillFunctions(); 296 void FillFunctions();
297 297
298 // If functions_filled_ is true, this is a table of functions we've 298 // If functions_filled_ is true, this is a table of functions we've
299 // extracted from module_, sorted by address. 299 // extracted from module_, sorted by address.
300 vector<Module::Function *> functions_; 300 vector<Module::Function *> functions_;
301 // True if we have filled the above vector with this.module_'s function list. 301 // True if we have filled the above vector with this.module_'s function list.
302 bool functions_filled_; 302 bool functions_filled_;
303 }; 303 };
304 304
305 const char CUFixtureBase::dummy_line_program_[] = "lots of fun data"; 305 const uint8_t CUFixtureBase::dummy_line_program_[] = "lots of fun data";
306 const size_t CUFixtureBase::dummy_line_size_ = 306 const size_t CUFixtureBase::dummy_line_size_ =
307 sizeof(CUFixtureBase::dummy_line_program_); 307 sizeof(CUFixtureBase::dummy_line_program_);
308 308
309 void CUFixtureBase::PushLine(Module::Address address, Module::Address size, 309 void CUFixtureBase::PushLine(Module::Address address, Module::Address size,
310 const string &filename, int line_number) { 310 const string &filename, int line_number) {
311 Module::Line l; 311 Module::Line l;
312 l.address = address; 312 l.address = address;
313 l.size = size; 313 l.size = size;
314 l.file = module_.FindFile(filename); 314 l.file = module_.FindFile(filename);
315 l.number = line_number; 315 l.number = line_number;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 dwarf2reader::DIEHandler *handler) { 368 dwarf2reader::DIEHandler *handler) {
369 handler->ProcessAttributeUnsigned((DwarfAttribute) 0xf560dead, 369 handler->ProcessAttributeUnsigned((DwarfAttribute) 0xf560dead,
370 (DwarfForm) 0x4106e4db, 370 (DwarfForm) 0x4106e4db,
371 0xa592571997facda1ULL); 371 0xa592571997facda1ULL);
372 handler->ProcessAttributeSigned((DwarfAttribute) 0x85380095, 372 handler->ProcessAttributeSigned((DwarfAttribute) 0x85380095,
373 (DwarfForm) 0x0f16fe87, 373 (DwarfForm) 0x0f16fe87,
374 0x12602a4e3bf1f446LL); 374 0x12602a4e3bf1f446LL);
375 handler->ProcessAttributeReference((DwarfAttribute) 0xf7f7480f, 375 handler->ProcessAttributeReference((DwarfAttribute) 0xf7f7480f,
376 (DwarfForm) 0x829e038a, 376 (DwarfForm) 0x829e038a,
377 0x50fddef44734fdecULL); 377 0x50fddef44734fdecULL);
378 static const char buffer[10] = "frobynode"; 378 static const uint8_t buffer[10] = "frobynode";
379 handler->ProcessAttributeBuffer((DwarfAttribute) 0xa55ffb51, 379 handler->ProcessAttributeBuffer((DwarfAttribute) 0xa55ffb51,
380 (DwarfForm) 0x2f43b041, 380 (DwarfForm) 0x2f43b041,
381 buffer, sizeof(buffer)); 381 buffer, sizeof(buffer));
382 handler->ProcessAttributeString((DwarfAttribute) 0x2f43b041, 382 handler->ProcessAttributeString((DwarfAttribute) 0x2f43b041,
383 (DwarfForm) 0x895ffa23, 383 (DwarfForm) 0x895ffa23,
384 "strange string"); 384 "strange string");
385 } 385 }
386 386
387 DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent, 387 DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent,
388 DwarfTag tag, 388 DwarfTag tag,
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 reporter.UncoveredLine(line); 1770 reporter.UncoveredLine(line);
1771 EXPECT_TRUE(reporter.uncovered_warnings_enabled()); 1771 EXPECT_TRUE(reporter.uncovered_warnings_enabled());
1772 } 1772 }
1773 1773
1774 TEST_F(Reporter, UnnamedFunction) { 1774 TEST_F(Reporter, UnnamedFunction) {
1775 reporter.UnnamedFunction(0x90c0baff9dedb2d9ULL); 1775 reporter.UnnamedFunction(0x90c0baff9dedb2d9ULL);
1776 } 1776 }
1777 1777
1778 // Would be nice to also test: 1778 // Would be nice to also test:
1779 // - overlapping lines, functions 1779 // - overlapping lines, functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698