Coverage for /Syzygy/kasko/client.cc

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

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