Coverage for /Syzygy/kasko/client.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
89.7%35390.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    :  #include "syzygy/kasko/client.h"
  16    :  
  17    :  #include <vector>
  18    :  
  19    :  #include "base/logging.h"
  20    :  #include "base/threading/platform_thread.h"
  21    :  #include "syzygy/common/rpc/helpers.h"
  22    :  #include "syzygy/kasko/kasko_rpc.h"
  23    :  #include "syzygy/kasko/minidump_request.h"
  24    :  
  25    :  namespace kasko {
  26    :  
  27  E :  Client::Client(const base::string16& endpoint) : endpoint_(endpoint) {
  28  E :  }
  29    :  
  30  E :  Client::~Client(){
  31  E :  }
  32    :  
  33  E :  void Client::SendReport(const MinidumpRequest& request) const {
  34  E :    DumpType rpc_dump_type = SMALL_DUMP;
  35  E :    switch (request.type) {
  36    :      case MinidumpRequest::SMALL_DUMP_TYPE:
  37  E :        rpc_dump_type = SMALL_DUMP;
  38  E :        break;
  39    :      case MinidumpRequest::LARGER_DUMP_TYPE:
  40  E :        rpc_dump_type = LARGER_DUMP;
  41  E :        break;
  42    :      case MinidumpRequest::FULL_DUMP_TYPE:
  43  E :        rpc_dump_type = FULL_DUMP;
  44  E :        break;
  45    :      default:
  46  i :        NOTREACHED();
  47    :        break;
  48    :    }
  49    :  
  50    :    // Alias the crash key string buffers into the CrashKey array used for the RPC
  51    :    // invocation.
  52  E :    std::vector<CrashKey> rpc_crash_keys;
  53  E :    for (auto& client_crash_key : request.crash_keys) {
  54  E :      CrashKey rpc_crash_key = {client_crash_key.first, client_crash_key.second};
  55  E :      rpc_crash_keys.push_back(rpc_crash_key);
  56  E :    }
  57    :  
  58    :    // Alias the custom stream buffers into the CustomStream array used for the
  59    :    // RPC invocation.
  60  E :    std::vector<CustomStream> rpc_custom_streams;
  61  E :    for (auto& client_custom_stream : request.custom_streams) {
  62    :      CustomStream rpc_custom_stream = {
  63    :          client_custom_stream.type, client_custom_stream.length,
  64  E :          reinterpret_cast<const signed char*>(client_custom_stream.data)};
  65  E :      rpc_custom_streams.push_back(rpc_custom_stream);
  66  E :    }
  67    :  
  68  E :    std::vector<MemoryRange> rpc_memory_ranges;
  69  E :    for (auto& client_memory_range : request.user_selected_memory_ranges) {
  70    :      MemoryRange rpc_memory_range = {client_memory_range.start(),
  71  E :                                      client_memory_range.size()};
  72  E :      rpc_memory_ranges.push_back(rpc_memory_range);
  73  E :    }
  74    :  
  75  E :    DCHECK(!request.exception_info_address || request.client_exception_pointers);
  76    :  
  77    :    ::MinidumpRequest rpc_request = {
  78    :        request.client_exception_pointers ? request.exception_info_address : 0,
  79    :        base::PlatformThread::CurrentId(),
  80    :        rpc_dump_type,
  81    :        rpc_memory_ranges.size(),
  82    :        rpc_memory_ranges.size() ? rpc_memory_ranges.data() : nullptr,
  83    :        rpc_crash_keys.size(),
  84    :        rpc_crash_keys.size() ? rpc_crash_keys.data() : nullptr,
  85    :        rpc_custom_streams.size(),
  86  E :        rpc_custom_streams.size() ? rpc_custom_streams.data() : nullptr};
  87    :  
  88    :    // Establish the RPC binding.
  89  E :    common::rpc::ScopedRpcBinding rpc_binding;
  90  E :    if (!rpc_binding.Open(L"ncalrpc", endpoint_)) {
  91  i :      LOG(ERROR) << "Failed to open an RPC binding.";
  92  i :      return;
  93    :    }
  94    :  
  95    :    // Invoke SendDiagnosticReport via RPC.
  96    :    common::rpc::RpcStatus status = common::rpc::InvokeRpc(
  97  E :        KaskoClient_SendDiagnosticReport, rpc_binding.Get(), rpc_request);
  98    :  
  99  E :    if (!status.succeeded())
 100  i :      LOG(ERROR) << "Failed to invoke the SendDiagnosticReport RPC.";
 101  E :  }
 102    :  
 103    :  }  // namespace kasko

Coverage information generated Thu Jan 14 17:40:38 2016.