Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -2967,40 +2967,32 @@ Error NativeProcessLinux::GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) { - char maps_file_name[32]; - snprintf(maps_file_name, sizeof(maps_file_name), "/proc/%" PRIu64 "/maps", GetID()); - - FileSpec maps_file_spec(maps_file_name, false); - if (!maps_file_spec.Exists()) { - file_spec.Clear(); - return Error("/proc/%" PRIu64 "/maps file doesn't exists!", GetID()); - } - FileSpec module_file_spec(module_path, true); - std::ifstream maps_file(maps_file_name); - std::string maps_data_str((std::istreambuf_iterator(maps_file)), std::istreambuf_iterator()); - StringRef maps_data(maps_data_str.c_str()); - - while (!maps_data.empty()) - { - StringRef maps_row; - std::tie(maps_row, maps_data) = maps_data.split('\n'); + bool found = false; + file_spec.Clear(); + ProcFileReader::ProcessLineByLine(GetID(), "maps", + [&] (const std::string &line) + { + SmallVector columns; + StringRef(line).split(columns, " ", -1, false); + if (columns.size() < 6) + return true; // continue searching + + FileSpec this_file_spec(columns[5].str().c_str(), false); + if (this_file_spec.GetFilename() != module_file_spec.GetFilename()) + return true; // continue searching - SmallVector maps_columns; - maps_row.split(maps_columns, StringRef(" "), -1, false); + file_spec = this_file_spec; + found = true; + return false; // we are done + }); - if (maps_columns.size() >= 6) - { - file_spec.SetFile(maps_columns[5].str().c_str(), false); - if (file_spec.GetFilename() == module_file_spec.GetFilename()) - return Error(); - } - } + if (! found) + return Error("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", + module_file_spec.GetFilename().AsCString(), GetID()); - file_spec.Clear(); - return Error("Module file (%s) not found in /proc/%" PRIu64 "/maps file!", - module_file_spec.GetFilename().AsCString(), GetID()); + return Error(); } Error