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

Side by Side Diff: snapshot/win/pe_image_annotations_reader.cc

Issue 1138923004: win: Retrieve "simple map" annotations from modules (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@module-version
Patch Set: . Created 5 years, 6 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/win/pe_image_annotations_reader.h"
16
17 #include <string.h>
18
19 #include "base/strings/utf_string_conversions.h"
20 #include "client/simple_string_dictionary.h"
21 #include "snapshot/win/pe_image_reader.h"
22 #include "snapshot/win/process_reader_win.h"
23
24 namespace crashpad {
25
26 PEImageAnnotationsReader::PEImageAnnotationsReader(
27 ProcessReaderWin* process_reader,
28 const PEImageReader* pe_image_reader,
29 const std::wstring& name)
30 : name_(name),
31 process_reader_(process_reader),
32 pe_image_reader_(pe_image_reader) {
33 }
34
35 std::map<std::string, std::string> PEImageAnnotationsReader::SimpleMap() const {
36 std::map<std::string, std::string> simple_map_annotations;
37 ReadCrashpadSimpleAnnotations(&simple_map_annotations);
38 return simple_map_annotations;
39 }
40
41 void PEImageAnnotationsReader::ReadCrashpadSimpleAnnotations(
42 std::map<std::string, std::string>* simple_map_annotations) const {
43 process_types::CrashpadInfo crashpad_info;
44 if (!pe_image_reader_->GetCrashpadInfo(&crashpad_info))
45 return;
46
47 if (!crashpad_info.simple_annotations)
48 return;
49
50 std::vector<SimpleStringDictionary::Entry>
51 simple_annotations(SimpleStringDictionary::num_entries);
52 if (!process_reader_->ReadMemory(
53 crashpad_info.simple_annotations,
54 simple_annotations.size() * sizeof(simple_annotations[0]),
55 &simple_annotations[0])) {
56 LOG(WARNING) << "could not read simple annotations from "
57 << base::UTF16ToUTF8(name_);
58 return;
59 }
60
61 for (const auto& entry : simple_annotations) {
62 size_t key_length = strnlen(entry.key, sizeof(entry.key));
63 if (key_length) {
64 std::string key(entry.key, key_length);
65 std::string value(entry.value, strnlen(entry.value, sizeof(entry.value)));
66 if (!simple_map_annotations->insert(std::make_pair(key, value)).second) {
67 LOG(INFO) << "duplicate simple annotation " << key << " in "
68 << base::UTF16ToUTF8(name_);
69 }
70 }
71 }
72 }
73
74 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/win/pe_image_annotations_reader.h ('k') | snapshot/win/pe_image_annotations_reader_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698