Coverage for /Syzygy/integration_tests/report_crash_with_protobuf_export.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
64.7%11170.C++source

Line-by-line coverage:

   1    :  // Copyright 2015 Google Inc. 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    :  // This file exports ReportCrashWithProtobuf, which is an optional API that
  16    :  // instrumented processes may export (from their executable module) in order to
  17    :  // handle SyzyASAN reports. The exit code from this method is used to verify
  18    :  // SyzyASAN functionality in instrument_integration_test.cc .
  19    :  //
  20    :  // This export, along with SetCrashKeyValueImpl, is expected of a Kasko crash
  21    :  // reporter enabled binary. If either ReportCrashWithProtobuf or
  22    :  // ReportCrashWithProtobufAndMemoryRanges is available, the RTL will use these
  23    :  // preferentially rather than the Breakpad exports provided by
  24    :  // crash_for_exception_export.cc .
  25    :  
  26    :  #include <windows.h>
  27    :  
  28    :  #include "base/environment.h"
  29    :  #include "syzygy/crashdata/crashdata.h"
  30    :  #include "syzygy/crashdata/json.h"
  31    :  
  32  E :  void Exit(UINT code) {
  33  E :    ::TerminateProcess(::GetCurrentProcess(), code);
  34  E :  }
  35    :  
  36    :  extern "C" void __declspec(dllexport)
  37    :      ReportCrashWithProtobuf(EXCEPTION_POINTERS* info,
  38    :                              const char* protobuf,
  39  E :                              size_t protobuf_length) {
  40    :    // Bail if there was no protobuf.
  41  E :    if (protobuf == nullptr || protobuf_length == 0)
  42  i :      Exit(97);
  43    :  
  44    :    // Parse the protobuf and bail if that fails.
  45  E :    crashdata::Value value;
  46  E :    if (!value.ParseFromArray(protobuf, protobuf_length))
  47  i :      ::Exit(97);
  48    :  
  49    :    // A useful debugging hack.
  50  E :    std::unique_ptr<base::Environment> env(base::Environment::Create());
  51  E :    if (env->HasVar("SYZYGY_ASAN_DUMP_PROTOBUF_ON_CRASH")) {
  52  i :      std::string json;
  53  i :      crashdata::ToJson(true, &value, &json);
  54  i :      ::printf("%s", json.c_str());
  55  i :    }
  56    :  
  57  E :    Exit(98);
  58  E :  }

Coverage information generated Fri Jul 29 11:00:21 2016.