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