Coverage for /Syzygy/agent/asan/reporter.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%220.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    :  // This class abstracts away various different crash reporting systems that
  16    :  // SyzyASan is able to interact with.
  17    :  
  18    :  #ifndef SYZYGY_AGENT_ASAN_REPORTER_H_
  19    :  #define SYZYGY_AGENT_ASAN_REPORTER_H_
  20    :  
  21    :  #include <cstdint>
  22    :  #include <utility>
  23    :  #include <vector>
  24    :  
  25    :  #include "base/strings/string_piece.h"
  26    :  
  27    :  namespace agent {
  28    :  namespace asan {
  29    :  
  30    :  // Interface for a crash reporter.
  31    :  class ReporterInterface {
  32    :   public:
  33    :    // This is the stream type defined to hold the Crashdata protobuf.
  34    :    // This was initially defined by Kasko, but is reused elsewhere.
  35    :    enum : uint32_t { kCrashdataProtobufStreamType = 0x4B6B0001 };
  36    :  
  37    :    // An enumeration of the features supported by this crash reporter. This
  38    :    // is a bitmask.
  39    :    enum Features : uint32_t {
  40    :      // Supports a crash keys metadata mechanism.
  41    :      FEATURE_CRASH_KEYS = (1 << 0),
  42    :  
  43    :      // Supports crash keys that can be set during RTL initialization, ie.
  44    :      // under the loader's lock.
  45    :      FEATURE_EARLY_CRASH_KEYS = (1 << 1),
  46    :  
  47    :      // Supports memory ranges.
  48    :      FEATURE_MEMORY_RANGES = (1 << 2),
  49    :  
  50    :      // Supports custom minidump streams.
  51    :      FEATURE_CUSTOM_STREAMS = (1 << 3),
  52    :  
  53    :      // Supports reporting without crashing.
  54    :      FEATURE_DUMP_WITHOUT_CRASH = (1 << 4),
  55    :    };
  56    :  
  57    :    // A memory range is expressed as a pointer and a length.
  58    :    using MemoryRange = std::pair<const char*, size_t>;
  59    :    using MemoryRanges = std::vector<MemoryRange>;
  60    :  
  61  E :    ReporterInterface() {}
  62  E :    virtual ~ReporterInterface() {}
  63    :  
  64    :    // @returns the name of this crash reporter.
  65    :    virtual const char* GetName() const = 0;
  66    :  
  67    :    // @returns the feature set of this crash reporter.
  68    :    virtual uint32_t GetFeatures() const = 0;
  69    :  
  70    :    // Sets a crash key. This may fail if crash keys are unsupported by the
  71    :    // crash reporter, or if the crash keys are otherwise invalid. The definition
  72    :    // of invalid depends on the reporter implementation.
  73    :    // @param key The crash key.
  74    :    // @param value The crash key value.
  75    :    // @returns true on success, false otherwise.
  76    :    virtual bool SetCrashKey(base::StringPiece key,
  77    :                             base::StringPiece value) = 0;
  78    :  
  79    :    // Sets a bag of memory ranges to be included in a crash report. This may
  80    :    // fail if the underlying crash reporter doesn't support the mechanism. This
  81    :    // has override semantics, so calling this will replace the values stored
  82    :    // in any previous calls.
  83    :    // @param memory_ranges The memory ranges to include in the report.
  84    :    // @returns true on success, false otherwise.
  85    :    virtual bool SetMemoryRanges(const MemoryRanges& memory_ranges) = 0;
  86    :  
  87    :    // Sets a custom stream to include with a crash report. For a given
  88    :    // @p stream_type this has override semantics. To erase a given stream
  89    :    // call this with nullptr @p stream_data and @p stream_length of zero.
  90    :    // @param stream_type The type of the stream to add. This should normally
  91    :    //     be larger than MINIDUMP_STREAM_TYPE::LastReservedStream, which is
  92    :    //     0xFFFF.
  93    :    // @param stream_data A pointer to the stream data. This is owned by the
  94    :    //     caller and must remain valid forever after being added.
  95    :    // @param stream_length The length of the stream.
  96    :    // @returns true on success, false otherwise.
  97    :    virtual bool SetCustomStream(uint32_t stream_type,
  98    :                                 const uint8_t* stream_data,
  99    :                                 size_t stream_length) = 0;
 100    :  
 101    :    // Crashes the running process and sends a crash report. This function
 102    :    // should not return, so users should follow it with a NOTREACHED to
 103    :    // ensure safety.
 104    :    // @param exception_pointers The exception pointers to use in the crash.
 105    :    virtual void DumpAndCrash(EXCEPTION_POINTERS* exception_pointers) = 0;
 106    :  
 107    :    // Generates a crash report, but continues running and returns.
 108    :    // @param context The context to use in the crash report.
 109    :    // @param returns true on success, false otherwise.
 110    :    virtual bool DumpWithoutCrash(const CONTEXT& context) = 0;
 111    :  
 112    :   private:
 113    :    DISALLOW_COPY_AND_ASSIGN(ReporterInterface);
 114    :  };
 115    :  
 116    :  }  // namespace asan
 117    :  }  // namespace agent
 118    :  
 119    :  #endif  // SYZYGY_AGENT_ASAN_REPORTER_H_

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