Coverage for /Syzygy/pdb/pdb_symbol_record.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
77.8%21270.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc.
   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/pdb/pdb_symbol_record.h"
  16    :  
  17    :  #include <string>
  18    :  
  19    :  #include "base/stringprintf.h"
  20    :  #include "syzygy/common/align.h"
  21    :  #include "syzygy/pdb/pdb_reader.h"
  22    :  #include "syzygy/pdb/pdb_util.h"
  23    :  
  24    :  namespace pdb {
  25    :  
  26    :  bool ReadSymbolRecord(PdbStream* stream,
  27    :                        size_t symbol_table_size,
  28  E :                        SymbolRecordVector* symbol_vector) {
  29  E :    DCHECK(stream != NULL);
  30  E :    DCHECK(symbol_vector != NULL);
  31    :  
  32  E :    size_t stream_end = stream->pos() + symbol_table_size;
  33  E :    if (stream_end > stream->length()) {
  34  i :      LOG(ERROR) << "The specified symbol table size exceeds the size of the "
  35    :                 << "stream.";
  36  i :      return false;
  37    :    }
  38    :  
  39    :    // Process each symbol present in the stream. For now we only save their
  40    :    // starting positions, their lengths and their types to be able to dump them.
  41  E :    while (stream->pos() < stream_end) {
  42  E :      uint16 len = 0;
  43  E :      uint16 symbol_type = 0;
  44  E :      if (!stream->Read(&len, 1)) {
  45  i :        LOG(ERROR) << "Unable to read a symbol record length.";
  46  i :        return false;
  47    :      }
  48  E :      size_t symbol_start = stream->pos();
  49  E :      if (!stream->Read(&symbol_type, 1))  {
  50  i :        LOG(ERROR) << "Unable to read a symbol record type.";
  51  i :        return false;
  52    :      }
  53    :      SymbolRecord sym_record;
  54  E :      sym_record.type = symbol_type;
  55  E :      sym_record.start_position = stream->pos();
  56  E :      sym_record.len = len - sizeof(symbol_type);
  57  E :      symbol_vector->push_back(sym_record);
  58  E :      if (stream->pos() != stream_end && !stream->Seek(symbol_start + len)) {
  59  E :        LOG(ERROR) << "Unable to seek to the end of the symbol record.";
  60  E :        return false;
  61    :      }
  62  E :    }
  63    :  
  64  E :    return true;
  65  E :  }
  66    :  
  67    :  }  // namespace pdb

Coverage information generated Thu Sep 06 11:30:46 2012.