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

Side by Side Diff: src/processor/microdump_processor_unittest.cc

Issue 1704243002: Support processing microdumps for x86 architecture. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Add the testdata file. Created 4 years, 10 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 | « src/processor/microdump.cc ('k') | src/processor/testdata/microdump-x86.dmp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, Google Inc. 1 // Copyright (c) 2014, 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const string& microdump_contents, 79 const string& microdump_contents,
80 ProcessState* state) { 80 ProcessState* state) {
81 SimpleSymbolSupplier supplier(symbols_file); 81 SimpleSymbolSupplier supplier(symbols_file);
82 BasicSourceLineResolver resolver; 82 BasicSourceLineResolver resolver;
83 StackFrameSymbolizer frame_symbolizer(&supplier, &resolver); 83 StackFrameSymbolizer frame_symbolizer(&supplier, &resolver);
84 MicrodumpProcessor processor(&frame_symbolizer); 84 MicrodumpProcessor processor(&frame_symbolizer);
85 85
86 return processor.Process(microdump_contents, state); 86 return processor.Process(microdump_contents, state);
87 } 87 }
88 88
89 void AnalyzeDump(const string& microdump_file_name, ProcessState* state, 89 void AnalyzeDump(const string& microdump_file_name, bool omit_symbols,
90 bool omit_symbols) { 90 int expected_cpu_count, ProcessState* state) {
91 string symbols_file = omit_symbols ? "" : files_path_ + "symbols/microdump"; 91 string symbols_file = omit_symbols ? "" : files_path_ + "symbols/microdump";
92 string microdump_file_path = files_path_ + microdump_file_name; 92 string microdump_file_path = files_path_ + microdump_file_name;
93 string microdump_contents; 93 string microdump_contents;
94 ReadFile(microdump_file_path, &microdump_contents); 94 ReadFile(microdump_file_path, &microdump_contents);
95 95
96 google_breakpad::ProcessResult result = 96 google_breakpad::ProcessResult result =
97 ProcessMicrodump(symbols_file, microdump_contents, state); 97 ProcessMicrodump(symbols_file, microdump_contents, state);
98 98
99 ASSERT_EQ(google_breakpad::PROCESS_OK, result); 99 ASSERT_EQ(google_breakpad::PROCESS_OK, result);
100 ASSERT_TRUE(state->crashed()); 100 ASSERT_TRUE(state->crashed());
101 ASSERT_EQ(0, state->requesting_thread()); 101 ASSERT_EQ(0, state->requesting_thread());
102 ASSERT_EQ(1U, state->threads()->size()); 102 ASSERT_EQ(1U, state->threads()->size());
103 103
104 ASSERT_EQ(2, state->system_info()->cpu_count); 104 ASSERT_EQ(expected_cpu_count, state->system_info()->cpu_count);
105 ASSERT_EQ("android", state->system_info()->os_short); 105 ASSERT_EQ("android", state->system_info()->os_short);
106 ASSERT_EQ("Android", state->system_info()->os); 106 ASSERT_EQ("Android", state->system_info()->os);
107 } 107 }
108 108
109 string files_path_; 109 string files_path_;
110 }; 110 };
111 111
112 TEST_F(MicrodumpProcessorTest, TestProcess_Empty) { 112 TEST_F(MicrodumpProcessorTest, TestProcess_Empty) {
113 ProcessState state; 113 ProcessState state;
114 google_breakpad::ProcessResult result = 114 google_breakpad::ProcessResult result =
115 ProcessMicrodump("", "", &state); 115 ProcessMicrodump("", "", &state);
116 ASSERT_EQ(google_breakpad::PROCESS_ERROR_MINIDUMP_NOT_FOUND, result); 116 ASSERT_EQ(google_breakpad::PROCESS_ERROR_MINIDUMP_NOT_FOUND, result);
117 } 117 }
118 118
119 TEST_F(MicrodumpProcessorTest, TestProcess_Invalid) { 119 TEST_F(MicrodumpProcessorTest, TestProcess_Invalid) {
120 ProcessState state; 120 ProcessState state;
121 google_breakpad::ProcessResult result = 121 google_breakpad::ProcessResult result =
122 ProcessMicrodump("", "This is not a valid microdump", &state); 122 ProcessMicrodump("", "This is not a valid microdump", &state);
123 ASSERT_EQ(google_breakpad::PROCESS_ERROR_NO_THREAD_LIST, result); 123 ASSERT_EQ(google_breakpad::PROCESS_ERROR_NO_THREAD_LIST, result);
124 } 124 }
125 125
126 TEST_F(MicrodumpProcessorTest, TestProcess_MissingSymbols) { 126 TEST_F(MicrodumpProcessorTest, TestProcess_MissingSymbols) {
127 ProcessState state; 127 ProcessState state;
128 AnalyzeDump("microdump-arm64.dmp", &state, true /* omit_symbols */); 128 AnalyzeDump("microdump-arm64.dmp", true /* omit_symbols */,
129 2 /* expected_cpu_count */, &state);
129 130
130 ASSERT_EQ(8U, state.modules()->module_count()); 131 ASSERT_EQ(8U, state.modules()->module_count());
131 ASSERT_EQ("arm64", state.system_info()->cpu); 132 ASSERT_EQ("arm64", state.system_info()->cpu);
132 ASSERT_EQ("OS 64 VERSION INFO", state.system_info()->os_version); 133 ASSERT_EQ("OS 64 VERSION INFO", state.system_info()->os_version);
133 ASSERT_EQ(1U, state.threads()->size()); 134 ASSERT_EQ(1U, state.threads()->size());
134 ASSERT_EQ(12U, state.threads()->at(0)->frames()->size()); 135 ASSERT_EQ(12U, state.threads()->at(0)->frames()->size());
135 136
136 ASSERT_EQ("", 137 ASSERT_EQ("",
137 state.threads()->at(0)->frames()->at(0)->function_name); 138 state.threads()->at(0)->frames()->at(0)->function_name);
138 ASSERT_EQ("", 139 ASSERT_EQ("",
139 state.threads()->at(0)->frames()->at(3)->function_name); 140 state.threads()->at(0)->frames()->at(3)->function_name);
140 } 141 }
141 142
142 TEST_F(MicrodumpProcessorTest, TestProcess_UnsupportedArch) { 143 TEST_F(MicrodumpProcessorTest, TestProcess_UnsupportedArch) {
143 string microdump_contents = 144 string microdump_contents =
144 "W/google-breakpad(26491): -----BEGIN BREAKPAD MICRODUMP-----\n" 145 "W/google-breakpad(26491): -----BEGIN BREAKPAD MICRODUMP-----\n"
145 "W/google-breakpad(26491): O A \"unsupported-arch\"\n" 146 "W/google-breakpad(26491): O A \"unsupported-arch\"\n"
146 "W/google-breakpad(26491): S 0 A48BD840 A48BD000 00002000\n"; 147 "W/google-breakpad(26491): S 0 A48BD840 A48BD000 00002000\n";
147 148
148 ProcessState state; 149 ProcessState state;
149 150
150 google_breakpad::ProcessResult result = 151 google_breakpad::ProcessResult result =
151 ProcessMicrodump("", microdump_contents, &state); 152 ProcessMicrodump("", microdump_contents, &state);
152 153
153 ASSERT_EQ(google_breakpad::PROCESS_ERROR_NO_THREAD_LIST, result); 154 ASSERT_EQ(google_breakpad::PROCESS_ERROR_NO_THREAD_LIST, result);
154 } 155 }
155 156
156 TEST_F(MicrodumpProcessorTest, TestProcessArm) { 157 TEST_F(MicrodumpProcessorTest, TestProcessArm) {
157 ProcessState state; 158 ProcessState state;
158 AnalyzeDump("microdump-arm.dmp", &state, false /* omit_symbols */); 159 AnalyzeDump("microdump-arm.dmp", false /* omit_symbols */,
160 2 /* expected_cpu_count*/, &state);
159 161
160 ASSERT_EQ(6U, state.modules()->module_count()); 162 ASSERT_EQ(6U, state.modules()->module_count());
161 ASSERT_EQ("arm", state.system_info()->cpu); 163 ASSERT_EQ("arm", state.system_info()->cpu);
162 ASSERT_EQ("OpenGL ES 3.0 V@104.0 AU@ (GIT@Id3510ff6dc)", 164 ASSERT_EQ("OpenGL ES 3.0 V@104.0 AU@ (GIT@Id3510ff6dc)",
163 state.system_info()->gl_version); 165 state.system_info()->gl_version);
164 ASSERT_EQ("Qualcomm", state.system_info()->gl_vendor); 166 ASSERT_EQ("Qualcomm", state.system_info()->gl_vendor);
165 ASSERT_EQ("Adreno (TM) 330", state.system_info()->gl_renderer); 167 ASSERT_EQ("Adreno (TM) 330", state.system_info()->gl_renderer);
166 ASSERT_EQ("OS VERSION INFO", state.system_info()->os_version); 168 ASSERT_EQ("OS VERSION INFO", state.system_info()->os_version);
167 ASSERT_EQ(8U, state.threads()->at(0)->frames()->size()); 169 ASSERT_EQ(8U, state.threads()->at(0)->frames()->size());
168 ASSERT_EQ("MicrodumpWriterTest_Setup_Test::TestBody", 170 ASSERT_EQ("MicrodumpWriterTest_Setup_Test::TestBody",
169 state.threads()->at(0)->frames()->at(0)->function_name); 171 state.threads()->at(0)->frames()->at(0)->function_name);
170 ASSERT_EQ("testing::Test::Run", 172 ASSERT_EQ("testing::Test::Run",
171 state.threads()->at(0)->frames()->at(1)->function_name); 173 state.threads()->at(0)->frames()->at(1)->function_name);
172 ASSERT_EQ("main", 174 ASSERT_EQ("main",
173 state.threads()->at(0)->frames()->at(6)->function_name); 175 state.threads()->at(0)->frames()->at(6)->function_name);
174 ASSERT_EQ("breakpad_unittests", 176 ASSERT_EQ("breakpad_unittests",
175 state.threads()->at(0)->frames()->at(6)->module->code_file()); 177 state.threads()->at(0)->frames()->at(6)->module->code_file());
176 } 178 }
177 179
178 TEST_F(MicrodumpProcessorTest, TestProcessArm64) { 180 TEST_F(MicrodumpProcessorTest, TestProcessArm64) {
179 ProcessState state; 181 ProcessState state;
180 AnalyzeDump("microdump-arm64.dmp", &state, false /* omit_symbols */); 182 AnalyzeDump("microdump-arm64.dmp", false /* omit_symbols */,
183 2 /* expected_cpu_count*/, &state);
181 184
182 ASSERT_EQ(8U, state.modules()->module_count()); 185 ASSERT_EQ(8U, state.modules()->module_count());
183 ASSERT_EQ("arm64", state.system_info()->cpu); 186 ASSERT_EQ("arm64", state.system_info()->cpu);
184 ASSERT_EQ("OS 64 VERSION INFO", state.system_info()->os_version); 187 ASSERT_EQ("OS 64 VERSION INFO", state.system_info()->os_version);
185 ASSERT_EQ(9U, state.threads()->at(0)->frames()->size()); 188 ASSERT_EQ(9U, state.threads()->at(0)->frames()->size());
186 ASSERT_EQ("MicrodumpWriterTest_Setup_Test::TestBody", 189 ASSERT_EQ("MicrodumpWriterTest_Setup_Test::TestBody",
187 state.threads()->at(0)->frames()->at(0)->function_name); 190 state.threads()->at(0)->frames()->at(0)->function_name);
188 ASSERT_EQ("testing::Test::Run", 191 ASSERT_EQ("testing::Test::Run",
189 state.threads()->at(0)->frames()->at(2)->function_name); 192 state.threads()->at(0)->frames()->at(2)->function_name);
190 ASSERT_EQ("main", 193 ASSERT_EQ("main",
191 state.threads()->at(0)->frames()->at(7)->function_name); 194 state.threads()->at(0)->frames()->at(7)->function_name);
192 ASSERT_EQ("breakpad_unittests", 195 ASSERT_EQ("breakpad_unittests",
193 state.threads()->at(0)->frames()->at(7)->module->code_file()); 196 state.threads()->at(0)->frames()->at(7)->module->code_file());
194 } 197 }
195 198
199 TEST_F(MicrodumpProcessorTest, TestProcessX86) {
200 ProcessState state;
201 AnalyzeDump("microdump-x86.dmp", false /* omit_symbols */,
202 4 /* expected_cpu_count */, &state);
203
204 ASSERT_EQ(105U, state.modules()->module_count());
205 ASSERT_EQ("x86", state.system_info()->cpu);
206 ASSERT_EQ("asus/WW_Z00A/Z00A:5.0/LRX21V/2.19.40.22_20150627_5104_user:user/"
207 "release-keys", state.system_info()->os_version);
208 ASSERT_EQ(56U, state.threads()->at(0)->frames()->size());
209 ASSERT_EQ("libc.so",
210 state.threads()->at(0)->frames()->at(0)->module->debug_file());
211 // TODO(mmandlis): Get symbols for the test X86 microdump and test function
212 // names.
213 }
214
196 } // namespace 215 } // namespace
197 216
198 int main(int argc, char* argv[]) { 217 int main(int argc, char* argv[]) {
199 ::testing::InitGoogleTest(&argc, argv); 218 ::testing::InitGoogleTest(&argc, argv);
200 return RUN_ALL_TESTS(); 219 return RUN_ALL_TESTS();
201 } 220 }
OLDNEW
« no previous file with comments | « src/processor/microdump.cc ('k') | src/processor/testdata/microdump-x86.dmp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698