Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:42

0001 //===-- SBModule.h ----------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_API_SBMODULE_H
0010 #define LLDB_API_SBMODULE_H
0011 
0012 #include "lldb/API/SBDefines.h"
0013 #include "lldb/API/SBError.h"
0014 #include "lldb/API/SBSection.h"
0015 #include "lldb/API/SBSymbolContext.h"
0016 #include "lldb/API/SBValueList.h"
0017 
0018 namespace lldb {
0019 
0020 class LLDB_API SBModule {
0021 public:
0022   SBModule();
0023 
0024   SBModule(const SBModule &rhs);
0025 
0026   SBModule(const SBModuleSpec &module_spec);
0027 
0028   const SBModule &operator=(const SBModule &rhs);
0029 
0030   SBModule(lldb::SBProcess &process, lldb::addr_t header_addr);
0031 
0032   ~SBModule();
0033 
0034   explicit operator bool() const;
0035 
0036   bool IsValid() const;
0037 
0038   void Clear();
0039 
0040   bool IsFileBacked() const;
0041 
0042   /// Get const accessor for the module file specification.
0043   ///
0044   /// This function returns the file for the module on the host system
0045   /// that is running LLDB. This can differ from the path on the
0046   /// platform since we might be doing remote debugging.
0047   ///
0048   /// \return
0049   ///     A const reference to the file specification object.
0050   lldb::SBFileSpec GetFileSpec() const;
0051 
0052   /// Get accessor for the module platform file specification.
0053   ///
0054   /// Platform file refers to the path of the module as it is known on
0055   /// the remote system on which it is being debugged. For local
0056   /// debugging this is always the same as Module::GetFileSpec(). But
0057   /// remote debugging might mention a file '/usr/lib/liba.dylib'
0058   /// which might be locally downloaded and cached. In this case the
0059   /// platform file could be something like:
0060   /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
0061   /// The file could also be cached in a local developer kit directory.
0062   ///
0063   /// \return
0064   ///     A const reference to the file specification object.
0065   lldb::SBFileSpec GetPlatformFileSpec() const;
0066 
0067   bool SetPlatformFileSpec(const lldb::SBFileSpec &platform_file);
0068 
0069   /// Get accessor for the remote install path for a module.
0070   ///
0071   /// When debugging to a remote platform by connecting to a remote
0072   /// platform, the install path of the module can be set. If the
0073   /// install path is set, every time the process is about to launch
0074   /// the target will install this module on the remote platform prior
0075   /// to launching.
0076   ///
0077   /// \return
0078   ///     A file specification object.
0079   lldb::SBFileSpec GetRemoteInstallFileSpec();
0080 
0081   /// Set accessor for the remote install path for a module.
0082   ///
0083   /// When debugging to a remote platform by connecting to a remote
0084   /// platform, the install path of the module can be set. If the
0085   /// install path is set, every time the process is about to launch
0086   /// the target will install this module on the remote platform prior
0087   /// to launching.
0088   ///
0089   /// If \a file specifies a full path to an install location, the
0090   /// module will be installed to this path. If the path is relative
0091   /// (no directory specified, or the path is partial like "usr/lib"
0092   /// or "./usr/lib", then the install path will be resolved using
0093   /// the platform's current working directory as the base path.
0094   ///
0095   /// \param[in] file
0096   ///     A file specification object.
0097   bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file);
0098 
0099   lldb::ByteOrder GetByteOrder();
0100 
0101   uint32_t GetAddressByteSize();
0102 
0103   const char *GetTriple();
0104 
0105   const uint8_t *GetUUIDBytes() const;
0106 
0107   const char *GetUUIDString() const;
0108 
0109   bool operator==(const lldb::SBModule &rhs) const;
0110 
0111   bool operator!=(const lldb::SBModule &rhs) const;
0112 
0113   lldb::SBSection FindSection(const char *sect_name);
0114 
0115   lldb::SBAddress ResolveFileAddress(lldb::addr_t vm_addr);
0116 
0117   lldb::SBSymbolContext
0118   ResolveSymbolContextForAddress(const lldb::SBAddress &addr,
0119                                  uint32_t resolve_scope);
0120 
0121   bool GetDescription(lldb::SBStream &description);
0122 
0123   uint32_t GetNumCompileUnits();
0124 
0125   lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t);
0126 
0127   /// Find compile units related to *this module and passed source
0128   /// file.
0129   ///
0130   /// \param[in] sb_file_spec
0131   ///     A lldb::SBFileSpec object that contains source file
0132   ///     specification.
0133   ///
0134   /// \return
0135   ///     A lldb::SBSymbolContextList that gets filled in with all of
0136   ///     the symbol contexts for all the matches.
0137   lldb::SBSymbolContextList
0138   FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
0139 
0140   size_t GetNumSymbols();
0141 
0142   lldb::SBSymbol GetSymbolAtIndex(size_t idx);
0143 
0144   lldb::SBSymbol FindSymbol(const char *name,
0145                             lldb::SymbolType type = eSymbolTypeAny);
0146 
0147   lldb::SBSymbolContextList FindSymbols(const char *name,
0148                                         lldb::SymbolType type = eSymbolTypeAny);
0149 
0150   size_t GetNumSections();
0151 
0152   lldb::SBSection GetSectionAtIndex(size_t idx);
0153   /// Find functions by name.
0154   ///
0155   /// \param[in] name
0156   ///     The name of the function we are looking for.
0157   ///
0158   /// \param[in] name_type_mask
0159   ///     A logical OR of one or more FunctionNameType enum bits that
0160   ///     indicate what kind of names should be used when doing the
0161   ///     lookup. Bits include fully qualified names, base names,
0162   ///     C++ methods, or ObjC selectors.
0163   ///     See FunctionNameType for more details.
0164   ///
0165   /// \return
0166   ///     A lldb::SBSymbolContextList that gets filled in with all of
0167   ///     the symbol contexts for all the matches.
0168   lldb::SBSymbolContextList
0169   FindFunctions(const char *name,
0170                 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
0171 
0172   /// Find global and static variables by name.
0173   ///
0174   /// \param[in] target
0175   ///     A valid SBTarget instance representing the debuggee.
0176   ///
0177   /// \param[in] name
0178   ///     The name of the global or static variable we are looking
0179   ///     for.
0180   ///
0181   /// \param[in] max_matches
0182   ///     Allow the number of matches to be limited to \a max_matches.
0183   ///
0184   /// \return
0185   ///     A list of matched variables in an SBValueList.
0186   lldb::SBValueList FindGlobalVariables(lldb::SBTarget &target,
0187                                         const char *name, uint32_t max_matches);
0188 
0189   /// Find the first global (or static) variable by name.
0190   ///
0191   /// \param[in] target
0192   ///     A valid SBTarget instance representing the debuggee.
0193   ///
0194   /// \param[in] name
0195   ///     The name of the global or static variable we are looking
0196   ///     for.
0197   ///
0198   /// \return
0199   ///     An SBValue that gets filled in with the found variable (if any).
0200   lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
0201                                         const char *name);
0202 
0203   lldb::SBType FindFirstType(const char *name);
0204 
0205   lldb::SBTypeList FindTypes(const char *type);
0206 
0207   /// Get a type using its type ID.
0208   ///
0209   /// Each symbol file reader will assign different user IDs to their
0210   /// types, but it is sometimes useful when debugging type issues to
0211   /// be able to grab a type using its type ID.
0212   ///
0213   /// For DWARF debug info, the type ID is the DIE offset.
0214   ///
0215   /// \param[in] uid
0216   ///     The type user ID.
0217   ///
0218   /// \return
0219   ///     An SBType for the given type ID, or an empty SBType if the
0220   ///     type was not found.
0221   lldb::SBType GetTypeByID(lldb::user_id_t uid);
0222 
0223   lldb::SBType GetBasicType(lldb::BasicType type);
0224 
0225   /// Get all types matching \a type_mask from debug info in this
0226   /// module.
0227   ///
0228   /// \param[in] type_mask
0229   ///     A bitfield that consists of one or more bits logically OR'ed
0230   ///     together from the lldb::TypeClass enumeration. This allows
0231   ///     you to request only structure types, or only class, struct
0232   ///     and union types. Passing in lldb::eTypeClassAny will return
0233   ///     all types found in the debug information for this module.
0234   ///
0235   /// \return
0236   ///     A list of types in this module that match \a type_mask
0237   lldb::SBTypeList GetTypes(uint32_t type_mask = lldb::eTypeClassAny);
0238 
0239   /// Get the module version numbers.
0240   ///
0241   /// Many object files have a set of version numbers that describe
0242   /// the version of the executable or shared library. Typically there
0243   /// are major, minor and build, but there may be more. This function
0244   /// will extract the versions from object files if they are available.
0245   ///
0246   /// If \a versions is NULL, or if \a num_versions is 0, the return
0247   /// value will indicate how many version numbers are available in
0248   /// this object file. Then a subsequent call can be made to this
0249   /// function with a value of \a versions and \a num_versions that
0250   /// has enough storage to store some or all version numbers.
0251   ///
0252   /// \param[out] versions
0253   ///     A pointer to an array of uint32_t types that is \a num_versions
0254   ///     long. If this value is NULL, the return value will indicate
0255   ///     how many version numbers are required for a subsequent call
0256   ///     to this function so that all versions can be retrieved. If
0257   ///     the value is non-NULL, then at most \a num_versions of the
0258   ///     existing versions numbers will be filled into \a versions.
0259   ///     If there is no version information available, \a versions
0260   ///     will be filled with \a num_versions UINT32_MAX values
0261   ///     and zero will be returned.
0262   ///
0263   /// \param[in] num_versions
0264   ///     The maximum number of entries to fill into \a versions. If
0265   ///     this value is zero, then the return value will indicate
0266   ///     how many version numbers there are in total so another call
0267   ///     to this function can be make with adequate storage in
0268   ///     \a versions to get all of the version numbers. If \a
0269   ///     num_versions is less than the actual number of version
0270   ///     numbers in this object file, only \a num_versions will be
0271   ///     filled into \a versions (if \a versions is non-NULL).
0272   ///
0273   /// \return
0274   ///     This function always returns the number of version numbers
0275   ///     that this object file has regardless of the number of
0276   ///     version numbers that were copied into \a versions.
0277   uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
0278 
0279   /// Get accessor for the symbol file specification.
0280   ///
0281   /// When debugging an object file an additional debug information can
0282   /// be provided in separate file. Therefore if you debugging something
0283   /// like '/usr/lib/liba.dylib' then debug information can be located
0284   /// in folder like '/usr/lib/liba.dylib.dSYM/'.
0285   ///
0286   /// \return
0287   ///     A const reference to the file specification object.
0288   lldb::SBFileSpec GetSymbolFileSpec() const;
0289 
0290   lldb::SBAddress GetObjectFileHeaderAddress() const;
0291   lldb::SBAddress GetObjectFileEntryPointAddress() const;
0292 
0293   /// Get the number of global modules.
0294   static uint32_t GetNumberAllocatedModules();
0295 
0296   /// Remove any global modules which are no longer needed.
0297   static void GarbageCollectAllocatedModules();
0298 
0299 private:
0300   friend class SBAddress;
0301   friend class SBFrame;
0302   friend class SBSection;
0303   friend class SBSymbolContext;
0304   friend class SBPlatform;
0305   friend class SBTarget;
0306   friend class SBType;
0307 
0308   friend class lldb_private::python::SWIGBridge;
0309 
0310   explicit SBModule(const lldb::ModuleSP &module_sp);
0311 
0312   ModuleSP GetSP() const;
0313 
0314   void SetSP(const ModuleSP &module_sp);
0315 
0316   lldb::ModuleSP m_opaque_sp;
0317 };
0318 
0319 } // namespace lldb
0320 
0321 #endif // LLDB_API_SBMODULE_H