mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:07:45 +00:00
Everywhere: Move shared library checks into a common function
While we're at it, unify the various different conditions that are scattered accross the codebase.
This commit is contained in:
parent
31c634be5a
commit
80cb44afae
7 changed files with 25 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue