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 allows reading the content of the symbol record table from a PDB
16 : // stream.
17 :
18 : #ifndef SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
19 : #define SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
20 :
21 : #include <vector>
22 :
23 : #include "base/basictypes.h"
24 : #include "base/callback.h"
25 : #include "syzygy/pdb/pdb_data_types.h"
26 :
27 m : namespace pdb {
28 :
29 : // Forward declarations.
30 m : class PdbStream;
31 :
32 : // Read a symbol record table from a Pdb stream.
33 : // @param stream The stream containing the table.
34 : // @param symbol_table_size The size of the symbol record table.
35 : // @param symbol_vector The vector where the symbol records should be stored.
36 : // @returns true on success, false otherwise.
37 m : bool ReadSymbolRecord(PdbStream* stream,
38 m : size_t symbol_table_size,
39 m : SymbolRecordVector* symbol_vector);
40 :
41 : // Defines a symbol visitor callback. This needs to return true on success
42 : // (indicating that the symbol visitor should continue), and false on failure
43 : // (indicating that it should terminate). The stream is positioned at the
44 : // beginning of the symbol data, which is of the provided length, the type
45 : // having already been read from the stream.
46 m : typedef base::Callback<bool(uint16 /* symbol_length */,
47 m : uint16 /* symbol_type */,
48 m : PdbStream* /* symbol_stream */)>
49 m : VisitSymbolsCallback;
50 :
51 : // Reads symbols from the given symbol stream until the end of the stream.
52 : // @param callback The callback to be invoked for each symbol.
53 : // @param symbol_table_size The size of the symbol record table.
54 : // @param has_header If true then this will first parse the symbol stream
55 : // header and ensure it is of the expected type. If false it will assume
56 : // it is the expected type and start parsing symbols immediately.
57 : // @param symbols The stream containing symbols to be visited. The stream
58 : // will be read starting from its current position, and will be advanced
59 : // past the symbols one by one.
60 : // @returns true on success, false otherwise.
61 m : bool VisitSymbols(VisitSymbolsCallback callback,
62 m : size_t symbol_table_size,
63 m : bool has_header,
64 m : PdbStream* symbols);
65 :
66 m : } // namespace pdb
67 :
68 : #endif // SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
|