1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:07:45 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -20,7 +20,7 @@ namespace Coredump {
ELFObjectInfo const* Backtrace::object_info_for_region(Reader const& coredump, MemoryRegionInfo const& region)
{
DeprecatedString path = coredump.resolve_object_path(region.object_name());
ByteString path = coredump.resolve_object_path(region.object_name());
auto maybe_ptr = m_debug_info_cache.get(path);
if (maybe_ptr.has_value())
@ -127,13 +127,13 @@ void Backtrace::add_entry(Reader const& coredump, FlatPtr ip)
m_entries.append({ ip, object_name, function_name, source_position });
}
DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const
ByteString Backtrace::Entry::to_byte_string(bool color) const
{
StringBuilder builder;
builder.appendff("{:p}: ", eip);
if (object_name.is_empty()) {
builder.append("???"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
builder.appendff("[{}] {}", object_name, function_name.is_empty() ? "???" : function_name);
builder.append(" ("sv);
@ -160,7 +160,7 @@ DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -31,11 +31,11 @@ class Backtrace {
public:
struct Entry {
FlatPtr eip;
DeprecatedString object_name;
DeprecatedString function_name;
ByteString object_name;
ByteString function_name;
Debug::DebugInfo::SourcePositionWithInlines source_position_with_inlines;
DeprecatedString to_deprecated_string(bool color = false) const;
ByteString to_byte_string(bool color = false) const;
};
Backtrace(Reader const&, const ELF::Core::ThreadInfo&, Function<void(size_t, size_t)> on_progress = {});
@ -51,7 +51,7 @@ private:
bool m_skip_loader_so { false };
ELF::Core::ThreadInfo m_thread_info;
Vector<Entry> m_entries;
HashMap<DeprecatedString, NonnullOwnPtr<ELFObjectInfo>> m_debug_info_cache;
HashMap<ByteString, NonnullOwnPtr<ELFObjectInfo>> m_debug_info_cache;
};
}

View file

@ -46,7 +46,7 @@ void Inspector::parse_loaded_libraries(Function<void(float)> on_progress)
return;
auto image = make<ELF::Image>(file_or_error.value()->bytes());
auto debug_info = make<Debug::DebugInfo>(*image, DeprecatedString {}, library.base_address);
auto debug_info = make<Debug::DebugInfo>(*image, ByteString {}, library.base_address);
m_loaded_libraries.append(make<Debug::LoadedLibrary>(library.name, file_or_error.release_value(), move(image), move(debug_info), library.base_address));
});
}

View file

