Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / mc / inspect / ObjectInformation.hpp
index 6bf27ff..8d7b7b1 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -49,10 +48,13 @@ struct FunctionIndexEntry {
  *  - etc.
  */
 class ObjectInformation {
+  bool dwarf_loaded = false; // Lazily loads the dwarf info
+
 public:
+  void ensure_dwarf_loaded(); // Used by functions that need the dwarf
   ObjectInformation() = default;
 
-  // Not copyable:
+  // Not copiable:
   ObjectInformation(ObjectInformation const&) = delete;
   ObjectInformation& operator=(ObjectInformation const&) = delete;
 
@@ -107,8 +109,8 @@ public:
   /** Whether this module is an executable
    *
    *  More precisely we check if this is an ET_EXE ELF. These ELF files
-   *  use fixed addresses instead of base-addres relative addresses.
-   *  Position independant executables are in fact ET_DYN.
+   *  use fixed addresses instead of base-address relative addresses.
+   *  Position independent executables are in fact ET_DYN.
    */
   bool executable() const { return this->flags & simgrid::mc::ObjectInformation::Executable; }
 
@@ -117,20 +119,24 @@ public:
    *  All the location information in ELF and DWARF are expressed as an offsets
    *  from this base address:
    *
-   *  - location of the functions and globale variables;
+   *  - location of the functions and global variables
    *
    *  - the DWARF instruction `OP_addr` pushes this on the DWARF stack.
    **/
   void* base_address() const;
 
   /** Find a function by instruction address
+   *
+   *  Loads the dwarf information on need.
    *
    *  @param ip instruction address
    *  @return corresponding function (if any) or nullptr
    */
-  simgrid::mc::Frame* find_function(const void* ip) const;
+  simgrid::mc::Frame* find_function(const void* ip);
 
   /** Find a global variable by name
+   *
+   *  Loads the dwarf information on need.
    *
    *  This is used to ignore global variables and to find well-known variables
    *  (`__mmalloc_default_mdp`).
@@ -138,7 +144,7 @@ public:
    *  @param name scopes name of the global variable (`myproject::Foo::count`)
    *  @return corresponding variable (if any) or nullptr
    */
-  const simgrid::mc::Variable* find_variable(const char* name) const;
+  const simgrid::mc::Variable* find_variable(const char* name);
 
   /** Remove a global variable (in order to ignore it)
    *
@@ -146,10 +152,10 @@ public:
    */
   void remove_global_variable(const char* name);
 
-  /** Remove a loval variables (in order to ignore it)
+  /** Remove a local variables (in order to ignore it)
    *
-   *  @param name Name of the globale variable
-   *  @param scope Namespaceed name of the function (or null for all functions)
+   *  @param name Name of the local variable
+   *  @param scope scopes name name of the function (myproject::Foo::count) or null for all functions
    */
   void remove_local_variable(const char* name, const char* scope);
 };
@@ -157,8 +163,9 @@ public:
 XBT_PRIVATE std::shared_ptr<ObjectInformation> createObjectInformation(std::vector<simgrid::xbt::VmMap> const& maps,
                                                                        const char* name);
 
-/** Augment the current module with informations about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info);
+/** Augment the current module with information about the other ones */
+XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteProcess* process,
+                                              simgrid::mc::ObjectInformation* info);
 } // namespace mc
 } // namespace simgrid