X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ba9a4cfeba4eb00e84cd17603fc9654e81445655..2f6b0aa5c5a2fada81b8593c0ba9d930a7ce41d2:/src/mc/ObjectInformation.cpp diff --git a/src/mc/ObjectInformation.cpp b/src/mc/ObjectInformation.cpp index b4c585102e..015a60b345 100644 --- a/src/mc/ObjectInformation.cpp +++ b/src/mc/ObjectInformation.cpp @@ -15,38 +15,24 @@ namespace simgrid { namespace mc { -ObjectInformation::ObjectInformation() -{ - this->flags = 0; - this->start = nullptr; - this->end = nullptr; - this->start_exec = nullptr; - this->end_exec = nullptr; - this->start_rw = nullptr; - this->end_rw = nullptr; - this->start_ro = nullptr; - this->end_ro = nullptr; -} - -/** Find the DWARF offset for this ELF object - * - * An offset is applied to address found in DWARF: - * - * * for an executable obejct, addresses are virtual address - * (there is no offset) i.e. - * \f$\text{virtual address} = \{dwarf address}\f$; +/* For an executable object, addresses are virtual address + * (there is no offset) i.e. + * \f$\text{virtual address} = \{dwarf address}\f$; * - * * for a shared object, the addreses are offset from the begining - * of the shared object (the base address of the mapped shared - * object must be used as offset - * i.e. \f$\text{virtual address} = \text{shared object base address} + * For a shared object, the addreses are offset from the begining + * of the shared object (the base address of the mapped shared + * object must be used as offset + * i.e. \f$\text{virtual address} = \text{shared object base address} * + \text{dwarf address}\f$. */ void *ObjectInformation::base_address() const { + // For an executable (more precisely for a ET_EXEC) the base it 0: if (this->executable()) return nullptr; + // For an a shared-object (ET_DYN, including position-independant executables) + // the base address is its lowest address: void *result = this->start_exec; if (this->start_rw != nullptr && result > (void *) this->start_rw) result = this->start_rw; @@ -55,18 +41,17 @@ void *ObjectInformation::base_address() const return result; } -/* Find a function by instruction pointer */ simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const { /* This is implemented by binary search on a sorted array. * - * We do quite a lot ot those so we want this to be cache efficient. + * We do quite a lot of those so we want this to be cache efficient. * We pack the only information we need in the index entries in order * to successfully do the binary search. We do not need the high_pc * during the binary search (only at the end) so it is not included * in the index entry. We could use parallel arrays as well. * - * We cannot really use the std:: alogrithm for this. + * We cannot really use the std:: algorithm for this. * We could use std::binary_search by including the high_pc inside * the FunctionIndexEntry. */ @@ -87,7 +72,7 @@ simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const /* At this point, the search is over. * Either we have found the correct function or we do not know * any function corresponding to this instruction address. - * Only at the point do we derefernce the function pointer. */ + * Only at the point do we dereference the function pointer. */ else if ((std::uint64_t) ip < base[k].function->range.end()) return base[k].function; else @@ -121,7 +106,7 @@ void ObjectInformation::remove_global_variable(const char* name) int cmp = current_var.name.compare(name); if (cmp == 0) { - + // Find the whole range: size_type first = cursor; while (first != 0 && this->global_variables[first - 1].name == name) @@ -130,12 +115,12 @@ void ObjectInformation::remove_global_variable(const char* name) size_type last = cursor; while (last != size - 1 && this->global_variables[last + 1].name == name) last++; - + // Remove the whole range: this->global_variables.erase( this->global_variables.begin() + first, this->global_variables.begin() + last + 1); - + return; } else if (cmp < 0) first = cursor + 1; @@ -146,16 +131,16 @@ void ObjectInformation::remove_global_variable(const char* name) } } -/** \brief Ignore a local variable in a scope +/** Ignore a local variable in a scope * * Ignore all instances of variables with a given name in * any (possibly inlined) subprogram with a given namespaced * name. * - * \param var_name Name of the local variable (or parameter to ignore) - * \param subprogram_name Name of the subprogram fo ignore (nullptr for any) - * \param subprogram (possibly inlined) Subprogram of the scope - * \param scope Current scope + * @param var_name Name of the local variable to ignore + * @param subprogram_name Name of the subprogram to ignore (nullptr for any) + * @param subprogram (possibly inlined) Subprogram of the scope current scope + * @param scope Current scope */ static void remove_local_variable(simgrid::mc::Frame& scope, const char *var_name, @@ -165,10 +150,8 @@ static void remove_local_variable(simgrid::mc::Frame& scope, typedef std::vector::size_type size_type; // If the current subprogram matches the given name: - if ((subprogram_name == nullptr || - (!subprogram.name.empty() - && subprogram.name == subprogram_name)) - && !scope.variables.empty()) { + if ((subprogram_name == nullptr || (not subprogram.name.empty() && subprogram.name == subprogram_name)) && + not scope.variables.empty()) { // Try to find the variable and remove it: size_type start = 0; @@ -213,4 +196,4 @@ void ObjectInformation::remove_local_variable( } } -} \ No newline at end of file +}