1 : // Copyright 2015 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 : #ifndef SYZYGY_REFINERY_TYPES_PDB_CRAWLER_H_
16 : #define SYZYGY_REFINERY_TYPES_PDB_CRAWLER_H_
17 :
18 : #include "base/containers/hash_tables.h"
19 : #include "base/files/file_path.h"
20 : #include "syzygy/pdb/pdb_stream.h"
21 :
22 m : namespace refinery {
23 : // Forward declaration.
24 m : class TypeRepository;
25 :
26 : // A worker class to scrape types from PDB symbols using type info enumerator.
27 : // TODO(manzagop): ensure duplicate types are properly dealt with. The current
28 : // implementation generates equivalent types due to:
29 : // - basic types that are mapped to the same type (eg T_LONG and T_INT4)
30 : // - UDTs that are identical up to extra LF_NESTTYPE (which do not make it to
31 : // our type representation)
32 : // - pointers: Foo* and Foo*const will lead to the creation of 2 Foo* types.
33 m : class PdbCrawler {
34 m : public:
35 m : PdbCrawler();
36 m : ~PdbCrawler();
37 :
38 : // Initializes this crawler for the file at @p path.
39 : // @param path the image file whose symbols to crawl for types.
40 m : bool InitializeForFile(const base::FilePath& path);
41 :
42 : // Retrieves all @p types associated with the file this instance
43 : // is initialized to.
44 : // @param types on success contains zero or more types.
45 : // @returns true on success, false on failure.
46 m : bool GetTypes(TypeRepository* types);
47 :
48 m : private:
49 : // Pointer to the PDB type info stream.
50 m : scoped_refptr<pdb::PdbStream> stream_;
51 m : };
52 :
53 m : } // namespace refinery
54 :
55 : #endif // SYZYGY_REFINERY_TYPES_PDB_CRAWLER_H_
|