Skip to content

Commit

Permalink
media: Add crash key for CDM version
Browse files Browse the repository at this point in the history
This makes it much easier to analyse CDM crashes.

Tested with --enable-crash-reporter-for-testing, which will upload
a crash report and print a crash ID to stdout. Then confirmed that
we have the CDM version in the crash report.

See crash ID 27c2f5df78d977e227 for an example crash.

BUG=788937

Change-Id: Ifa565f0d01a78cfef2329704ea3bc3feb9a5723a
Reviewed-on: https://chromium-review.googlesource.com/792258
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521805}
  • Loading branch information
xhwang-chromium authored and Commit Bot committed Dec 5, 2017
1 parent f0b716f commit c550dc1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions media/cdm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ source_set("cdm") {
deps += [
":cdm_api",
":cdm_paths",
"//components/crash/core/common:crash_key",
]
sources += [
"cdm_adapter.cc",
Expand Down
1 change: 1 addition & 0 deletions media/cdm/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+components/crash/core/common/crash_key.h",
"+crypto",
"+ppapi/cpp/logging.h",
]
12 changes: 11 additions & 1 deletion media/cdm/cdm_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/crash/core/common/crash_key.h"

#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
#include "media/cdm/cdm_host_files.h"
Expand Down Expand Up @@ -150,18 +151,27 @@ bool CdmModule::Initialize(const base::FilePath& cdm_path) {
library_.GetFunctionPointer("DeinitializeCdmModule"));
create_cdm_func_ = reinterpret_cast<CreateCdmFunc>(
library_.GetFunctionPointer("CreateCdmInstance"));
get_cdm_version_func_ = reinterpret_cast<GetCdmVersionFunc>(
library_.GetFunctionPointer("GetCdmVersion"));

if (!initialize_cdm_module_func_ || !deinitialize_cdm_module_func_ ||
!create_cdm_func_) {
!create_cdm_func_ || !get_cdm_version_func_) {
LOG(ERROR) << "Missing entry function in CDM at " << cdm_path.value();
initialize_cdm_module_func_ = nullptr;
deinitialize_cdm_module_func_ = nullptr;
create_cdm_func_ = nullptr;
get_cdm_version_func_ = nullptr;
library_.Release();
ReportLoadResult(LoadResult::kEntryPointMissing);
return false;
}

// In case of crashes, provide CDM version to facilitate investigation.
crash_reporter::InitializeCrashKeys();
static crash_reporter::CrashKeyString<32> cdm_version_key("cdm-version");
std::string cdm_version = get_cdm_version_func_();
cdm_version_key.Set(cdm_version);

#if defined(OS_WIN)
// Load DXVA before sandbox lockdown to give CDM access to Output Protection
// Manager (OPM).
Expand Down
2 changes: 2 additions & 0 deletions media/cdm/cdm_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MEDIA_EXPORT CdmModule {
private:
using InitializeCdmModuleFunc = void (*)();
using DeinitializeCdmModuleFunc = void (*)();
using GetCdmVersionFunc = char* (*)();

CdmModule();

Expand All @@ -68,6 +69,7 @@ class MEDIA_EXPORT CdmModule {
CreateCdmFunc create_cdm_func_ = nullptr;
InitializeCdmModuleFunc initialize_cdm_module_func_ = nullptr;
DeinitializeCdmModuleFunc deinitialize_cdm_module_func_ = nullptr;
GetCdmVersionFunc get_cdm_version_func_ = nullptr;

DISALLOW_COPY_AND_ASSIGN(CdmModule);
};
Expand Down

0 comments on commit c550dc1

Please sign in to comment.