Coverage for /Syzygy/trace/logger/logger.h

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

Line-by-line coverage:

   1    :  // Copyright 2012 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 file declares the trace::logger::Logger class which implements
  16    :  // a simple logging service over RPC.
  17    :  
  18    :  #ifndef SYZYGY_TRACE_LOGGER_LOGGER_H_
  19    :  #define SYZYGY_TRACE_LOGGER_LOGGER_H_
  20    :  
  21    :  #include "base/callback.h"
  22    :  #include "base/file_util.h"
  23    :  #include "base/message_loop.h"
  24    :  #include "base/process.h"
  25    :  #include "base/string_piece.h"
  26    :  #include "base/threading/platform_thread.h"
  27    :  #include "syzygy/trace/common/service.h"
  28    :  #include "syzygy/trace/rpc/logger_rpc.h"
  29    :  
  30    :  namespace trace {
  31    :  namespace logger {
  32    :  
  33    :  // Implements the Logger interface (see "logger_rpc.idl").
  34    :  //
  35    :  // Note: The Logger expects to be the only RPC service running in the process.
  36    :  class Logger : public trace::common::Service {
  37    :   public:
  38    :    Logger();
  39    :    virtual ~Logger();
  40    :  
  41    :    // Set the destination file for this logger.
  42  E :    void set_destination(FILE* destination) {
  43  E :      DCHECK(destination != NULL);
  44  E :      destination_ = destination;
  45  E :    }
  46    :  
  47    :    // Get/Set the directory to which minidumps should be written.
  48    :    // @{
  49  E :    const base::FilePath& minidump_dir() const { return minidump_dir_; }
  50  E :    void set_minidump_dir(const base::FilePath& dir) { minidump_dir_ = dir; }
  51    :    // @}
  52    :  
  53    :    // Append a trace dump for @p process, given @p trace_data containing
  54    :    // @p trace_length elements. The output will be appended to @p message.
  55    :    //
  56    :    // Note that the DWORD elements of @p trace_data are really void* values
  57    :    // pointing to the frame pointers of a call stack in @p process.
  58    :    //
  59    :    // Calls to this method are serialized under symbol_lock_.
  60    :    bool AppendTrace(HANDLE process,
  61    :                     const DWORD* trace_data,
  62    :                     size_t trace_length,
  63    :                     std::string* message);
  64    :  
  65    :    // Captures a stack trace in a @p process given a program @p context.
  66    :    // @param process An open handle to the running process.
  67    :    // @param context The program context from which to trace.
  68    :    // @param trace_data The vector into which the trace will be populated.
  69    :    // @returns true on success, false otherwise.
  70    :    bool CaptureRemoteTrace(HANDLE process,
  71    :                            CONTEXT* context,
  72    :                            std::vector<DWORD>* trace_data);
  73    :  
  74    :    // Write @p message to the log destination. Note that calls to this method
  75    :    // are serialized using write_lock_.
  76    :    bool Write(const base::StringPiece& message);
  77    :  
  78    :    // Generate a minidump for the calling process.
  79    :    // @param process An open handle to the running process.
  80    :    // @param pid The process id of the process to dump.
  81    :    // @param tid The thread id (in the process to dump) of the thread which is
  82    :    //     causing the minidump to be generated.
  83    :    // @param exc_ptr The pointer value (in the memory address space of the
  84    :    //     process to dump) of the exception record for which the dump is being
  85    :    //     generated.
  86    :    // @param flags Reserved.
  87    :    // @returns true on success, false otherwise.
  88    :    bool SaveMiniDump(HANDLE process,
  89    :                      base::ProcessId pid,
  90    :                      DWORD tid,
  91    :                      DWORD exc_ptr,
  92    :                      DWORD flags);
  93    :  
  94    :   protected:
  95    :    // @name Implementation of Service.
  96    :    // @{
  97    :    virtual bool StartImpl();
  98    :    virtual bool StopImpl();
  99    :    virtual bool JoinImpl();
 100    :    // @}
 101    :  
 102    :    // @name RPC Server Management Functions.
 103    :    // These functions, unless otherwise noted, are single threaded and must
 104    :    // all be called from the thread that created this instance.
 105    :    // @{
 106    :    bool InitRpc();
 107    :    bool StartRpc();
 108    :    bool StopRpc();  // This non-blocking function may be called from any thread.
 109    :    bool FinishRpc();  // This function is blocking.
 110    :    // @}
 111    :  
 112    :    // The file to which received log messages should be written. This must
 113    :    // remain valid for at least as long as the logger is valid. Writes to
 114    :    // the destination are serialized with lock_;
 115    :    FILE* destination_;
 116    :  
 117    :    // The directory to which minidumps should be written.
 118    :    base::FilePath minidump_dir_;
 119    :  
 120    :    // The lock used to serializes writes to destination_;
 121    :    base::Lock write_lock_;
 122    :  
 123    :    // The lock used to serialize access to the debug help library used to
 124    :    // symbolize traces.
 125    :    base::Lock symbol_lock_;
 126    :  
 127    :   private:
 128    :    DISALLOW_COPY_AND_ASSIGN(Logger);
 129    :  };
 130    :  
 131    :  }  // namespace logger
 132    :  }  // namespace trace
 133    :  
 134    :  #endif  // SYZYGY_TRACE_LOGGER_LOGGER_H_

Coverage information generated Tue Jun 25 13:56:24 2013.