@ -210,20 +210,20 @@ u8 Reader::process_termination_signal() const
return *termination_signal;
}
DeprecatedString Reader::process_executable_path() const
ByteString Reader::process_executable_path() const
{
auto process_info = this->process_info();
auto executable_path = process_info.get_deprecated_string("executable_path"sv);
auto executable_path = process_info.get_byte_string("executable_path"sv);
return executable_path.value_or({});
}
Vector<DeprecatedString> Reader::process_arguments() const
Vector<ByteString> Reader::process_arguments() const
{
auto process_info = this->process_info();
auto arguments = process_info.get_array("arguments"sv);
if (!arguments.has_value())
return {};
Vector<DeprecatedString> vector;
Vector<ByteString> vector;
arguments->for_each([&](auto& value) {
if (value.is_string())
vector.append(value.as_string());
@ -231,13 +231,13 @@ Vector<DeprecatedString> Reader::process_arguments() const
return vector;
}
Vector<DeprecatedString> Reader::process_environment() const
Vector<ByteString> Reader::process_environment() const
{
auto process_info = this->process_info();
auto environment = process_info.get_array("environment"sv);
if (!environment.has_value())
return {};
Vector<DeprecatedString> vector;
Vector<ByteString> vector;
environment->for_each([&](auto& value) {
if (value.is_string())
vector.append(value.as_string());
@ -245,7 +245,7 @@ Vector<DeprecatedString> Reader::process_environment() const
return vector;
}
HashMap<DeprecatedString, DeprecatedString> Reader::metadata() const
HashMap<ByteString, ByteString> Reader::metadata() const
{
const ELF::Core::Metadata* metadata_notes_entry = nullptr;
NotesEntryIterator it(bit_cast<u8 const*>(m_coredump_image.program_header(m_notes_segment_index).raw_data()));
@ -263,7 +263,7 @@ HashMap<DeprecatedString, DeprecatedString> Reader::metadata() const
return {};
if (!metadata_json_value.value().is_object())
return {};
HashMap<DeprecatedString, DeprecatedString> metadata;
HashMap<ByteString, ByteString> metadata;
metadata_json_value.value().as_object().for_each_member([&](auto& key, auto& value) {
metadata.set(key, value.as_string_or({}));
});
@ -272,13 +272,13 @@ HashMap<DeprecatedString, DeprecatedString> Reader::metadata() const
Reader::LibraryData const* Reader::library_containing(FlatPtr address) const
{
static HashMap<DeprecatedString, OwnPtr<LibraryData>> cached_libs;
static HashMap<ByteString, OwnPtr<LibraryData>> cached_libs;
auto region = region_containing(address);
if (!region.has_value())
return {};
auto name = region->object_name();
DeprecatedString path = resolve_object_path(name);
ByteString path = resolve_object_path(name);
if (!cached_libs.contains(path)) {
auto file_or_error = Core::MappedFile::map(path);
@ -292,7 +292,7 @@ Reader::LibraryData const* Reader::library_containing(FlatPtr address) const
return lib_data;
}
DeprecatedString Reader::resolve_object_path(StringView name) const
ByteString Reader::resolve_object_path(StringView name) const
{
// TODO: There are other places where similar method is implemented or would be useful.
// (e.g. UserspaceEmulator, LibSymbolication, Profiler, and DynamicLinker itself)
@ -302,7 +302,7 @@ DeprecatedString Reader::resolve_object_path(StringView name) const
return name;
}
Vector<DeprecatedString> library_search_directories;
Vector<ByteString> library_search_directories;
// If LD_LIBRARY_PATH is present, check its folders first
for (auto& environment_variable : process_environment()) {
@ -336,7 +336,7 @@ DeprecatedString Reader::resolve_object_path(StringView name) const
void Reader::for_each_library(Function<void(LibraryInfo)> func) const
{
HashTable<DeprecatedString> libraries;
HashTable<ByteString> libraries;
for_each_memory_region_info([&](auto const& region) {
auto name = region.object_name();
if (name.is_null() || libraries.contains(name))
@ -344,7 +344,7 @@ void Reader::for_each_library(Function<void(LibraryInfo)> func) const
libraries.set(name);
DeprecatedString path = resolve_object_path(name);
ByteString path = resolve_object_path(name);
func(LibraryInfo { name, path, static_cast<FlatPtr>(region.region_start) });
return IterationDecision::Continue;

View file

@ -47,8 +47,8 @@ public:
void for_each_memory_region_info(Func func) const;
struct LibraryInfo {
DeprecatedString name;
DeprecatedString path;
ByteString name;
ByteString path;
FlatPtr base_address { 0 };
};
@ -64,21 +64,21 @@ public:
Optional<MemoryRegionInfo> region_containing(FlatPtr address) const;
struct LibraryData {
DeprecatedString name;
ByteString name;
FlatPtr base_address { 0 };
NonnullOwnPtr<Core::MappedFile> file;
ELF::Image lib_elf;
};
LibraryData const* library_containing(FlatPtr address) const;
DeprecatedString resolve_object_path(StringView object_name) const;
ByteString resolve_object_path(StringView object_name) const;
int process_pid() const;
u8 process_termination_signal() const;
DeprecatedString process_executable_path() const;
Vector<DeprecatedString> process_arguments() const;
Vector<DeprecatedString> process_environment() const;
HashMap<DeprecatedString, DeprecatedString> metadata() const;
ByteString process_executable_path() const;
Vector<ByteString> process_arguments() const;
Vector<ByteString> process_environment() const;
HashMap<ByteString, ByteString> metadata() const;
private:
explicit Reader(ReadonlyBytes);