| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "minidump/minidump_thread_writer.h" | |
| 16 | |
| 17 #include <string> | 15 #include <string> |
| 18 #include <utility> | 16 #include <utility> |
| 19 | 17 |
| 20 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 21 #include "base/format_macros.h" | 19 #include "base/format_macros.h" |
| 20 #include "base/memory/ptr_util.h" |
| 22 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 23 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
| 24 #include "minidump/minidump_context_writer.h" | 23 #include "minidump/minidump_context_writer.h" |
| 25 #include "minidump/minidump_file_writer.h" | 24 #include "minidump/minidump_file_writer.h" |
| 26 #include "minidump/minidump_memory_writer.h" | 25 #include "minidump/minidump_memory_writer.h" |
| 27 #include "minidump/minidump_thread_id_map.h" | 26 #include "minidump/minidump_thread_id_map.h" |
| 27 #include "minidump/minidump_thread_writer.h" |
| 28 #include "minidump/test/minidump_context_test_util.h" | 28 #include "minidump/test/minidump_context_test_util.h" |
| 29 #include "minidump/test/minidump_file_writer_test_util.h" | 29 #include "minidump/test/minidump_file_writer_test_util.h" |
| 30 #include "minidump/test/minidump_memory_writer_test_util.h" | 30 #include "minidump/test/minidump_memory_writer_test_util.h" |
| 31 #include "minidump/test/minidump_writable_test_util.h" | 31 #include "minidump/test/minidump_writable_test_util.h" |
| 32 #include "snapshot/test/test_cpu_context.h" | 32 #include "snapshot/test/test_cpu_context.h" |
| 33 #include "snapshot/test/test_memory_snapshot.h" | 33 #include "snapshot/test/test_memory_snapshot.h" |
| 34 #include "snapshot/test/test_thread_snapshot.h" | 34 #include "snapshot/test/test_thread_snapshot.h" |
| 35 #include "test/gtest_death_check.h" | 35 #include "test/gtest_death_check.h" |
| 36 #include "util/file/string_file.h" | 36 #include "util/file/string_file.h" |
| 37 | 37 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 ASSERT_EQ(kMinidumpStreamTypeMemoryList, directory[1].StreamType); | 71 ASSERT_EQ(kMinidumpStreamTypeMemoryList, directory[1].StreamType); |
| 72 | 72 |
| 73 *memory_list = MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>( | 73 *memory_list = MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>( |
| 74 file_contents, directory[1].Location); | 74 file_contents, directory[1].Location); |
| 75 ASSERT_TRUE(*memory_list); | 75 ASSERT_TRUE(*memory_list); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST(MinidumpThreadWriter, EmptyThreadList) { | 79 TEST(MinidumpThreadWriter, EmptyThreadList) { |
| 80 MinidumpFileWriter minidump_file_writer; | 80 MinidumpFileWriter minidump_file_writer; |
| 81 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 81 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 82 | 82 |
| 83 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 83 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 84 | 84 |
| 85 StringFile string_file; | 85 StringFile string_file; |
| 86 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 86 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
| 87 | 87 |
| 88 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 88 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
| 89 sizeof(MINIDUMP_THREAD_LIST), | 89 sizeof(MINIDUMP_THREAD_LIST), |
| 90 string_file.string().size()); | 90 string_file.string().size()); |
| 91 | 91 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 EXPECT_EQ(expected->ThreadContext.DataSize, observed->ThreadContext.DataSize); | 132 EXPECT_EQ(expected->ThreadContext.DataSize, observed->ThreadContext.DataSize); |
| 133 ASSERT_NE(0u, observed->ThreadContext.DataSize); | 133 ASSERT_NE(0u, observed->ThreadContext.DataSize); |
| 134 ASSERT_NE(0u, observed->ThreadContext.Rva); | 134 ASSERT_NE(0u, observed->ThreadContext.Rva); |
| 135 ASSERT_GE(file_contents.size(), | 135 ASSERT_GE(file_contents.size(), |
| 136 observed->ThreadContext.Rva + expected->ThreadContext.DataSize); | 136 observed->ThreadContext.Rva + expected->ThreadContext.DataSize); |
| 137 *context_base = &file_contents[observed->ThreadContext.Rva]; | 137 *context_base = &file_contents[observed->ThreadContext.Rva]; |
| 138 } | 138 } |
| 139 | 139 |
| 140 TEST(MinidumpThreadWriter, OneThread_x86_NoStack) { | 140 TEST(MinidumpThreadWriter, OneThread_x86_NoStack) { |
| 141 MinidumpFileWriter minidump_file_writer; | 141 MinidumpFileWriter minidump_file_writer; |
| 142 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 142 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 143 | 143 |
| 144 const uint32_t kThreadID = 0x11111111; | 144 const uint32_t kThreadID = 0x11111111; |
| 145 const uint32_t kSuspendCount = 1; | 145 const uint32_t kSuspendCount = 1; |
| 146 const uint32_t kPriorityClass = 0x20; | 146 const uint32_t kPriorityClass = 0x20; |
| 147 const uint32_t kPriority = 10; | 147 const uint32_t kPriority = 10; |
| 148 const uint64_t kTEB = 0x55555555; | 148 const uint64_t kTEB = 0x55555555; |
| 149 const uint32_t kSeed = 123; | 149 const uint32_t kSeed = 123; |
| 150 | 150 |
| 151 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 151 auto thread_writer = base::WrapUnique(new MinidumpThreadWriter()); |
| 152 thread_writer->SetThreadID(kThreadID); | 152 thread_writer->SetThreadID(kThreadID); |
| 153 thread_writer->SetSuspendCount(kSuspendCount); | 153 thread_writer->SetSuspendCount(kSuspendCount); |
| 154 thread_writer->SetPriorityClass(kPriorityClass); | 154 thread_writer->SetPriorityClass(kPriorityClass); |
| 155 thread_writer->SetPriority(kPriority); | 155 thread_writer->SetPriority(kPriority); |
| 156 thread_writer->SetTEB(kTEB); | 156 thread_writer->SetTEB(kTEB); |
| 157 | 157 |
| 158 auto context_x86_writer = make_scoped_ptr(new MinidumpContextX86Writer()); | 158 auto context_x86_writer = base::WrapUnique(new MinidumpContextX86Writer()); |
| 159 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed); | 159 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed); |
| 160 thread_writer->SetContext(std::move(context_x86_writer)); | 160 thread_writer->SetContext(std::move(context_x86_writer)); |
| 161 | 161 |
| 162 thread_list_writer->AddThread(std::move(thread_writer)); | 162 thread_list_writer->AddThread(std::move(thread_writer)); |
| 163 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 163 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 164 | 164 |
| 165 StringFile string_file; | 165 StringFile string_file; |
| 166 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 166 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
| 167 | 167 |
| 168 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 168 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 string_file.string(), | 191 string_file.string(), |
| 192 nullptr, | 192 nullptr, |
| 193 reinterpret_cast<const void**>(&observed_context))); | 193 reinterpret_cast<const void**>(&observed_context))); |
| 194 | 194 |
| 195 ASSERT_NO_FATAL_FAILURE( | 195 ASSERT_NO_FATAL_FAILURE( |
| 196 ExpectMinidumpContextX86(kSeed, observed_context, false)); | 196 ExpectMinidumpContextX86(kSeed, observed_context, false)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) { | 199 TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) { |
| 200 MinidumpFileWriter minidump_file_writer; | 200 MinidumpFileWriter minidump_file_writer; |
| 201 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 201 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 202 | 202 |
| 203 const uint32_t kThreadID = 0x22222222; | 203 const uint32_t kThreadID = 0x22222222; |
| 204 const uint32_t kSuspendCount = 2; | 204 const uint32_t kSuspendCount = 2; |
| 205 const uint32_t kPriorityClass = 0x30; | 205 const uint32_t kPriorityClass = 0x30; |
| 206 const uint32_t kPriority = 20; | 206 const uint32_t kPriority = 20; |
| 207 const uint64_t kTEB = 0x5555555555555555; | 207 const uint64_t kTEB = 0x5555555555555555; |
| 208 const uint64_t kMemoryBase = 0x765432100000; | 208 const uint64_t kMemoryBase = 0x765432100000; |
| 209 const size_t kMemorySize = 32; | 209 const size_t kMemorySize = 32; |
| 210 const uint8_t kMemoryValue = 99; | 210 const uint8_t kMemoryValue = 99; |
| 211 const uint32_t kSeed = 456; | 211 const uint32_t kSeed = 456; |
| 212 | 212 |
| 213 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 213 auto thread_writer = base::WrapUnique(new MinidumpThreadWriter()); |
| 214 thread_writer->SetThreadID(kThreadID); | 214 thread_writer->SetThreadID(kThreadID); |
| 215 thread_writer->SetSuspendCount(kSuspendCount); | 215 thread_writer->SetSuspendCount(kSuspendCount); |
| 216 thread_writer->SetPriorityClass(kPriorityClass); | 216 thread_writer->SetPriorityClass(kPriorityClass); |
| 217 thread_writer->SetPriority(kPriority); | 217 thread_writer->SetPriority(kPriority); |
| 218 thread_writer->SetTEB(kTEB); | 218 thread_writer->SetTEB(kTEB); |
| 219 | 219 |
| 220 auto memory_writer = make_scoped_ptr( | 220 auto memory_writer = base::WrapUnique( |
| 221 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); | 221 new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); |
| 222 thread_writer->SetStack(std::move(memory_writer)); | 222 thread_writer->SetStack(std::move(memory_writer)); |
| 223 | 223 |
| 224 MSVC_SUPPRESS_WARNING(4316); // Object allocated on heap may not be aligned. | 224 MSVC_SUPPRESS_WARNING(4316); // Object allocated on heap may not be aligned. |
| 225 auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); | 225 auto context_amd64_writer = |
| 226 base::WrapUnique(new MinidumpContextAMD64Writer()); |
| 226 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); | 227 InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); |
| 227 thread_writer->SetContext(std::move(context_amd64_writer)); | 228 thread_writer->SetContext(std::move(context_amd64_writer)); |
| 228 | 229 |
| 229 thread_list_writer->AddThread(std::move(thread_writer)); | 230 thread_list_writer->AddThread(std::move(thread_writer)); |
| 230 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 231 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 231 | 232 |
| 232 StringFile string_file; | 233 StringFile string_file; |
| 233 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 234 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
| 234 | 235 |
| 235 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + | 236 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 observed_stack, | 268 observed_stack, |
| 268 string_file.string(), | 269 string_file.string(), |
| 269 kMemoryValue, | 270 kMemoryValue, |
| 270 true)); | 271 true)); |
| 271 ASSERT_NO_FATAL_FAILURE( | 272 ASSERT_NO_FATAL_FAILURE( |
| 272 ExpectMinidumpContextAMD64(kSeed, observed_context, false)); | 273 ExpectMinidumpContextAMD64(kSeed, observed_context, false)); |
| 273 } | 274 } |
| 274 | 275 |
| 275 TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) { | 276 TEST(MinidumpThreadWriter, ThreeThreads_x86_MemoryList) { |
| 276 MinidumpFileWriter minidump_file_writer; | 277 MinidumpFileWriter minidump_file_writer; |
| 277 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 278 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 278 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter()); | 279 auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter()); |
| 279 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); | 280 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); |
| 280 | 281 |
| 281 const uint32_t kThreadID0 = 1111111; | 282 const uint32_t kThreadID0 = 1111111; |
| 282 const uint32_t kSuspendCount0 = 111111; | 283 const uint32_t kSuspendCount0 = 111111; |
| 283 const uint32_t kPriorityClass0 = 11111; | 284 const uint32_t kPriorityClass0 = 11111; |
| 284 const uint32_t kPriority0 = 1111; | 285 const uint32_t kPriority0 = 1111; |
| 285 const uint64_t kTEB0 = 111; | 286 const uint64_t kTEB0 = 111; |
| 286 const uint64_t kMemoryBase0 = 0x1110; | 287 const uint64_t kMemoryBase0 = 0x1110; |
| 287 const size_t kMemorySize0 = 16; | 288 const size_t kMemorySize0 = 16; |
| 288 const uint8_t kMemoryValue0 = 11; | 289 const uint8_t kMemoryValue0 = 11; |
| 289 const uint32_t kSeed0 = 1; | 290 const uint32_t kSeed0 = 1; |
| 290 | 291 |
| 291 auto thread_writer_0 = make_scoped_ptr(new MinidumpThreadWriter()); | 292 auto thread_writer_0 = base::WrapUnique(new MinidumpThreadWriter()); |
| 292 thread_writer_0->SetThreadID(kThreadID0); | 293 thread_writer_0->SetThreadID(kThreadID0); |
| 293 thread_writer_0->SetSuspendCount(kSuspendCount0); | 294 thread_writer_0->SetSuspendCount(kSuspendCount0); |
| 294 thread_writer_0->SetPriorityClass(kPriorityClass0); | 295 thread_writer_0->SetPriorityClass(kPriorityClass0); |
| 295 thread_writer_0->SetPriority(kPriority0); | 296 thread_writer_0->SetPriority(kPriority0); |
| 296 thread_writer_0->SetTEB(kTEB0); | 297 thread_writer_0->SetTEB(kTEB0); |
| 297 | 298 |
| 298 auto memory_writer_0 = make_scoped_ptr( | 299 auto memory_writer_0 = base::WrapUnique( |
| 299 new TestMinidumpMemoryWriter(kMemoryBase0, kMemorySize0, kMemoryValue0)); | 300 new TestMinidumpMemoryWriter(kMemoryBase0, kMemorySize0, kMemoryValue0)); |
| 300 thread_writer_0->SetStack(std::move(memory_writer_0)); | 301 thread_writer_0->SetStack(std::move(memory_writer_0)); |
| 301 | 302 |
| 302 auto context_x86_writer_0 = make_scoped_ptr(new MinidumpContextX86Writer()); | 303 auto context_x86_writer_0 = base::WrapUnique(new MinidumpContextX86Writer()); |
| 303 InitializeMinidumpContextX86(context_x86_writer_0->context(), kSeed0); | 304 InitializeMinidumpContextX86(context_x86_writer_0->context(), kSeed0); |
| 304 thread_writer_0->SetContext(std::move(context_x86_writer_0)); | 305 thread_writer_0->SetContext(std::move(context_x86_writer_0)); |
| 305 | 306 |
| 306 thread_list_writer->AddThread(std::move(thread_writer_0)); | 307 thread_list_writer->AddThread(std::move(thread_writer_0)); |
| 307 | 308 |
| 308 const uint32_t kThreadID1 = 2222222; | 309 const uint32_t kThreadID1 = 2222222; |
| 309 const uint32_t kSuspendCount1 = 222222; | 310 const uint32_t kSuspendCount1 = 222222; |
| 310 const uint32_t kPriorityClass1 = 22222; | 311 const uint32_t kPriorityClass1 = 22222; |
| 311 const uint32_t kPriority1 = 2222; | 312 const uint32_t kPriority1 = 2222; |
| 312 const uint64_t kTEB1 = 222; | 313 const uint64_t kTEB1 = 222; |
| 313 const uint64_t kMemoryBase1 = 0x2220; | 314 const uint64_t kMemoryBase1 = 0x2220; |
| 314 const size_t kMemorySize1 = 32; | 315 const size_t kMemorySize1 = 32; |
| 315 const uint8_t kMemoryValue1 = 22; | 316 const uint8_t kMemoryValue1 = 22; |
| 316 const uint32_t kSeed1 = 2; | 317 const uint32_t kSeed1 = 2; |
| 317 | 318 |
| 318 auto thread_writer_1 = make_scoped_ptr(new MinidumpThreadWriter()); | 319 auto thread_writer_1 = base::WrapUnique(new MinidumpThreadWriter()); |
| 319 thread_writer_1->SetThreadID(kThreadID1); | 320 thread_writer_1->SetThreadID(kThreadID1); |
| 320 thread_writer_1->SetSuspendCount(kSuspendCount1); | 321 thread_writer_1->SetSuspendCount(kSuspendCount1); |
| 321 thread_writer_1->SetPriorityClass(kPriorityClass1); | 322 thread_writer_1->SetPriorityClass(kPriorityClass1); |
| 322 thread_writer_1->SetPriority(kPriority1); | 323 thread_writer_1->SetPriority(kPriority1); |
| 323 thread_writer_1->SetTEB(kTEB1); | 324 thread_writer_1->SetTEB(kTEB1); |
| 324 | 325 |
| 325 auto memory_writer_1 = make_scoped_ptr( | 326 auto memory_writer_1 = base::WrapUnique( |
| 326 new TestMinidumpMemoryWriter(kMemoryBase1, kMemorySize1, kMemoryValue1)); | 327 new TestMinidumpMemoryWriter(kMemoryBase1, kMemorySize1, kMemoryValue1)); |
| 327 thread_writer_1->SetStack(std::move(memory_writer_1)); | 328 thread_writer_1->SetStack(std::move(memory_writer_1)); |
| 328 | 329 |
| 329 auto context_x86_writer_1 = make_scoped_ptr(new MinidumpContextX86Writer()); | 330 auto context_x86_writer_1 = base::WrapUnique(new MinidumpContextX86Writer()); |
| 330 InitializeMinidumpContextX86(context_x86_writer_1->context(), kSeed1); | 331 InitializeMinidumpContextX86(context_x86_writer_1->context(), kSeed1); |
| 331 thread_writer_1->SetContext(std::move(context_x86_writer_1)); | 332 thread_writer_1->SetContext(std::move(context_x86_writer_1)); |
| 332 | 333 |
| 333 thread_list_writer->AddThread(std::move(thread_writer_1)); | 334 thread_list_writer->AddThread(std::move(thread_writer_1)); |
| 334 | 335 |
| 335 const uint32_t kThreadID2 = 3333333; | 336 const uint32_t kThreadID2 = 3333333; |
| 336 const uint32_t kSuspendCount2 = 333333; | 337 const uint32_t kSuspendCount2 = 333333; |
| 337 const uint32_t kPriorityClass2 = 33333; | 338 const uint32_t kPriorityClass2 = 33333; |
| 338 const uint32_t kPriority2 = 3333; | 339 const uint32_t kPriority2 = 3333; |
| 339 const uint64_t kTEB2 = 333; | 340 const uint64_t kTEB2 = 333; |
| 340 const uint64_t kMemoryBase2 = 0x3330; | 341 const uint64_t kMemoryBase2 = 0x3330; |
| 341 const size_t kMemorySize2 = 48; | 342 const size_t kMemorySize2 = 48; |
| 342 const uint8_t kMemoryValue2 = 33; | 343 const uint8_t kMemoryValue2 = 33; |
| 343 const uint32_t kSeed2 = 3; | 344 const uint32_t kSeed2 = 3; |
| 344 | 345 |
| 345 auto thread_writer_2 = make_scoped_ptr(new MinidumpThreadWriter()); | 346 auto thread_writer_2 = base::WrapUnique(new MinidumpThreadWriter()); |
| 346 thread_writer_2->SetThreadID(kThreadID2); | 347 thread_writer_2->SetThreadID(kThreadID2); |
| 347 thread_writer_2->SetSuspendCount(kSuspendCount2); | 348 thread_writer_2->SetSuspendCount(kSuspendCount2); |
| 348 thread_writer_2->SetPriorityClass(kPriorityClass2); | 349 thread_writer_2->SetPriorityClass(kPriorityClass2); |
| 349 thread_writer_2->SetPriority(kPriority2); | 350 thread_writer_2->SetPriority(kPriority2); |
| 350 thread_writer_2->SetTEB(kTEB2); | 351 thread_writer_2->SetTEB(kTEB2); |
| 351 | 352 |
| 352 auto memory_writer_2 = make_scoped_ptr( | 353 auto memory_writer_2 = base::WrapUnique( |
| 353 new TestMinidumpMemoryWriter(kMemoryBase2, kMemorySize2, kMemoryValue2)); | 354 new TestMinidumpMemoryWriter(kMemoryBase2, kMemorySize2, kMemoryValue2)); |
| 354 thread_writer_2->SetStack(std::move(memory_writer_2)); | 355 thread_writer_2->SetStack(std::move(memory_writer_2)); |
| 355 | 356 |
| 356 auto context_x86_writer_2 = make_scoped_ptr(new MinidumpContextX86Writer()); | 357 auto context_x86_writer_2 = base::WrapUnique(new MinidumpContextX86Writer()); |
| 357 InitializeMinidumpContextX86(context_x86_writer_2->context(), kSeed2); | 358 InitializeMinidumpContextX86(context_x86_writer_2->context(), kSeed2); |
| 358 thread_writer_2->SetContext(std::move(context_x86_writer_2)); | 359 thread_writer_2->SetContext(std::move(context_x86_writer_2)); |
| 359 | 360 |
| 360 thread_list_writer->AddThread(std::move(thread_writer_2)); | 361 thread_list_writer->AddThread(std::move(thread_writer_2)); |
| 361 | 362 |
| 362 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 363 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 363 minidump_file_writer.AddStream(std::move(memory_list_writer)); | 364 minidump_file_writer.AddStream(std::move(memory_list_writer)); |
| 364 | 365 |
| 365 StringFile string_file; | 366 StringFile string_file; |
| 366 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 367 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 for (size_t index = 0; index < arraysize(expect_threads); ++index) { | 586 for (size_t index = 0; index < arraysize(expect_threads); ++index) { |
| 586 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot(); | 587 TestThreadSnapshot* thread_snapshot = new TestThreadSnapshot(); |
| 587 thread_snapshots_owner.push_back(thread_snapshot); | 588 thread_snapshots_owner.push_back(thread_snapshot); |
| 588 | 589 |
| 589 thread_snapshot->SetThreadID(thread_ids[index]); | 590 thread_snapshot->SetThreadID(thread_ids[index]); |
| 590 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); | 591 thread_snapshot->SetSuspendCount(expect_threads[index].SuspendCount); |
| 591 thread_snapshot->SetPriority(expect_threads[index].Priority); | 592 thread_snapshot->SetPriority(expect_threads[index].Priority); |
| 592 thread_snapshot->SetThreadSpecificDataAddress(expect_threads[index].Teb); | 593 thread_snapshot->SetThreadSpecificDataAddress(expect_threads[index].Teb); |
| 593 | 594 |
| 594 if (expect_threads[index].Stack.Memory.DataSize) { | 595 if (expect_threads[index].Stack.Memory.DataSize) { |
| 595 auto memory_snapshot = make_scoped_ptr(new TestMemorySnapshot()); | 596 auto memory_snapshot = base::WrapUnique(new TestMemorySnapshot()); |
| 596 memory_snapshot->SetAddress( | 597 memory_snapshot->SetAddress( |
| 597 expect_threads[index].Stack.StartOfMemoryRange); | 598 expect_threads[index].Stack.StartOfMemoryRange); |
| 598 memory_snapshot->SetSize(expect_threads[index].Stack.Memory.DataSize); | 599 memory_snapshot->SetSize(expect_threads[index].Stack.Memory.DataSize); |
| 599 memory_snapshot->SetValue(memory_values[index]); | 600 memory_snapshot->SetValue(memory_values[index]); |
| 600 thread_snapshot->SetStack(std::move(memory_snapshot)); | 601 thread_snapshot->SetStack(std::move(memory_snapshot)); |
| 601 } | 602 } |
| 602 | 603 |
| 603 Traits::InitializeCPUContext(thread_snapshot->MutableContext(), | 604 Traits::InitializeCPUContext(thread_snapshot->MutableContext(), |
| 604 context_seeds[index]); | 605 context_seeds[index]); |
| 605 | 606 |
| 606 auto teb_snapshot = make_scoped_ptr(new TestMemorySnapshot()); | 607 auto teb_snapshot = base::WrapUnique(new TestMemorySnapshot()); |
| 607 teb_snapshot->SetAddress(expect_threads[index].Teb); | 608 teb_snapshot->SetAddress(expect_threads[index].Teb); |
| 608 teb_snapshot->SetSize(kTebSize); | 609 teb_snapshot->SetSize(kTebSize); |
| 609 teb_snapshot->SetValue(static_cast<char>('t' + index)); | 610 teb_snapshot->SetValue(static_cast<char>('t' + index)); |
| 610 thread_snapshot->AddExtraMemory(std::move(teb_snapshot)); | 611 thread_snapshot->AddExtraMemory(std::move(teb_snapshot)); |
| 611 | 612 |
| 612 thread_snapshots.push_back(thread_snapshot); | 613 thread_snapshots.push_back(thread_snapshot); |
| 613 } | 614 } |
| 614 | 615 |
| 615 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 616 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 616 auto memory_list_writer = make_scoped_ptr(new MinidumpMemoryListWriter()); | 617 auto memory_list_writer = base::WrapUnique(new MinidumpMemoryListWriter()); |
| 617 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); | 618 thread_list_writer->SetMemoryListWriter(memory_list_writer.get()); |
| 618 MinidumpThreadIDMap thread_id_map; | 619 MinidumpThreadIDMap thread_id_map; |
| 619 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); | 620 thread_list_writer->InitializeFromSnapshot(thread_snapshots, &thread_id_map); |
| 620 | 621 |
| 621 MinidumpFileWriter minidump_file_writer; | 622 MinidumpFileWriter minidump_file_writer; |
| 622 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 623 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 623 minidump_file_writer.AddStream(std::move(memory_list_writer)); | 624 minidump_file_writer.AddStream(std::move(memory_list_writer)); |
| 624 | 625 |
| 625 StringFile string_file; | 626 StringFile string_file; |
| 626 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); | 627 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 TEST(MinidumpThreadWriter, InitializeFromSnapshot_AMD64) { | 687 TEST(MinidumpThreadWriter, InitializeFromSnapshot_AMD64) { |
| 687 RunInitializeFromSnapshotTest<InitializeFromSnapshotAMD64Traits>(false); | 688 RunInitializeFromSnapshotTest<InitializeFromSnapshotAMD64Traits>(false); |
| 688 } | 689 } |
| 689 | 690 |
| 690 TEST(MinidumpThreadWriter, InitializeFromSnapshot_ThreadIDCollision) { | 691 TEST(MinidumpThreadWriter, InitializeFromSnapshot_ThreadIDCollision) { |
| 691 RunInitializeFromSnapshotTest<InitializeFromSnapshotX86Traits>(true); | 692 RunInitializeFromSnapshotTest<InitializeFromSnapshotX86Traits>(true); |
| 692 } | 693 } |
| 693 | 694 |
| 694 TEST(MinidumpThreadWriterDeathTest, NoContext) { | 695 TEST(MinidumpThreadWriterDeathTest, NoContext) { |
| 695 MinidumpFileWriter minidump_file_writer; | 696 MinidumpFileWriter minidump_file_writer; |
| 696 auto thread_list_writer = make_scoped_ptr(new MinidumpThreadListWriter()); | 697 auto thread_list_writer = base::WrapUnique(new MinidumpThreadListWriter()); |
| 697 | 698 |
| 698 auto thread_writer = make_scoped_ptr(new MinidumpThreadWriter()); | 699 auto thread_writer = base::WrapUnique(new MinidumpThreadWriter()); |
| 699 | 700 |
| 700 thread_list_writer->AddThread(std::move(thread_writer)); | 701 thread_list_writer->AddThread(std::move(thread_writer)); |
| 701 minidump_file_writer.AddStream(std::move(thread_list_writer)); | 702 minidump_file_writer.AddStream(std::move(thread_list_writer)); |
| 702 | 703 |
| 703 StringFile string_file; | 704 StringFile string_file; |
| 704 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), | 705 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), |
| 705 "context_"); | 706 "context_"); |
| 706 } | 707 } |
| 707 | 708 |
| 708 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { | 709 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { |
| 709 ASSERT_DEATH_CHECK( | 710 ASSERT_DEATH_CHECK( |
| 710 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( | 711 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( |
| 711 false), "context_"); | 712 false), "context_"); |
| 712 } | 713 } |
| 713 | 714 |
| 714 } // namespace | 715 } // namespace |
| 715 } // namespace test | 716 } // namespace test |
| 716 } // namespace crashpad | 717 } // namespace crashpad |
| OLD | NEW |