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

Side by Side Diff: snapshot/minidump/process_snapshot_minidump_test.cc

Issue 983103004: win: fixes for Windows x64 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: mac Created 5 years, 9 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/test/minidump_rva_list_test_util.cc ('k') | snapshot/win/process_reader_win.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 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 ProcessSnapshotMinidump process_snapshot; 57 ProcessSnapshotMinidump process_snapshot;
58 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); 58 EXPECT_TRUE(process_snapshot.Initialize(&string_file));
59 } 59 }
60 60
61 // Writes |string| to |writer| as a MinidumpUTF8String, and returns the file 61 // Writes |string| to |writer| as a MinidumpUTF8String, and returns the file
62 // offst of the beginning of the string. 62 // offst of the beginning of the string.
63 RVA WriteString(FileWriterInterface* writer, const std::string& string) { 63 RVA WriteString(FileWriterInterface* writer, const std::string& string) {
64 RVA rva = static_cast<RVA>(writer->SeekGet()); 64 RVA rva = static_cast<RVA>(writer->SeekGet());
65 65
66 uint32_t string_size = string.size(); 66 uint32_t string_size = static_cast<uint32_t>(string.size());
67 EXPECT_TRUE(writer->Write(&string_size, sizeof(string_size))); 67 EXPECT_TRUE(writer->Write(&string_size, sizeof(string_size)));
68 68
69 // Include the trailing NUL character. 69 // Include the trailing NUL character.
70 EXPECT_TRUE(writer->Write(string.c_str(), string.size() + 1)); 70 EXPECT_TRUE(writer->Write(string.c_str(), string.size() + 1));
71 71
72 return rva; 72 return rva;
73 } 73 }
74 74
75 // Writes |dictionary| to |writer| as a MinidumpSimpleStringDictionary, and 75 // Writes |dictionary| to |writer| as a MinidumpSimpleStringDictionary, and
76 // populates |location| with a location descriptor identifying what was written. 76 // populates |location| with a location descriptor identifying what was written.
77 void WriteMinidumpSimpleStringDictionary( 77 void WriteMinidumpSimpleStringDictionary(
78 MINIDUMP_LOCATION_DESCRIPTOR* location, 78 MINIDUMP_LOCATION_DESCRIPTOR* location,
79 FileWriterInterface* writer, 79 FileWriterInterface* writer,
80 const std::map<std::string, std::string>& dictionary) { 80 const std::map<std::string, std::string>& dictionary) {
81 std::vector<MinidumpSimpleStringDictionaryEntry> entries; 81 std::vector<MinidumpSimpleStringDictionaryEntry> entries;
82 for (const auto& it : dictionary) { 82 for (const auto& it : dictionary) {
83 MinidumpSimpleStringDictionaryEntry entry; 83 MinidumpSimpleStringDictionaryEntry entry;
84 entry.key = WriteString(writer, it.first); 84 entry.key = WriteString(writer, it.first);
85 entry.value = WriteString(writer, it.second); 85 entry.value = WriteString(writer, it.second);
86 entries.push_back(entry); 86 entries.push_back(entry);
87 } 87 }
88 88
89 location->Rva = static_cast<RVA>(writer->SeekGet()); 89 location->Rva = static_cast<RVA>(writer->SeekGet());
90 90
91 const uint32_t simple_string_dictionary_entries = entries.size(); 91 const uint32_t simple_string_dictionary_entries =
92 static_cast<uint32_t>(entries.size());
92 EXPECT_TRUE(writer->Write(&simple_string_dictionary_entries, 93 EXPECT_TRUE(writer->Write(&simple_string_dictionary_entries,
93 sizeof(simple_string_dictionary_entries))); 94 sizeof(simple_string_dictionary_entries)));
94 for (const MinidumpSimpleStringDictionaryEntry& entry : entries) { 95 for (const MinidumpSimpleStringDictionaryEntry& entry : entries) {
95 EXPECT_TRUE(writer->Write(&entry, sizeof(entry))); 96 EXPECT_TRUE(writer->Write(&entry, sizeof(entry)));
96 } 97 }
97 98
98 location->DataSize = 99 location->DataSize = static_cast<uint32_t>(
99 sizeof(simple_string_dictionary_entries) + 100 sizeof(simple_string_dictionary_entries) +
100 entries.size() * sizeof(MinidumpSimpleStringDictionaryEntry); 101 entries.size() * sizeof(MinidumpSimpleStringDictionaryEntry));
101 } 102 }
102 103
103 // Writes |strings| to |writer| as a MinidumpRVAList referencing 104 // Writes |strings| to |writer| as a MinidumpRVAList referencing
104 // MinidumpUTF8String objects, and populates |location| with a location 105 // MinidumpUTF8String objects, and populates |location| with a location
105 // descriptor identifying what was written. 106 // descriptor identifying what was written.
106 void WriteMinidumpStringList(MINIDUMP_LOCATION_DESCRIPTOR* location, 107 void WriteMinidumpStringList(MINIDUMP_LOCATION_DESCRIPTOR* location,
107 FileWriterInterface* writer, 108 FileWriterInterface* writer,
108 const std::vector<std::string>& strings) { 109 const std::vector<std::string>& strings) {
109 std::vector<RVA> rvas; 110 std::vector<RVA> rvas;
110 for (const std::string& string : strings) { 111 for (const std::string& string : strings) {
111 rvas.push_back(WriteString(writer, string)); 112 rvas.push_back(WriteString(writer, string));
112 } 113 }
113 114
114 location->Rva = static_cast<RVA>(writer->SeekGet()); 115 location->Rva = static_cast<RVA>(writer->SeekGet());
115 116
116 const uint32_t string_list_entries = rvas.size(); 117 const uint32_t string_list_entries = static_cast<uint32_t>(rvas.size());
117 EXPECT_TRUE(writer->Write(&string_list_entries, sizeof(string_list_entries))); 118 EXPECT_TRUE(writer->Write(&string_list_entries, sizeof(string_list_entries)));
118 for (RVA rva : rvas) { 119 for (RVA rva : rvas) {
119 EXPECT_TRUE(writer->Write(&rva, sizeof(rva))); 120 EXPECT_TRUE(writer->Write(&rva, sizeof(rva)));
120 } 121 }
121 122
122 location->DataSize = sizeof(string_list_entries) + rvas.size() * sizeof(RVA); 123 location->DataSize = static_cast<uint32_t>(sizeof(string_list_entries) +
124 rvas.size() * sizeof(RVA));
123 } 125 }
124 126
125 TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) { 127 TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) {
126 StringFile string_file; 128 StringFile string_file;
127 129
128 MINIDUMP_HEADER header = {}; 130 MINIDUMP_HEADER header = {};
129 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); 131 EXPECT_TRUE(string_file.Write(&header, sizeof(header)));
130 132
131 MinidumpCrashpadInfo crashpad_info = {}; 133 MinidumpCrashpadInfo crashpad_info = {};
132 crashpad_info.version = MinidumpCrashpadInfo::kVersion; 134 crashpad_info.version = MinidumpCrashpadInfo::kVersion;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 annotations_simple_map = modules[2]->AnnotationsSimpleMap(); 278 annotations_simple_map = modules[2]->AnnotationsSimpleMap();
277 EXPECT_EQ(dictionary_2, annotations_simple_map); 279 EXPECT_EQ(dictionary_2, annotations_simple_map);
278 280
279 annotations_vector = modules[2]->AnnotationsVector(); 281 annotations_vector = modules[2]->AnnotationsVector();
280 EXPECT_EQ(list_annotations_2, annotations_vector); 282 EXPECT_EQ(list_annotations_2, annotations_vector);
281 } 283 }
282 284
283 } // namespace 285 } // namespace
284 } // namespace test 286 } // namespace test
285 } // namespace crashpad 287 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/test/minidump_rva_list_test_util.cc ('k') | snapshot/win/process_reader_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698