36
36
37
37
namespace lldb_private {
38
38
39
+ // / Provides public interface for all SymbolFiles. Any protected
40
+ // / virtual members should go into SymbolFileCommon; most SymbolFile
41
+ // / implementations should inherit from SymbolFileCommon to override
42
+ // / the behaviors except SymbolFileOnDemand which inherits
43
+ // / public interfaces from SymbolFile and forward to underlying concrete
44
+ // / SymbolFile implementation.
39
45
class SymbolFile : public PluginInterface {
40
46
// / LLVM RTTI support.
41
47
static char ID;
@@ -67,8 +73,7 @@ class SymbolFile : public PluginInterface {
67
73
static SymbolFile *FindPlugin (lldb::ObjectFileSP objfile_sp);
68
74
69
75
// Constructors and Destructors
70
- SymbolFile (lldb::ObjectFileSP objfile_sp)
71
- : m_objfile_sp(std::move(objfile_sp)) {}
76
+ SymbolFile () = default ;
72
77
73
78
~SymbolFile () override = default ;
74
79
@@ -99,15 +104,7 @@ class SymbolFile : public PluginInterface {
99
104
// / A uint32_t mask containing bits from the SymbolFile::Abilities
100
105
// / enumeration. Any bits that are set represent an ability that
101
106
// / this symbol plug-in can parse from the object file.
102
- uint32_t GetAbilities () {
103
- if (!m_calculated_abilities) {
104
- m_abilities = CalculateAbilities ();
105
- m_calculated_abilities = true ;
106
- }
107
-
108
- return m_abilities;
109
- }
110
-
107
+ virtual uint32_t GetAbilities () = 0;
111
108
virtual uint32_t CalculateAbilities () = 0;
112
109
113
110
// / Symbols file subclasses should override this to return the Module that
@@ -125,10 +122,10 @@ class SymbolFile : public PluginInterface {
125
122
126
123
// Compile Unit function calls
127
124
// Approach 1 - iterator
128
- uint32_t GetNumCompileUnits ();
129
- lldb::CompUnitSP GetCompileUnitAtIndex (uint32_t idx);
125
+ virtual uint32_t GetNumCompileUnits () = 0 ;
126
+ virtual lldb::CompUnitSP GetCompileUnitAtIndex (uint32_t idx) = 0 ;
130
127
131
- Symtab *GetSymtab ();
128
+ virtual Symtab *GetSymtab () = 0 ;
132
129
133
130
virtual lldb::LanguageType ParseLanguage (CompileUnit &comp_unit) = 0;
134
131
// / Return the Xcode SDK comp_unit was compiled against.
@@ -256,16 +253,16 @@ class SymbolFile : public PluginInterface {
256
253
virtual void PreloadSymbols ();
257
254
258
255
virtual llvm::Expected<lldb_private::TypeSystem &>
259
- GetTypeSystemForLanguage (lldb::LanguageType language);
256
+ GetTypeSystemForLanguage (lldb::LanguageType language) = 0 ;
260
257
261
258
virtual CompilerDeclContext
262
259
FindNamespace (ConstString name, const CompilerDeclContext &parent_decl_ctx) {
263
260
return CompilerDeclContext ();
264
261
}
265
262
266
- ObjectFile *GetObjectFile () { return m_objfile_sp. get (); }
267
- const ObjectFile *GetObjectFile () const { return m_objfile_sp. get (); }
268
- ObjectFile *GetMainObjectFile ();
263
+ virtual ObjectFile *GetObjectFile () = 0;
264
+ virtual const ObjectFile *GetObjectFile () const = 0;
265
+ virtual ObjectFile *GetMainObjectFile () = 0 ;
269
266
270
267
virtual std::vector<std::unique_ptr<CallEdge>>
271
268
ParseCallEdgesInFunction (UserID func_id) {
@@ -276,7 +273,7 @@ class SymbolFile : public PluginInterface {
276
273
277
274
// / Notify the SymbolFile that the file addresses in the Sections
278
275
// / for this module have been changed.
279
- virtual void SectionFileAddressesChanged ();
276
+ virtual void SectionFileAddressesChanged () = 0 ;
280
277
281
278
struct RegisterInfoResolver {
282
279
virtual ~RegisterInfoResolver (); // anchor
@@ -297,7 +294,7 @@ class SymbolFile : public PluginInterface {
297
294
" Operation not supported." );
298
295
}
299
296
300
- virtual void Dump (Stream &s);
297
+ virtual void Dump (Stream &s) = 0 ;
301
298
302
299
// / Metrics gathering functions
303
300
@@ -311,7 +308,7 @@ class SymbolFile : public PluginInterface {
311
308
// / entire file should be returned. The default implementation of this
312
309
// / function will iterate over all sections in a module and add up their
313
310
// / debug info only section byte sizes.
314
- virtual uint64_t GetDebugInfoSize ();
311
+ virtual uint64_t GetDebugInfoSize () = 0 ;
315
312
316
313
// / Return the time taken to parse the debug information.
317
314
// /
@@ -344,26 +341,90 @@ class SymbolFile : public PluginInterface {
344
341
// / index is saved to the cache, debug sessions can be slower. These accessors
345
342
// / can be accessed by the statistics and emitted to help track these costs.
346
343
// / \{
347
- bool GetDebugInfoIndexWasLoadedFromCache () const {
344
+ virtual bool GetDebugInfoIndexWasLoadedFromCache () const = 0;
345
+ virtual void SetDebugInfoIndexWasLoadedFromCache () = 0;
346
+ virtual bool GetDebugInfoIndexWasSavedToCache () const = 0;
347
+ virtual void SetDebugInfoIndexWasSavedToCache () = 0;
348
+ // / \}
349
+
350
+ protected:
351
+ void AssertModuleLock ();
352
+
353
+ private:
354
+ SymbolFile (const SymbolFile &) = delete ;
355
+ const SymbolFile &operator =(const SymbolFile &) = delete ;
356
+ };
357
+
358
+ // / Containing protected virtual methods for child classes to override.
359
+ // / Most actual SymbolFile implementations should inherit from this class.
360
+ class SymbolFileCommon : public SymbolFile {
361
+ // / LLVM RTTI support.
362
+ static char ID;
363
+
364
+ public:
365
+ // / LLVM RTTI support.
366
+ // / \{
367
+ bool isA (const void *ClassID) const override {
368
+ return ClassID == &ID || SymbolFile::isA (ClassID);
369
+ }
370
+ static bool classof (const SymbolFileCommon *obj) { return obj->isA (&ID); }
371
+ // / \}
372
+
373
+ // Constructors and Destructors
374
+ SymbolFileCommon (lldb::ObjectFileSP objfile_sp)
375
+ : m_objfile_sp(std::move(objfile_sp)) {}
376
+
377
+ ~SymbolFileCommon () override = default ;
378
+
379
+ uint32_t GetAbilities () override {
380
+ if (!m_calculated_abilities) {
381
+ m_abilities = CalculateAbilities ();
382
+ m_calculated_abilities = true ;
383
+ }
384
+ return m_abilities;
385
+ }
386
+
387
+ Symtab *GetSymtab () override ;
388
+
389
+ ObjectFile *GetObjectFile () override { return m_objfile_sp.get (); }
390
+ const ObjectFile *GetObjectFile () const override {
391
+ return m_objfile_sp.get ();
392
+ }
393
+ ObjectFile *GetMainObjectFile () override ;
394
+
395
+ // / Notify the SymbolFile that the file addresses in the Sections
396
+ // / for this module have been changed.
397
+ void SectionFileAddressesChanged () override ;
398
+
399
+ // Compile Unit function calls
400
+ // Approach 1 - iterator
401
+ uint32_t GetNumCompileUnits () override ;
402
+ lldb::CompUnitSP GetCompileUnitAtIndex (uint32_t idx) override ;
403
+
404
+ llvm::Expected<lldb_private::TypeSystem &>
405
+ GetTypeSystemForLanguage (lldb::LanguageType language) override ;
406
+
407
+ void Dump (Stream &s) override ;
408
+
409
+ uint64_t GetDebugInfoSize () override ;
410
+
411
+ bool GetDebugInfoIndexWasLoadedFromCache () const override {
348
412
return m_index_was_loaded_from_cache;
349
413
}
350
- void SetDebugInfoIndexWasLoadedFromCache () {
414
+ void SetDebugInfoIndexWasLoadedFromCache () override {
351
415
m_index_was_loaded_from_cache = true ;
352
416
}
353
- bool GetDebugInfoIndexWasSavedToCache () const {
417
+ bool GetDebugInfoIndexWasSavedToCache () const override {
354
418
return m_index_was_saved_to_cache;
355
419
}
356
- void SetDebugInfoIndexWasSavedToCache () {
420
+ void SetDebugInfoIndexWasSavedToCache () override {
357
421
m_index_was_saved_to_cache = true ;
358
422
}
359
- // / \}
360
423
361
424
protected:
362
- void AssertModuleLock ();
363
425
virtual uint32_t CalculateNumCompileUnits () = 0;
364
426
virtual lldb::CompUnitSP ParseCompileUnitAtIndex (uint32_t idx) = 0;
365
427
virtual TypeList &GetTypeList () { return m_type_list; }
366
-
367
428
void SetCompileUnitAtIndex (uint32_t idx, const lldb::CompUnitSP &cu_sp);
368
429
369
430
lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
@@ -379,8 +440,8 @@ class SymbolFile : public PluginInterface {
379
440
bool m_index_was_saved_to_cache = false ;
380
441
381
442
private:
382
- SymbolFile (const SymbolFile &) = delete ;
383
- const SymbolFile &operator =(const SymbolFile &) = delete ;
443
+ SymbolFileCommon (const SymbolFileCommon &) = delete ;
444
+ const SymbolFileCommon &operator =(const SymbolFileCommon &) = delete ;
384
445
};
385
446
386
447
} // namespace lldb_private
0 commit comments