forked from chromium/crashpad
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include string annotation objects when uploading crash reports.
This extracts string annotation objects from the minidumps and includes them as form POST key-value pairs. This change also starts building a crashpad_handler_test binary on Mac. Bug: crashpad:192 Change-Id: I68cbf6fda6f1e57c1e621d5e3de8717cfaea65bf Reviewed-on: https://chromium-review.googlesource.com/749793 Commit-Queue: Robert Sesek <[email protected]> Reviewed-by: Mark Mentovai <[email protected]>
- Loading branch information
Showing
7 changed files
with
289 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2017 The Crashpad Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "handler/minidump_to_upload_parameters.h" | ||
|
||
#include "base/logging.h" | ||
#include "client/annotation.h" | ||
#include "snapshot/module_snapshot.h" | ||
#include "util/stdlib/map_insert.h" | ||
|
||
namespace crashpad { | ||
|
||
namespace { | ||
|
||
void InsertOrReplaceMapEntry(std::map<std::string, std::string>* map, | ||
const std::string& key, | ||
const std::string& value) { | ||
std::string old_value; | ||
if (!MapInsertOrReplace(map, key, value, &old_value)) { | ||
LOG(WARNING) << "duplicate key " << key << ", discarding value " | ||
<< old_value; | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
std::map<std::string, std::string> BreakpadHTTPFormParametersFromMinidump( | ||
const ProcessSnapshot* process_snapshot) { | ||
std::map<std::string, std::string> parameters = | ||
process_snapshot->AnnotationsSimpleMap(); | ||
|
||
std::string list_annotations; | ||
for (const ModuleSnapshot* module : process_snapshot->Modules()) { | ||
for (const auto& kv : module->AnnotationsSimpleMap()) { | ||
if (!parameters.insert(kv).second) { | ||
LOG(WARNING) << "duplicate key " << kv.first << ", discarding value " | ||
<< kv.second; | ||
} | ||
} | ||
|
||
for (std::string annotation : module->AnnotationsVector()) { | ||
list_annotations.append(annotation); | ||
list_annotations.append("\n"); | ||
} | ||
|
||
for (const AnnotationSnapshot& annotation : module->AnnotationObjects()) { | ||
if (annotation.type != static_cast<uint16_t>(Annotation::Type::kString)) { | ||
continue; | ||
} | ||
|
||
std::string value(reinterpret_cast<const char*>(annotation.value.data()), | ||
annotation.value.size()); | ||
std::pair<std::string, std::string> entry(annotation.name, value); | ||
if (!parameters.insert(entry).second) { | ||
LOG(WARNING) << "duplicate annotation name " << annotation.name | ||
<< ", discarding value " << value; | ||
} | ||
} | ||
} | ||
|
||
if (!list_annotations.empty()) { | ||
// Remove the final newline character. | ||
list_annotations.resize(list_annotations.size() - 1); | ||
|
||
InsertOrReplaceMapEntry(¶meters, "list_annotations", list_annotations); | ||
} | ||
|
||
UUID client_id; | ||
process_snapshot->ClientID(&client_id); | ||
InsertOrReplaceMapEntry(¶meters, "guid", client_id.ToString()); | ||
|
||
return parameters; | ||
} | ||
|
||
} // namespace crashpad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2017 The Crashpad Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef HANDLER_MINIDUMP_TO_UPLOAD_PARAMETERS_H_ | ||
#define HANDLER_MINIDUMP_TO_UPLOAD_PARAMETERS_H_ | ||
|
||
#include <map> | ||
#include <string> | ||
|
||
#include "snapshot/process_snapshot.h" | ||
|
||
namespace crashpad { | ||
|
||
//! \brief Given a ProcessSnapshot, returns a map of key-value pairs to use as | ||
//! HTTP form parameters for upload to a Breakpad crash report colleciton | ||
//! server. | ||
//! | ||
//! The map is built by combining the process simple annotations map with | ||
//! each module’s simple annotations map and annotation objects. | ||
//! | ||
//! In the case of duplicate simple map keys or annotation names, the map will | ||
//! retain the first value found for any key, and will log a warning about | ||
//! discarded values. The precedence rules for annotation names are: the two | ||
//! reserved keys discussed below, process simple annotations, module simple | ||
//! annotations, and module annotation objects. | ||
//! | ||
//! For annotation objects, only ones of that are Annotation::Type::kString are | ||
//! included. | ||
//! | ||
//! Each module’s annotations vector is also examined and built into a single | ||
//! string value, with distinct elements separated by newlines, and stored at | ||
//! the key named “list_annotations”, which supersedes any other key found by | ||
//! that name. | ||
//! | ||
//! The client ID stored in the minidump is converted to a string and stored at | ||
//! the key named “guid”, which supersedes any other key found by that name. | ||
//! | ||
//! In the event of an error reading the minidump file, a message will be | ||
//! logged. | ||
//! | ||
//! \param[in] process_snapshot The process snapshot from which annotations | ||
//! will be extracted. | ||
//! | ||
//! \returns A string map of the annotations. | ||
std::map<std::string, std::string> BreakpadHTTPFormParametersFromMinidump( | ||
const ProcessSnapshot* process_snapshot); | ||
|
||
} // namespace crashpad | ||
|
||
#endif // HANDLER_MINIDUMP_TO_UPLOAD_PARAMETERS_H_ |
Oops, something went wrong.