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

Side by Side Diff: minidump/minidump_thread_id_map.cc

Issue 883773005: win: Work towards getting 'minidump' to compile (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@crash-report-db-win
Patch Set: more mucking around Created 5 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 | « minidump/minidump_system_info_writer_test.cc ('k') | minidump/minidump_thread_writer.h » ('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 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,
(...skipping 18 matching lines...) Expand all
29 DCHECK(thread_id_map->empty()); 29 DCHECK(thread_id_map->empty());
30 30
31 // First, try truncating each 64-bit thread ID to 32 bits. If that’s possible 31 // First, try truncating each 64-bit thread ID to 32 bits. If that’s possible
32 // for each unique 64-bit thread ID, then this will be used as the mapping. 32 // for each unique 64-bit thread ID, then this will be used as the mapping.
33 // This preserves as much of the original thread ID as possible when feasible. 33 // This preserves as much of the original thread ID as possible when feasible.
34 bool collision = false; 34 bool collision = false;
35 std::set<uint32_t> thread_ids_32; 35 std::set<uint32_t> thread_ids_32;
36 for (const ThreadSnapshot* thread_snapshot : thread_snapshots) { 36 for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
37 uint64_t thread_id_64 = thread_snapshot->ThreadID(); 37 uint64_t thread_id_64 = thread_snapshot->ThreadID();
38 if (thread_id_map->find(thread_id_64) == thread_id_map->end()) { 38 if (thread_id_map->find(thread_id_64) == thread_id_map->end()) {
39 uint32_t thread_id_32 = thread_id_64; 39 uint32_t thread_id_32 = static_cast<uint32_t>(thread_id_64);
40 if (thread_ids_32.find(thread_id_32) != thread_ids_32.end()) { 40 if (thread_ids_32.find(thread_id_32) != thread_ids_32.end()) {
41 collision = true; 41 collision = true;
42 break; 42 break;
43 } 43 }
44 thread_ids_32.insert(thread_id_32); 44 thread_ids_32.insert(thread_id_32);
45 thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32)); 45 thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32));
46 } 46 }
47 } 47 }
48 48
49 if (collision) { 49 if (collision) {
50 // Since there was a collision, go back and assign each unique 64-bit thread 50 // Since there was a collision, go back and assign each unique 64-bit thread
51 // ID its own sequential 32-bit equivalent. The 32-bit thread IDs will not 51 // ID its own sequential 32-bit equivalent. The 32-bit thread IDs will not
52 // bear any resemblance to the original 64-bit thread IDs. 52 // bear any resemblance to the original 64-bit thread IDs.
53 thread_id_map->clear(); 53 thread_id_map->clear();
54 for (const ThreadSnapshot* thread_snapshot : thread_snapshots) { 54 for (const ThreadSnapshot* thread_snapshot : thread_snapshots) {
55 uint64_t thread_id_64 = thread_snapshot->ThreadID(); 55 uint64_t thread_id_64 = thread_snapshot->ThreadID();
56 if (thread_id_map->find(thread_id_64) == thread_id_map->end()) { 56 if (thread_id_map->find(thread_id_64) == thread_id_map->end()) {
57 uint32_t thread_id_32 = thread_id_map->size(); 57 uint32_t thread_id_32 = thread_id_map->size();
58 thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32)); 58 thread_id_map->insert(std::make_pair(thread_id_64, thread_id_32));
59 } 59 }
60 } 60 }
61 61
62 DCHECK_LE(thread_id_map->size(), std::numeric_limits<uint32_t>::max()); 62 DCHECK_LE(thread_id_map->size(), std::numeric_limits<uint32_t>::max());
63 } 63 }
64 } 64 }
65 65
66 } // namespace crashpad 66 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_system_info_writer_test.cc ('k') | minidump/minidump_thread_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698