Coverage for /Syzygy/agent/asan/reporters/breakpad_reporter.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%550.C++source

Line-by-line coverage:

   1    :  // Copyright 2016 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    :  #ifndef SYZYGY_AGENT_ASAN_REPORTERS_BREAKPAD_REPORTER_H_
  16    :  #define SYZYGY_AGENT_ASAN_REPORTERS_BREAKPAD_REPORTER_H_
  17    :  
  18    :  #include <windows.h>
  19    :  #include <memory>
  20    :  
  21    :  #include "syzygy/agent/asan/reporter.h"
  22    :  #include "syzygy/agent/asan/reporters/exported_function.h"
  23    :  
  24    :  namespace agent {
  25    :  namespace asan {
  26    :  namespace reporters {
  27    :  
  28    :  // Implements Breakpad crash reporting integration.
  29    :  class BreakpadReporter : public ReporterInterface {
  30    :   public:
  31    :    // The main crash inducing function that Breakpad exports.
  32    :    using CrashForException = ExportedFunction<
  33    :        int __cdecl(EXCEPTION_POINTERS* info)>;
  34    :    // Signatures of Breakpad-related functions for setting crash keys. This
  35    :    // API has evolved over time, so multiple signatures are supported.
  36    :    // Post r194002.
  37    :    using SetCrashKeyValuePair = ExportedFunction<
  38    :        void __cdecl(const char* key, const char* value)>;
  39    :    // Post r217590.
  40    :    using SetCrashKeyValueImpl = ExportedFunction<
  41    :        void __cdecl(const wchar_t* key, const wchar_t* value)>;
  42    :  
  43    :    // Expected Breakpad crash reporter functions. This allows functions
  44    :    // to be injected for testing.
  45    :    struct BreakpadFunctions {
  46    :      CrashForException crash_for_exception;
  47    :      SetCrashKeyValuePair set_crash_key_value_pair;
  48    :      SetCrashKeyValueImpl set_crash_key_value_impl;
  49    :    };
  50    :  
  51    :    // Factory for a BreakpadReporter. This returns null if the running process
  52    :    // does not support Breakpad crash reporting. Support is decided by examining
  53    :    // the exports of the running executable, and looking for Breakpad's expected
  54    :    // exports.
  55    :    // @returns an allocated BreakpadReporter
  56    :    static std::unique_ptr<BreakpadReporter> Create();
  57    :  
  58    :    // Helper to determine if a given set of functions is valid.
  59    :    // @param breakpad_functions The functions to evaluate.
  60    :    // @returns true on success, false otherwise.
  61    :    static bool AreValid(const BreakpadFunctions& breakpad_functions);
  62    :  
  63    :    // Constructor with specified functions.
  64  E :    explicit BreakpadReporter(const BreakpadFunctions& breakpad_functions)
  65  E :        : breakpad_functions_(breakpad_functions) {
  66  E :      DCHECK(AreValid(breakpad_functions_));
  67  E :    }
  68    :  
  69  E :    virtual ~BreakpadReporter() {}
  70    :  
  71    :    // @name ReporterInterface implementation.
  72    :    // @{
  73    :    const char* GetName() const override;
  74    :    uint32_t GetFeatures() const override;
  75    :    bool SetCrashKey(base::StringPiece key, base::StringPiece value) override;
  76    :    bool SetMemoryRanges(const MemoryRanges& memory_ranges) override;
  77    :    bool SetCustomStream(uint32_t stream_type,
  78    :                         const uint8_t* stream_data,
  79    :                         size_t stream_length) override;
  80    :    void DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) override;
  81    :    bool DumpWithoutCrash(const CONTEXT& context) override;
  82    :    // @}
  83    :  
  84    :   private:
  85    :    // The breakpad functions to use.
  86    :    BreakpadFunctions breakpad_functions_;
  87    :  
  88    :    DISALLOW_COPY_AND_ASSIGN(BreakpadReporter);
  89    :  };
  90    :  
  91    :  }  // namespace reporters
  92    :  }  // namespace asan
  93    :  }  // namespace agent
  94    :  
  95    :  #endif  // SYZYGY_AGENT_ASAN_REPORTERS_BREAKPAD_REPORTER_H_

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