summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/DevTools/Profiler/Process.cpp3
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.cpp8
-rw-r--r--Userland/Libraries/LibCore/File.cpp10
-rw-r--r--Userland/Libraries/LibCore/File.h3
-rw-r--r--Userland/Libraries/LibCoredump/Backtrace.cpp2
-rw-r--r--Userland/Libraries/LibCoredump/Reader.cpp3
-rw-r--r--Userland/Libraries/LibDebug/DebugSession.cpp2
7 files changed, 25 insertions, 6 deletions
diff --git a/Userland/DevTools/Profiler/Process.cpp b/Userland/DevTools/Profiler/Process.cpp
index c4874300c7..0924ab8959 100644
--- a/Userland/DevTools/Profiler/Process.cpp
+++ b/Userland/DevTools/Profiler/Process.cpp
@@ -5,6 +5,7 @@
*/
#include "Process.h"
+#include <LibCore/File.h>
namespace Profiler {
@@ -90,7 +91,7 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, const String& name)
} else {
String path_string = path.to_string();
String full_path;
- if (path_string.ends_with(".so"sv))
+ if (Core::File::looks_like_shared_library(path_string))
full_path = String::formatted("/usr/lib/{}", path);
else
full_path = path_string;
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
index c888367df7..0b9e4b2fcf 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp
@@ -15,6 +15,7 @@
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/StringUtils.h>
+#include <LibCore/File.h>
#include <LibELF/AuxiliaryVector.h>
#include <LibELF/Image.h>
#include <LibELF/Validation.h>
@@ -395,7 +396,7 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address)
return {};
String lib_path = lib_name;
- if (lib_name.ends_with(".so"))
+ if (Core::File::looks_like_shared_library(lib_name))
lib_path = String::formatted("/usr/lib/{}", lib_path);
if (!m_dynamic_library_cache.contains(lib_path)) {
@@ -432,7 +433,10 @@ Optional<Emulator::SymbolInfo> Emulator::symbol_at(FlatPtr address)
auto lib_name = address_region->lib_name();
auto const* first_region = (lib_name.is_null() || lib_name.is_empty()) ? address_region : first_region_for_object(lib_name);
VERIFY(first_region);
- auto lib_path = lib_name.ends_with(".so"sv) ? String::formatted("/usr/lib/{}", lib_name) : lib_name;
+ auto lib_path = lib_name;
+ if (Core::File::looks_like_shared_library(lib_name)) {
+ lib_path = String::formatted("/usr/lib/{}", lib_name);
+ }
auto it = m_dynamic_library_cache.find(lib_path);
auto const& elf = it->value.debug_info->elf();
diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp
index 184042d569..9104350231 100644
--- a/Userland/Libraries/LibCore/File.cpp
+++ b/Userland/Libraries/LibCore/File.cpp
@@ -147,6 +147,16 @@ bool File::is_link(String const& filename)
return S_ISLNK(st.st_mode);
}
+bool File::looks_like_shared_library() const
+{
+ return File::looks_like_shared_library(m_filename);
+}
+
+bool File::looks_like_shared_library(const String& filename)
+{
+ return filename.ends_with(".so"sv) || filename.contains(".so."sv);
+}
+
bool File::exists(String const& filename)
{
struct stat st;
diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h
index 34b024b160..6c59972fdd 100644
--- a/Userland/Libraries/LibCore/File.h
+++ b/Userland/Libraries/LibCore/File.h
@@ -32,6 +32,9 @@ public:
bool is_link() const;
static bool is_link(String const& filename);
+ bool looks_like_shared_library() const;
+ static bool looks_like_shared_library(String const& filename);
+
static bool exists(String const& filename);
static ErrorOr<size_t> size(String const& filename);
static bool ensure_parent_directories(String const& path);
diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp
index 86b53584cb..a0f9969d42 100644
--- a/Userland/Libraries/LibCoredump/Backtrace.cpp
+++ b/Userland/Libraries/LibCoredump/Backtrace.cpp
@@ -20,7 +20,7 @@ namespace Coredump {
ELFObjectInfo const* Backtrace::object_info_for_region(ELF::Core::MemoryRegionInfo const& region)
{
auto path = region.object_name();
- if (!path.starts_with('/') && (path.ends_with(".so"sv) || path.contains(".so."sv)))
+ if (!path.starts_with('/') && Core::File::looks_like_shared_library(path))
path = LexicalPath::join("/usr/lib", path).string();
auto maybe_ptr = m_debug_info_cache.get(path);
diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp
index 672da0c29d..744f4100bc 100644
--- a/Userland/Libraries/LibCoredump/Reader.cpp
+++ b/Userland/Libraries/LibCoredump/Reader.cpp
@@ -7,6 +7,7 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <LibCompress/Gzip.h>
+#include <LibCore/File.h>
#include <LibCoredump/Reader.h>
#include <signal_numbers.h>
#include <string.h>
@@ -273,7 +274,7 @@ const Reader::LibraryData* Reader::library_containing(FlatPtr address) const
auto name = region->object_name();
String path;
- if (name.ends_with(".so"))
+ if (Core::File::looks_like_shared_library(name))
path = String::formatted("/usr/lib/{}", name);
else {
path = name;
diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp
index ebb36d78c2..ec76677a77 100644
--- a/Userland/Libraries/LibDebug/DebugSession.cpp
+++ b/Userland/Libraries/LibDebug/DebugSession.cpp
@@ -433,7 +433,7 @@ void DebugSession::update_loaded_libs()
return IterationDecision::Continue;
String lib_name = object_path.value();
- if (lib_name.ends_with(".so"))
+ if (Core::File::looks_like_shared_library(lib_name))
lib_name = LexicalPath::basename(object_path.value());
FlatPtr base_address = entry.as_object().get("address").to_addr();