*
* `dl_iterate_phdr` would be more robust but would not work in cross-process.
* */
-void MC_find_object_address(std::vector<simgrid::mc::VmMap> const& maps, mc_object_info_t result)
+void MC_find_object_address(
+ std::vector<simgrid::mc::VmMap> const& maps, mc_object_info_t result)
{
- const char *name = basename(result->file_name);
+ const char* file_name = xbt_strdup(result->file_name.c_str());
+ const char *name = basename(file_name);
for (size_t i = 0; i < maps.size(); ++i) {
simgrid::mc::VmMap const& reg = maps[i];
if (maps[i].pathname.empty()
if (result->end_exec && (const void*) result->end_exec > result->end)
result->end = result->end_exec;
- xbt_assert(result->file_name);
xbt_assert(result->start_rw);
xbt_assert(result->start_exec);
}
xbt_assert(region1->object_info() == region2->object_info());
xbt_assert(region1->object_info());
- const char* name = region1->object_info()->file_name;
+ std::string const& name = region1->object_info()->file_name;
#ifdef MC_DEBUG
if (is_diff == 0)
xbt_os_walltimer_stop(timer);
mc_comp_times->global_variables_comparison_time
+= xbt_os_timer_elapsed(timer);
- XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2,
- name);
+ XBT_DEBUG("(%d - %d) Different global variables in %s",
+ num1, num2, name.c_str());
errors++;
#else
#ifdef MC_VERBOSE
- XBT_VERB("(%d - %d) Different global variables in %s", num1, num2,
- name);
+ XBT_VERB("(%d - %d) Different global variables in %s",
+ num1, num2, name.c_str());
#endif
reset_heap_information();
*/
void MC_dwarf_get_variables(mc_object_info_t info)
{
- int fd = open(info->file_name, O_RDONLY);
- if (fd < 0) {
- xbt_die("Could not open file %s", info->file_name);
- }
+ int fd = open(info->file_name.c_str(), O_RDONLY);
+ if (fd < 0)
+ xbt_die("Could not open file %s", info->file_name.c_str());
Dwarf *dwarf = dwarf_begin(fd, DWARF_C_READ);
- if (dwarf == NULL) {
- xbt_die("Your program must be compiled with -g (%s)", info->file_name);
- }
+ if (dwarf == NULL)
+ xbt_die("Your program must be compiled with -g (%s)",
+ info->file_name.c_str());
// For each compilation unit:
Dwarf_Off offset = 0;
Dwarf_Off next_offset = 0;
std::make_shared<s_mc_object_info_t>();
if (executable)
result->flags |= MC_OBJECT_INFO_EXECUTABLE;
- result->file_name = xbt_strdup(name);
+ result->file_name = name;
MC_find_object_address(maps, result.get());
MC_dwarf_get_variables(result.get());
MC_post_process_types(result.get());
ObjectInformation::ObjectInformation()
{
this->flags = 0;
- this->file_name = nullptr;
this->start = nullptr;
this->end = nullptr;
this->start_exec = nullptr;
ObjectInformation::~ObjectInformation()
{
- xbt_free(this->file_name);
xbt_dynar_free(&this->functions_index);
}
ObjectInformation& operator=(ObjectInformation const&) = delete;
mc_object_info_flags flags;
- char* file_name;
+ std::string file_name;
const void* start;
const void *end;
char *start_exec;