1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:27:35 +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

@ -13,7 +13,7 @@
namespace Debug {
DebugInfo::DebugInfo(ELF::Image const& elf, DeprecatedString source_root, FlatPtr base_address)
DebugInfo::DebugInfo(ELF::Image const& elf, ByteString source_root, FlatPtr base_address)
: m_elf(elf)
, m_source_root(move(source_root))
, m_base_address(base_address)
@ -91,8 +91,8 @@ ErrorOr<void> DebugInfo::prepare_lines()
return {};
}));
HashMap<DeprecatedFlyString, Optional<DeprecatedString>> memoized_full_paths;
auto compute_full_path = [&](DeprecatedFlyString const& file_path) -> Optional<DeprecatedString> {
HashMap<DeprecatedFlyString, Optional<ByteString>> memoized_full_paths;
auto compute_full_path = [&](DeprecatedFlyString const& file_path) -> Optional<ByteString> {
if (file_path.view().contains("Toolchain/"sv) || file_path.view().contains("libgcc"sv))
return {};
if (file_path.view().starts_with("./"sv) && !m_source_root.is_empty())
@ -135,11 +135,11 @@ Optional<DebugInfo::SourcePosition> DebugInfo::get_source_position(FlatPtr targe
return {};
}
Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source_position(DeprecatedString const& file, size_t line) const
Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source_position(ByteString const& file, size_t line) const
{
DeprecatedString file_path = file;
ByteString file_path = file;
if (!file_path.starts_with('/'))
file_path = DeprecatedString::formatted("/{}", file_path);
file_path = ByteString::formatted("/{}", file_path);
Optional<SourcePositionAndAddress> result;
for (auto const& line_entry : m_sorted_lines) {
@ -327,10 +327,10 @@ ErrorOr<void> DebugInfo::add_type_info_to_variable(Dwarf::DIE const& type_die, P
array_type_name.append(type_info->type_name);
for (auto array_size : type_info->dimension_sizes) {
array_type_name.append('[');
array_type_name.append(DeprecatedString::formatted("{:d}", array_size));
array_type_name.append(ByteString::formatted("{:d}", array_size));
array_type_name.append(']');
}
parent_variable->type_name = array_type_name.to_deprecated_string();
parent_variable->type_name = array_type_name.to_byte_string();
}
parent_variable->type = move(type_info);
parent_variable->type->type_tag = type_die.tag();
@ -350,7 +350,7 @@ bool DebugInfo::is_variable_tag_supported(Dwarf::EntryTag const& tag)
|| tag == Dwarf::EntryTag::ArrayType;
}
DeprecatedString DebugInfo::name_of_containing_function(FlatPtr address) const
ByteString DebugInfo::name_of_containing_function(FlatPtr address) const
{
auto function = get_containing_function(address);
if (!function.has_value())
@ -408,7 +408,7 @@ ErrorOr<DebugInfo::SourcePositionWithInlines> DebugInfo::get_source_position_wit
return {};
}
inline_chain.append({ DeprecatedString::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() });
inline_chain.append({ ByteString::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() });
return {};
};

View file

@ -23,7 +23,7 @@ class DebugInfo {
AK_MAKE_NONMOVABLE(DebugInfo);
public:
explicit DebugInfo(ELF::Image const&, DeprecatedString source_root = {}, FlatPtr base_address = 0);
explicit DebugInfo(ELF::Image const&, ByteString source_root = {}, FlatPtr base_address = 0);
ELF::Image const& elf() const { return m_elf; }
@ -33,15 +33,15 @@ public:
Optional<FlatPtr> address_of_first_statement;
SourcePosition()
: SourcePosition(DeprecatedString::empty(), 0)
: SourcePosition(ByteString::empty(), 0)
{
}
SourcePosition(DeprecatedString file_path, size_t line_number)
SourcePosition(ByteString file_path, size_t line_number)
: file_path(file_path)
, line_number(line_number)
{
}
SourcePosition(DeprecatedString file_path, size_t line_number, FlatPtr address_of_first_statement)
SourcePosition(ByteString file_path, size_t line_number, FlatPtr address_of_first_statement)
: file_path(file_path)
, line_number(line_number)
, address_of_first_statement(address_of_first_statement)
@ -59,8 +59,8 @@ public:
Address,
Register,
};
DeprecatedString name;
DeprecatedString type_name;
ByteString name;
ByteString type_name;
LocationType location_type { LocationType::None };
union {
FlatPtr address;
@ -83,7 +83,7 @@ public:
struct VariablesScope {
bool is_function { false };
DeprecatedString name;
ByteString name;
FlatPtr address_low { 0 };
FlatPtr address_high { 0 }; // Non-inclusive - the lowest address after address_low that's not in this scope
Vector<Dwarf::DIE> dies_of_variables;
@ -100,14 +100,14 @@ public:
ErrorOr<SourcePositionWithInlines> get_source_position_with_inlines(FlatPtr address) const;
struct SourcePositionAndAddress {
DeprecatedString file;
ByteString file;
size_t line;
FlatPtr address;
};
Optional<SourcePositionAndAddress> get_address_from_source_position(DeprecatedString const& file, size_t line) const;
Optional<SourcePositionAndAddress> get_address_from_source_position(ByteString const& file, size_t line) const;
DeprecatedString name_of_containing_function(FlatPtr address) const;
ByteString name_of_containing_function(FlatPtr address) const;
Vector<SourcePosition> source_lines_in_scope(VariablesScope const&) const;
Optional<VariablesScope> get_containing_function(FlatPtr address) const;
@ -123,7 +123,7 @@ private:
ErrorOr<Optional<uint32_t>> get_line_of_inline(Dwarf::DIE const&) const;
ELF::Image const& m_elf;
DeprecatedString m_source_root;
ByteString m_source_root;
FlatPtr m_base_address { 0 };
Dwarf::DwarfInfo m_dwarf_info;

View file

@ -17,7 +17,7 @@
namespace Debug {
DebugSession::DebugSession(pid_t pid, DeprecatedString source_root, Function<void(float)> on_initialization_progress)
DebugSession::DebugSession(pid_t pid, ByteString source_root, Function<void(float)> on_initialization_progress)
: m_debuggee_pid(pid)
, m_source_root(source_root)
, m_on_initialization_progress(move(on_initialization_progress))
@ -53,8 +53,8 @@ void DebugSession::for_each_loaded_library(Function<IterationDecision(LoadedLibr
}
}
OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& command,
DeprecatedString source_root,
OwnPtr<DebugSession> DebugSession::exec_and_attach(ByteString const& command,
ByteString source_root,
Function<ErrorOr<void>()> setup_child,
Function<void(float)> on_initialization_progress)
{
@ -134,7 +134,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& comma
return debug_session;
}
OwnPtr<DebugSession> DebugSession::attach(pid_t pid, DeprecatedString source_root, Function<void(float)> on_initialization_progress)
OwnPtr<DebugSession> DebugSession::attach(pid_t pid, ByteString source_root, Function<void(float)> on_initialization_progress)
{
if (ptrace(PT_ATTACH, pid, 0, 0) < 0) {
perror("PT_ATTACH");
@ -415,7 +415,7 @@ void DebugSession::detach()
continue_debuggee();
}
Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_breakpoint(DeprecatedString const& symbol_name)
Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_breakpoint(ByteString const& symbol_name)
{
Optional<InsertBreakpointAtSymbolResult> result;
for_each_loaded_library([this, symbol_name, &result](auto& lib) {
@ -438,7 +438,7 @@ Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_brea
return result;
}
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(DeprecatedString const& filename, size_t line_number)
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(ByteString const& filename, size_t line_number)
{
auto address_and_source_position = get_address_from_source_position(filename, line_number);
if (!address_and_source_position.has_value())
@ -466,17 +466,17 @@ ErrorOr<void> DebugSession::update_loaded_libs()
auto const& vm_entries = json.as_array();
Regex<PosixExtended> segment_name_re("(.+): ");
auto get_path_to_object = [&segment_name_re](DeprecatedString const& vm_name) -> Optional<DeprecatedString> {
auto get_path_to_object = [&segment_name_re](ByteString const& vm_name) -> Optional<ByteString> {
if (vm_name == "/usr/lib/Loader.so")
return vm_name;
RegexResult result;
auto rc = segment_name_re.search(vm_name, result);
if (!rc)
return {};
auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_deprecated_string();
auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_byte_string();
if (lib_name.starts_with('/'))
return lib_name;
return DeprecatedString::formatted("/usr/lib/{}", lib_name);
return ByteString::formatted("/usr/lib/{}", lib_name);
};
ScopeGuard progress_guard([this]() {
@ -492,13 +492,13 @@ ErrorOr<void> DebugSession::update_loaded_libs()
m_on_initialization_progress(vm_entry_index / static_cast<float>(vm_entries.size()));
// TODO: check that region is executable
auto vm_name = entry.as_object().get_deprecated_string("name"sv).value();
auto vm_name = entry.as_object().get_byte_string("name"sv).value();
auto object_path = get_path_to_object(vm_name);
if (!object_path.has_value())
return IterationDecision::Continue;
DeprecatedString lib_name = object_path.value();
ByteString lib_name = object_path.value();
if (FileSystem::looks_like_shared_library(lib_name))
lib_name = LexicalPath::basename(object_path.value());

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/ByteString.h>
#include <AK/Demangle.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
@ -27,8 +27,8 @@ namespace Debug {
class DebugSession : public ProcessInspector {
public:
static OwnPtr<DebugSession> exec_and_attach(DeprecatedString const& command, DeprecatedString source_root = {}, Function<ErrorOr<void>()> setup_child = {}, Function<void(float)> on_initialization_progress = {});
static OwnPtr<DebugSession> attach(pid_t pid, DeprecatedString source_root = {}, Function<void(float)> on_initialization_progress = {});
static OwnPtr<DebugSession> exec_and_attach(ByteString const& command, ByteString source_root = {}, Function<ErrorOr<void>()> setup_child = {}, Function<void(float)> on_initialization_progress = {});
static OwnPtr<DebugSession> attach(pid_t pid, ByteString source_root = {}, Function<void(float)> on_initialization_progress = {});
virtual ~DebugSession() override;
@ -56,20 +56,20 @@ public:
};
struct InsertBreakpointAtSymbolResult {
DeprecatedString library_name;
ByteString library_name;
FlatPtr address { 0 };
};
Optional<InsertBreakpointAtSymbolResult> insert_breakpoint(DeprecatedString const& symbol_name);
Optional<InsertBreakpointAtSymbolResult> insert_breakpoint(ByteString const& symbol_name);
struct InsertBreakpointAtSourcePositionResult {
DeprecatedString library_name;
DeprecatedString filename;
ByteString library_name;
ByteString filename;
size_t line_number { 0 };
FlatPtr address { 0 };
};
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(DeprecatedString const& filename, size_t line_number);
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(ByteString const& filename, size_t line_number);
bool insert_breakpoint(FlatPtr address);
bool disable_breakpoint(FlatPtr address);
@ -132,7 +132,7 @@ public:
};
private:
explicit DebugSession(pid_t, DeprecatedString source_root, Function<void(float)> on_initialization_progress = {});
explicit DebugSession(pid_t, ByteString source_root, Function<void(float)> on_initialization_progress = {});
// x86 breakpoint instruction "int3"
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
@ -140,14 +140,14 @@ private:
ErrorOr<void> update_loaded_libs();
int m_debuggee_pid { -1 };
DeprecatedString m_source_root;
ByteString m_source_root;
bool m_is_debuggee_dead { false };
HashMap<FlatPtr, BreakPoint> m_breakpoints;
HashMap<FlatPtr, WatchPoint> m_watchpoints;
// Maps from library name to LoadedLibrary object
HashMap<DeprecatedString, NonnullOwnPtr<LoadedLibrary>> m_loaded_libraries;
HashMap<ByteString, NonnullOwnPtr<LoadedLibrary>> m_loaded_libraries;
Function<void(float)> m_on_initialization_progress;
};

View file

@ -81,7 +81,7 @@ ErrorOr<void> LineProgram::parse_path_entries(Function<void(PathEntry& entry)> c
StringBuilder builder;
while (auto c = TRY(m_stream.read_value<char>()))
TRY(builder.try_append(c));
auto path = builder.to_deprecated_string();
auto path = builder.to_byte_string();
if (path.length() == 0)
break;
dbgln_if(DWARF_DEBUG, "path: {}", path);

View file

@ -95,7 +95,7 @@ struct PathEntryFormat {
};
struct PathEntry {
DeprecatedString path;
ByteString path;
size_t directory_index { 0 };
};
@ -180,7 +180,7 @@ private:
size_t m_unit_offset { 0 };
LineProgramUnitHeader32 m_unit_header {};
Vector<DeprecatedString> m_source_directories;
Vector<ByteString> m_source_directories;
Vector<FileEntry> m_source_files;
// The registers of the "line program" virtual machine

View file

@ -13,13 +13,13 @@
namespace Debug {
struct LoadedLibrary {
DeprecatedString name;
ByteString name;
NonnullOwnPtr<Core::MappedFile> file;
NonnullOwnPtr<ELF::Image> image;
NonnullOwnPtr<DebugInfo> debug_info;
FlatPtr base_address {};
LoadedLibrary(DeprecatedString const& name, NonnullOwnPtr<Core::MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
LoadedLibrary(ByteString const& name, NonnullOwnPtr<Core::MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
: name(name)
, file(move(file))
, image(move(image))

View file

@ -27,12 +27,12 @@ Optional<ProcessInspector::SymbolicationResult> ProcessInspector::symbolicate(Fl
auto* lib = library_at(address);
if (!lib)
return {};
// FIXME: ELF::Image symbolicate() API should return DeprecatedString::empty() if symbol is not found (It currently returns ??)
// FIXME: ELF::Image symbolicate() API should return ByteString::empty() if symbol is not found (It currently returns ??)
auto symbol = lib->debug_info->elf().symbolicate(address - lib->base_address);
return { { lib->name, symbol } };
}
Optional<DebugInfo::SourcePositionAndAddress> ProcessInspector::get_address_from_source_position(DeprecatedString const& file, size_t line) const
Optional<DebugInfo::SourcePositionAndAddress> ProcessInspector::get_address_from_source_position(ByteString const& file, size_t line) const
{
Optional<DebugInfo::SourcePositionAndAddress> result;
for_each_loaded_library([file, line, &result](auto& lib) {

View file

@ -24,11 +24,11 @@ public:
LoadedLibrary const* library_at(FlatPtr address) const;
struct SymbolicationResult {
DeprecatedString library_name;
DeprecatedString symbol;
ByteString library_name;
ByteString symbol;
};
Optional<SymbolicationResult> symbolicate(FlatPtr address) const;
Optional<DebugInfo::SourcePositionAndAddress> get_address_from_source_position(DeprecatedString const& file, size_t line) const;
Optional<DebugInfo::SourcePositionAndAddress> get_address_from_source_position(ByteString const& file, size_t line) const;
Optional<DebugInfo::SourcePosition> get_source_position(FlatPtr address) const;
protected: