[Lldb-commits] [PATCH] D11460: Speed up NativeProcessLinux::GetLoadedModuleFileSpec
Pavel Labath
labath at google.com
Thu Jul 23 07:47:53 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL243019: Speed up NativeProcessLinux::GetLoadedModuleFileSpec (authored by labath).
Changed prior to commit:
http://reviews.llvm.org/D11460?vs=30481&id=30486#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11460
Files:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
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<char>(maps_file)), std::istreambuf_iterator<char>());
- 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<StringRef, 16> 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<StringRef, 16> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11460.30486.patch
Type: text/x-patch
Size: 2552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150723/352a02cb/attachment.bin>
More information about the lldb-commits
mailing list