| OLD | NEW |
| 1 // Copyright 2015 Google Inc. All Rights Reserved. | 1 // Copyright 2015 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "syzygy/refinery/symbols/simple_cache.h" | 25 #include "syzygy/refinery/symbols/simple_cache.h" |
| 26 #include "syzygy/refinery/types/type_repository.h" | 26 #include "syzygy/refinery/types/type_repository.h" |
| 27 | 27 |
| 28 namespace refinery { | 28 namespace refinery { |
| 29 | 29 |
| 30 // Fwd. | 30 // Fwd. |
| 31 class ProcessState; | 31 class ProcessState; |
| 32 | 32 |
| 33 // The SymbolProvider provides symbol information. See DiaSymbolProvider for an | 33 // The SymbolProvider provides symbol information. See DiaSymbolProvider for an |
| 34 // alternative. | 34 // alternative. |
| 35 // TODO(manzagop): get rid of the functions that take in a process state. The |
| 36 // symbol provider shouldn't offer that service. |
| 35 class SymbolProvider : public base::RefCounted<SymbolProvider> { | 37 class SymbolProvider : public base::RefCounted<SymbolProvider> { |
| 36 public: | 38 public: |
| 37 SymbolProvider(); | 39 SymbolProvider(); |
| 38 ~SymbolProvider(); | 40 // @note virtual to enable mocking. |
| 41 virtual ~SymbolProvider(); |
| 39 | 42 |
| 40 // Retrieves or creates a TypeRepository for the module within @p | 43 // Retrieves or creates a TypeRepository for the module within @p |
| 41 // process_state corresponding to @p va. | 44 // process_state corresponding to @p va. |
| 42 // @param va virtual address within a module for which to get a | 45 // @param va virtual address within a module for which to get a |
| 43 // TypeRepository. | 46 // TypeRepository. |
| 44 // @param process_state the process state within which to interpret @p va. | 47 // @param process_state the process state within which to interpret @p va. |
| 45 // @param type_repo on success, returns a type repository for the module. On | 48 // @param type_repo on success, returns a type repository for the module. On |
| 46 // failure, contains nullptr. | 49 // failure, contains nullptr. |
| 47 // @returns true on success, false on failure. | 50 // @returns true on success, false on failure. |
| 48 bool FindOrCreateTypeRepository(const Address va, | 51 bool FindOrCreateTypeRepository(const Address va, |
| 49 ProcessState* process_state, | 52 ProcessState* process_state, |
| 50 scoped_refptr<TypeRepository>* type_repo); | 53 scoped_refptr<TypeRepository>* type_repo); |
| 51 | 54 |
| 52 // Retrieves or creates a TypeRepository for the module corresponding to @p | 55 // Retrieves or creates a TypeRepository for the module corresponding to @p |
| 53 // signature. | 56 // signature. |
| 57 // @note virtual to enable mocking. |
| 54 // @param signature the signature of the module for which to get a type | 58 // @param signature the signature of the module for which to get a type |
| 55 // repository. | 59 // repository. |
| 56 // @param type_repo on success, returns a type repository for the module. On | 60 // @param type_repo on success, returns a type repository for the module. On |
| 57 // failure, contains nullptr. | 61 // failure, contains nullptr. |
| 58 // @returns true on success, false on failure. | 62 // @returns true on success, false on failure. |
| 59 bool FindOrCreateTypeRepository(const pe::PEFile::Signature& signature, | 63 virtual bool FindOrCreateTypeRepository( |
| 60 scoped_refptr<TypeRepository>* type_repo); | 64 const pe::PEFile::Signature& signature, |
| 65 scoped_refptr<TypeRepository>* type_repo); |
| 61 | 66 |
| 62 // Retrieves or creates a TypeNameIndex for the module within @p | 67 // Retrieves or creates a TypeNameIndex for the module within @p |
| 63 // process_state corresponding to @p va. | 68 // process_state corresponding to @p va. |
| 64 // @param va virtual address within a module for which to get a | 69 // @param va virtual address within a module for which to get a |
| 65 // TypeRepository. | 70 // TypeRepository. |
| 66 // @param process_state the process state within which to interpret @p va. | 71 // @param process_state the process state within which to interpret @p va. |
| 67 // @param type_repo on success, returns a typename index for the module. On | 72 // @param type_repo on success, returns a typename index for the module. On |
| 68 // failure, contains nullptr. | 73 // failure, contains nullptr. |
| 69 // @returns true on success, false on failure. | 74 // @returns true on success, false on failure. |
| 70 bool FindOrCreateTypeNameIndex(const Address va, | 75 bool FindOrCreateTypeNameIndex(const Address va, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 // form of null pointers. | 104 // form of null pointers. |
| 100 SimpleCache<TypeRepository> type_repos_; | 105 SimpleCache<TypeRepository> type_repos_; |
| 101 SimpleCache<TypeNameIndex> typename_indices_; | 106 SimpleCache<TypeNameIndex> typename_indices_; |
| 102 | 107 |
| 103 DISALLOW_COPY_AND_ASSIGN(SymbolProvider); | 108 DISALLOW_COPY_AND_ASSIGN(SymbolProvider); |
| 104 }; | 109 }; |
| 105 | 110 |
| 106 } // namespace refinery | 111 } // namespace refinery |
| 107 | 112 |
| 108 #endif // SYZYGY_REFINERY_SYMBOLS_SYMBOL_PROVIDER_H_ | 113 #endif // SYZYGY_REFINERY_SYMBOLS_SYMBOL_PROVIDER_H_ |
| OLD | NEW |