Coverage for /Syzygy/poirot/minidump_processor.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
81.8%27330.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/poirot/minidump_processor.h"
  16    :  
  17    :  #include <string>
  18    :  
  19    :  #include "base/logging.h"
  20    :  #include "syzygy/crashdata/json.h"
  21    :  #include "syzygy/kasko/api/client.h"
  22    :  #include "syzygy/minidump/minidump.h"
  23    :  
  24    :  namespace poirot {
  25    :  
  26    :  MinidumpProcessor::MinidumpProcessor(const base::FilePath& input_minidump)
  27  E :      : input_minidump_(input_minidump), processed_(false) {
  28  E :  }
  29    :  
  30  E :  bool MinidumpProcessor::ProcessDump() {
  31  E :    DCHECK(!input_minidump_.empty());
  32  E :    DCHECK(!processed_);
  33  E :    minidump::FileMinidump minidump;
  34    :  
  35  E :    if (!minidump.Open(input_minidump_)) {
  36  E :      LOG(ERROR) << "Unable to open the minidump.";
  37  E :      return false;
  38    :    }
  39    :  
  40    :    // Get the Kasko stream from the minidump.
  41    :    minidump::Minidump::Stream stream =
  42  E :        minidump.FindNextStream(nullptr, kasko::api::kProtobufStreamType);
  43  E :    if (!stream.IsValid()) {
  44  E :      LOG(ERROR) << "Unable to read the Kasko stream.";
  45  E :      return false;
  46    :    }
  47    :  
  48    :    // Read the stream content and initialize the protobuf with it.
  49  E :    std::string stream_content;
  50  E :    if (!stream.ReadAndAdvanceBytes(stream.remaining_length(), &stream_content)) {
  51  i :      LOG(ERROR) << "Unable to read the minidump bytes.";
  52  i :      return false;
  53    :    }
  54  E :    if (!protobuf_value_.ParseFromString(stream_content)) {
  55  i :      LOG(ERROR) << "Unable to parse the protobuf from the Kasko stream.";
  56  i :      return false;
  57    :    }
  58  E :    processed_ = true;
  59  E :    return true;
  60  E :  }
  61    :  
  62  E :  bool MinidumpProcessor::GenerateJsonOutput(FILE* file) {
  63  E :    DCHECK_NE(static_cast<FILE*>(nullptr), file);
  64  E :    DCHECK(processed_);
  65    :  
  66  E :    std::string out_str;
  67  E :    if (!crashdata::ToJson(true, &protobuf_value_, &out_str)) {
  68  i :      LOG(ERROR) << "Unable to convert the protobuf to JSON.";
  69  i :      return false;
  70    :    }
  71  E :    ::fprintf(file, "%s", out_str.c_str());
  72  E :    return true;
  73  E :  }
  74    :  
  75    :  } // namespace poirot

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