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

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

Issue 972383002: snapshot: Add a minimal ModuleSnapshotMinidump and accessor from ProcessSnapshotMinidump (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "snapshot/minidump/minidump_string_list_reader.h"
16
17 #include "base/logging.h"
18 #include "minidump/minidump_extensions.h"
19 #include "snapshot/minidump/minidump_string_reader.h"
20
21 namespace crashpad {
22 namespace internal {
23
24 bool ReadMinidumpStringList(FileReaderInterface* file_reader,
25 const MINIDUMP_LOCATION_DESCRIPTOR& location,
26 std::vector<std::string>* list) {
27 list->clear();
28
29 if (location.Rva == 0) {
30 return true;
31 }
32
33 if (location.DataSize < sizeof(MinidumpRVAList)) {
34 LOG(ERROR) << "string_list size mismatch";
35 return false;
36 }
37
38 if (!file_reader->SeekSet(location.Rva)) {
39 return false;
40 }
41
42 uint32_t entry_count;
43 if (!file_reader->ReadExactly(&entry_count, sizeof(entry_count))) {
44 return false;
45 }
46
47 if (location.DataSize !=
48 sizeof(MinidumpRVAList) + entry_count * sizeof(RVA)) {
49 LOG(ERROR) << "string_list size mismatch";
50 return false;
51 }
52
53 std::vector<RVA> rvas(entry_count);
54 if (!file_reader->ReadExactly(&rvas[0], entry_count * sizeof(rvas[0]))) {
55 return false;
56 }
57
58 for (RVA rva : rvas) {
59 std::string element;
60 if (!ReadMinidumpUTF8String(file_reader, rva, &element)) {
61 // Not a hard error, keep trying.
62 continue;
63 }
64
65 list->push_back(element);
66 }
67
68 return true;
69 }
70
71 } // namespace internal
72 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698