mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:27:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace Debug {
|
||||
|
||||
DebugInfo::DebugInfo(ELF::Image const& elf, String source_root, FlatPtr base_address)
|
||||
DebugInfo::DebugInfo(ELF::Image const& elf, DeprecatedString source_root, FlatPtr base_address)
|
||||
: m_elf(elf)
|
||||
, m_source_root(move(source_root))
|
||||
, m_base_address(base_address)
|
||||
|
@ -86,8 +86,8 @@ void DebugInfo::prepare_lines()
|
|||
all_lines.extend(unit.line_program().lines());
|
||||
});
|
||||
|
||||
HashMap<FlyString, Optional<String>> memoized_full_paths;
|
||||
auto compute_full_path = [&](FlyString const& file_path) -> Optional<String> {
|
||||
HashMap<FlyString, Optional<DeprecatedString>> memoized_full_paths;
|
||||
auto compute_full_path = [&](FlyString const& file_path) -> Optional<DeprecatedString> {
|
||||
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_null())
|
||||
|
@ -129,17 +129,17 @@ Optional<DebugInfo::SourcePosition> DebugInfo::get_source_position(FlatPtr targe
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source_position(String const& file, size_t line) const
|
||||
Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source_position(DeprecatedString const& file, size_t line) const
|
||||
{
|
||||
String file_path = file;
|
||||
DeprecatedString file_path = file;
|
||||
if (!file_path.starts_with('/'))
|
||||
file_path = String::formatted("/{}", file_path);
|
||||
file_path = DeprecatedString::formatted("/{}", file_path);
|
||||
|
||||
constexpr auto SERENITY_LIBS_PREFIX = "/usr/src/serenity"sv;
|
||||
if (file.starts_with(SERENITY_LIBS_PREFIX)) {
|
||||
size_t file_prefix_offset = SERENITY_LIBS_PREFIX.length() + 1;
|
||||
file_path = file.substring(file_prefix_offset, file.length() - file_prefix_offset);
|
||||
file_path = String::formatted("../{}", file_path);
|
||||
file_path = DeprecatedString::formatted("../{}", file_path);
|
||||
}
|
||||
|
||||
Optional<SourcePositionAndAddress> result;
|
||||
|
@ -331,7 +331,7 @@ void DebugInfo::add_type_info_to_variable(Dwarf::DIE const& type_die, PtraceRegi
|
|||
array_type_name.append(type_info->type_name);
|
||||
for (auto array_size : type_info->dimension_sizes) {
|
||||
array_type_name.append('[');
|
||||
array_type_name.append(String::formatted("{:d}", array_size));
|
||||
array_type_name.append(DeprecatedString::formatted("{:d}", array_size));
|
||||
array_type_name.append(']');
|
||||
}
|
||||
parent_variable->type_name = array_type_name.to_string();
|
||||
|
@ -352,7 +352,7 @@ bool DebugInfo::is_variable_tag_supported(Dwarf::EntryTag const& tag)
|
|||
|| tag == Dwarf::EntryTag::ArrayType;
|
||||
}
|
||||
|
||||
String DebugInfo::name_of_containing_function(FlatPtr address) const
|
||||
DeprecatedString DebugInfo::name_of_containing_function(FlatPtr address) const
|
||||
{
|
||||
auto function = get_containing_function(address);
|
||||
if (!function.has_value())
|
||||
|
@ -410,7 +410,7 @@ DebugInfo::SourcePositionWithInlines DebugInfo::get_source_position_with_inlines
|
|||
return;
|
||||
}
|
||||
|
||||
inline_chain.append({ String::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() });
|
||||
inline_chain.append({ DeprecatedString::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() });
|
||||
};
|
||||
|
||||
while (die->tag() == Dwarf::EntryTag::InlinedSubroutine) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class DebugInfo {
|
|||
AK_MAKE_NONMOVABLE(DebugInfo);
|
||||
|
||||
public:
|
||||
explicit DebugInfo(ELF::Image const&, String source_root = {}, FlatPtr base_address = 0);
|
||||
explicit DebugInfo(ELF::Image const&, DeprecatedString source_root = {}, FlatPtr base_address = 0);
|
||||
|
||||
ELF::Image const& elf() const { return m_elf; }
|
||||
|
||||
|
@ -34,15 +34,15 @@ public:
|
|||
Optional<FlatPtr> address_of_first_statement;
|
||||
|
||||
SourcePosition()
|
||||
: SourcePosition(String::empty(), 0)
|
||||
: SourcePosition(DeprecatedString::empty(), 0)
|
||||
{
|
||||
}
|
||||
SourcePosition(String file_path, size_t line_number)
|
||||
SourcePosition(DeprecatedString file_path, size_t line_number)
|
||||
: file_path(file_path)
|
||||
, line_number(line_number)
|
||||
{
|
||||
}
|
||||
SourcePosition(String file_path, size_t line_number, FlatPtr address_of_first_statement)
|
||||
SourcePosition(DeprecatedString 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)
|
||||
|
@ -60,8 +60,8 @@ public:
|
|||
Address,
|
||||
Register,
|
||||
};
|
||||
String name;
|
||||
String type_name;
|
||||
DeprecatedString name;
|
||||
DeprecatedString type_name;
|
||||
LocationType location_type { LocationType::None };
|
||||
union {
|
||||
FlatPtr address;
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
struct VariablesScope {
|
||||
bool is_function { false };
|
||||
String name;
|
||||
DeprecatedString 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;
|
||||
|
@ -101,14 +101,14 @@ public:
|
|||
SourcePositionWithInlines get_source_position_with_inlines(FlatPtr address) const;
|
||||
|
||||
struct SourcePositionAndAddress {
|
||||
String file;
|
||||
DeprecatedString file;
|
||||
size_t line;
|
||||
FlatPtr address;
|
||||
};
|
||||
|
||||
Optional<SourcePositionAndAddress> get_address_from_source_position(String const& file, size_t line) const;
|
||||
Optional<SourcePositionAndAddress> get_address_from_source_position(DeprecatedString const& file, size_t line) const;
|
||||
|
||||
String name_of_containing_function(FlatPtr address) const;
|
||||
DeprecatedString name_of_containing_function(FlatPtr address) const;
|
||||
Vector<SourcePosition> source_lines_in_scope(VariablesScope const&) const;
|
||||
Optional<VariablesScope> get_containing_function(FlatPtr address) const;
|
||||
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
Optional<uint32_t> get_line_of_inline(Dwarf::DIE const&) const;
|
||||
|
||||
ELF::Image const& m_elf;
|
||||
String m_source_root;
|
||||
DeprecatedString m_source_root;
|
||||
FlatPtr m_base_address { 0 };
|
||||
Dwarf::DwarfInfo m_dwarf_info;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace Debug {
|
||||
|
||||
DebugSession::DebugSession(pid_t pid, String source_root)
|
||||
DebugSession::DebugSession(pid_t pid, DeprecatedString source_root)
|
||||
: m_debuggee_pid(pid)
|
||||
, m_source_root(source_root)
|
||||
|
||||
|
@ -53,8 +53,8 @@ void DebugSession::for_each_loaded_library(Function<IterationDecision(LoadedLibr
|
|||
}
|
||||
}
|
||||
|
||||
OwnPtr<DebugSession> DebugSession::exec_and_attach(String const& command,
|
||||
String source_root,
|
||||
OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& command,
|
||||
DeprecatedString source_root,
|
||||
Function<ErrorOr<void>()> setup_child)
|
||||
{
|
||||
auto pid = fork();
|
||||
|
@ -388,7 +388,7 @@ void DebugSession::detach()
|
|||
continue_debuggee();
|
||||
}
|
||||
|
||||
Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_breakpoint(String const& symbol_name)
|
||||
Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_breakpoint(DeprecatedString const& symbol_name)
|
||||
{
|
||||
Optional<InsertBreakpointAtSymbolResult> result;
|
||||
for_each_loaded_library([this, symbol_name, &result](auto& lib) {
|
||||
|
@ -411,7 +411,7 @@ Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_brea
|
|||
return result;
|
||||
}
|
||||
|
||||
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(String const& filename, size_t line_number)
|
||||
Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::insert_breakpoint(DeprecatedString 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())
|
||||
|
@ -430,7 +430,7 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
|
|||
|
||||
void DebugSession::update_loaded_libs()
|
||||
{
|
||||
auto file = Core::File::construct(String::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||
auto file = Core::File::construct(DeprecatedString::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||
bool rc = file->open(Core::OpenMode::ReadOnly);
|
||||
VERIFY(rc);
|
||||
|
||||
|
@ -440,7 +440,7 @@ 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](String const& vm_name) -> Optional<String> {
|
||||
auto get_path_to_object = [&segment_name_re](DeprecatedString const& vm_name) -> Optional<DeprecatedString> {
|
||||
if (vm_name == "/usr/lib/Loader.so")
|
||||
return vm_name;
|
||||
RegexResult result;
|
||||
|
@ -450,7 +450,7 @@ void DebugSession::update_loaded_libs()
|
|||
auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_string();
|
||||
if (lib_name.starts_with('/'))
|
||||
return lib_name;
|
||||
return String::formatted("/usr/lib/{}", lib_name);
|
||||
return DeprecatedString::formatted("/usr/lib/{}", lib_name);
|
||||
};
|
||||
|
||||
vm_entries.for_each([&](auto& entry) {
|
||||
|
@ -461,7 +461,7 @@ void DebugSession::update_loaded_libs()
|
|||
if (!object_path.has_value())
|
||||
return IterationDecision::Continue;
|
||||
|
||||
String lib_name = object_path.value();
|
||||
DeprecatedString lib_name = object_path.value();
|
||||
if (Core::File::looks_like_shared_library(lib_name))
|
||||
lib_name = LexicalPath::basename(object_path.value());
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Demangle.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibC/sys/arch/i386/regs.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibDebug/DebugInfo.h>
|
||||
|
@ -27,7 +27,7 @@ namespace Debug {
|
|||
|
||||
class DebugSession : public ProcessInspector {
|
||||
public:
|
||||
static OwnPtr<DebugSession> exec_and_attach(String const& command, String source_root = {}, Function<ErrorOr<void>()> setup_child = {});
|
||||
static OwnPtr<DebugSession> exec_and_attach(DeprecatedString const& command, DeprecatedString source_root = {}, Function<ErrorOr<void>()> setup_child = {});
|
||||
|
||||
virtual ~DebugSession() override;
|
||||
|
||||
|
@ -55,20 +55,20 @@ public:
|
|||
};
|
||||
|
||||
struct InsertBreakpointAtSymbolResult {
|
||||
String library_name;
|
||||
DeprecatedString library_name;
|
||||
FlatPtr address { 0 };
|
||||
};
|
||||
|
||||
Optional<InsertBreakpointAtSymbolResult> insert_breakpoint(String const& symbol_name);
|
||||
Optional<InsertBreakpointAtSymbolResult> insert_breakpoint(DeprecatedString const& symbol_name);
|
||||
|
||||
struct InsertBreakpointAtSourcePositionResult {
|
||||
String library_name;
|
||||
String filename;
|
||||
DeprecatedString library_name;
|
||||
DeprecatedString filename;
|
||||
size_t line_number { 0 };
|
||||
FlatPtr address { 0 };
|
||||
};
|
||||
|
||||
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(String const& filename, size_t line_number);
|
||||
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(DeprecatedString const& filename, size_t line_number);
|
||||
|
||||
bool insert_breakpoint(FlatPtr address);
|
||||
bool disable_breakpoint(FlatPtr address);
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
explicit DebugSession(pid_t, String source_root);
|
||||
explicit DebugSession(pid_t, DeprecatedString source_root);
|
||||
|
||||
// x86 breakpoint instruction "int3"
|
||||
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
||||
|
@ -138,14 +138,14 @@ private:
|
|||
void update_loaded_libs();
|
||||
|
||||
int m_debuggee_pid { -1 };
|
||||
String m_source_root;
|
||||
DeprecatedString 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<String, NonnullOwnPtr<LoadedLibrary>> m_loaded_libraries;
|
||||
HashMap<DeprecatedString, NonnullOwnPtr<LoadedLibrary>> m_loaded_libraries;
|
||||
};
|
||||
|
||||
template<typename Callback>
|
||||
|
|
|
@ -196,7 +196,7 @@ AttributeValue DwarfInfo::get_attribute_value(AttributeDataForm form, ssize_t im
|
|||
break;
|
||||
}
|
||||
case AttributeDataForm::String: {
|
||||
String str;
|
||||
DeprecatedString str;
|
||||
u32 str_offset = debug_info_stream.offset();
|
||||
debug_info_stream >> str;
|
||||
VERIFY(!debug_info_stream.has_any_error());
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
#include "AttributeValue.h"
|
||||
#include "DwarfTypes.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RedBlackTree.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibDebug/Dwarf/DIE.h>
|
||||
#include <LibELF/Image.h>
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "LineProgram.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibDebug/Dwarf/DwarfInfo.h>
|
||||
|
||||
|
@ -74,7 +74,7 @@ void LineProgram::parse_path_entries(Function<void(PathEntry& entry)> callback,
|
|||
}
|
||||
} else {
|
||||
while (m_stream.peek_or_error()) {
|
||||
String path;
|
||||
DeprecatedString path;
|
||||
m_stream >> path;
|
||||
dbgln_if(DWARF_DEBUG, "path: {}", path);
|
||||
PathEntry entry;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct PathEntryFormat {
|
|||
};
|
||||
|
||||
struct PathEntry {
|
||||
String path;
|
||||
DeprecatedString path;
|
||||
size_t directory_index { 0 };
|
||||
};
|
||||
|
||||
|
@ -175,7 +175,7 @@ private:
|
|||
|
||||
size_t m_unit_offset { 0 };
|
||||
LineProgramUnitHeader32 m_unit_header {};
|
||||
Vector<String> m_source_directories;
|
||||
Vector<DeprecatedString> m_source_directories;
|
||||
Vector<FileEntry> m_source_files;
|
||||
|
||||
// The registers of the "line program" virtual machine
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
namespace Debug {
|
||||
struct LoadedLibrary {
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
NonnullRefPtr<Core::MappedFile> file;
|
||||
NonnullOwnPtr<ELF::Image> image;
|
||||
NonnullOwnPtr<DebugInfo> debug_info;
|
||||
FlatPtr base_address {};
|
||||
|
||||
LoadedLibrary(String const& name, NonnullRefPtr<Core::MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
|
||||
LoadedLibrary(DeprecatedString const& name, NonnullRefPtr<Core::MappedFile> file, NonnullOwnPtr<ELF::Image> image, NonnullOwnPtr<DebugInfo>&& debug_info, FlatPtr base_address)
|
||||
: name(name)
|
||||
, file(move(file))
|
||||
, image(move(image))
|
||||
|
|
|
@ -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 String::empty() if symbol is not found (It currently returns ??)
|
||||
// FIXME: ELF::Image symbolicate() API should return DeprecatedString::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(String const& file, size_t line) const
|
||||
Optional<DebugInfo::SourcePositionAndAddress> ProcessInspector::get_address_from_source_position(DeprecatedString const& file, size_t line) const
|
||||
{
|
||||
Optional<DebugInfo::SourcePositionAndAddress> result;
|
||||
for_each_loaded_library([file, line, &result](auto& lib) {
|
||||
|
|
|
@ -24,11 +24,11 @@ public:
|
|||
|
||||
LoadedLibrary const* library_at(FlatPtr address) const;
|
||||
struct SymbolicationResult {
|
||||
String library_name;
|
||||
String symbol;
|
||||
DeprecatedString library_name;
|
||||
DeprecatedString symbol;
|
||||
};
|
||||
Optional<SymbolicationResult> symbolicate(FlatPtr address) const;
|
||||
Optional<DebugInfo::SourcePositionAndAddress> get_address_from_source_position(String const& file, size_t line) const;
|
||||
Optional<DebugInfo::SourcePositionAndAddress> get_address_from_source_position(DeprecatedString const& file, size_t line) const;
|
||||
Optional<DebugInfo::SourcePosition> get_source_position(FlatPtr address) const;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue