|
16 | 16 | #include "lldb/Utility/Log.h"
|
17 | 17 |
|
18 | 18 | #include "Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.h"
|
| 19 | +#include <regex> |
19 | 20 |
|
20 | 21 | using namespace lldb;
|
21 | 22 | using namespace lldb_private;
|
@@ -155,14 +156,28 @@ void DynamicLoaderDumpWithModuleList::LoadAllModules(
|
155 | 156 | addr_t base_addr, module_size;
|
156 | 157 | std::string name;
|
157 | 158 | if (!mod_info.get_base(base_addr) || !mod_info.get_name(name) ||
|
158 |
| - !mod_info.get_size(module_size)) |
| 159 | + !mod_info.get_size(module_size) || !ShouldLoadModule(name)) |
159 | 160 | continue;
|
160 | 161 |
|
161 |
| - callback(name, base_addr, module_size); |
| 162 | + callback(SanitizeName(name), base_addr, module_size); |
162 | 163 | }
|
163 | 164 | }
|
164 | 165 | }
|
165 | 166 |
|
| 167 | +bool DynamicLoaderDumpWithModuleList::ShouldLoadModule( |
| 168 | + const std::string &module_name) { |
| 169 | + // Use a regular expression to match /dev/* path |
| 170 | + static const std::regex pattern("^/dev/.*$"); |
| 171 | + return !std::regex_match(module_name, pattern); |
| 172 | +} |
| 173 | + |
| 174 | +std::string |
| 175 | +DynamicLoaderDumpWithModuleList::SanitizeName(const std::string &input) { |
| 176 | + // Use a regular expression to match and remove the parenthesized substring |
| 177 | + static const std::regex pattern("\\s*\\(\\S+\\)\\s*$"); |
| 178 | + return std::regex_replace(input, pattern, ""); |
| 179 | +} |
| 180 | + |
166 | 181 | void DynamicLoaderDumpWithModuleList::DidAttach() {
|
167 | 182 | Log *log = GetLog(LLDBLog::DynamicLoader);
|
168 | 183 | LLDB_LOGF(log, "DynamicLoaderDumpWithModuleList::%s() pid %" PRIu64,
|
|
0 commit comments