1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:57:34 +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:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -20,7 +20,7 @@ namespace Coredump {
ELFObjectInfo const* Backtrace::object_info_for_region(Reader const& coredump, MemoryRegionInfo const& region)
{
String path = coredump.resolve_object_path(region.object_name());
DeprecatedString path = coredump.resolve_object_path(region.object_name());
auto maybe_ptr = m_debug_info_cache.get(path);
if (maybe_ptr.has_value())
@ -128,7 +128,7 @@ void Backtrace::add_entry(Reader const& coredump, FlatPtr ip)
m_entries.append({ ip, object_name, function_name, source_position });
}
String Backtrace::Entry::to_string(bool color) const
DeprecatedString Backtrace::Entry::to_string(bool color) const
{
StringBuilder builder;
builder.appendff("{:p}: ", eip);

View file

@ -31,11 +31,11 @@ class Backtrace {
public:
struct Entry {
FlatPtr eip;
String object_name;
String function_name;
DeprecatedString object_name;
DeprecatedString function_name;
Debug::DebugInfo::SourcePositionWithInlines source_position_with_inlines;
String to_string(bool color = false) const;
DeprecatedString to_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<String, NonnullOwnPtr<ELFObjectInfo>> m_debug_info_cache;
HashMap<DeprecatedString, NonnullOwnPtr<ELFObjectInfo>> m_debug_info_cache;
};
}

View file

@ -8,7 +8,7 @@
namespace Coredump {
OwnPtr<Inspector> Inspector::create(String const& coredump_path, Function<void(float)> on_progress)
OwnPtr<Inspector> Inspector::create(DeprecatedString const& coredump_path, Function<void(float)> on_progress)
{
auto reader = Reader::create(coredump_path);
if (!reader)
@ -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, String {}, library.base_address);
auto debug_info = make<Debug::DebugInfo>(*image, DeprecatedString {}, library.base_address);
m_loaded_libraries.append(make<Debug::LoadedLibrary>(library.name, file_or_error.value(), move(image), move(debug_info), library.base_address));
});
}

View file

@ -17,7 +17,7 @@ class Inspector : public Debug::ProcessInspector {
AK_MAKE_NONMOVABLE(Inspector);
public:
static OwnPtr<Inspector> create(String const& coredump_path, Function<void(float)> on_progress = {});
static OwnPtr<Inspector> create(DeprecatedString const& coredump_path, Function<void(float)> on_progress = {});
virtual ~Inspector() override = default;
// ^Debug::ProcessInspector

View file

@ -210,20 +210,20 @@ u8 Reader::process_termination_signal() const
return signal_number;
}
String Reader::process_executable_path() const
DeprecatedString Reader::process_executable_path() const
{
auto process_info = this->process_info();
auto executable_path = process_info.get("executable_path"sv);
return executable_path.as_string_or({});
}
Vector<String> Reader::process_arguments() const
Vector<DeprecatedString> Reader::process_arguments() const
{
auto process_info = this->process_info();
auto arguments = process_info.get("arguments"sv);
if (!arguments.is_array())
return {};
Vector<String> vector;
Vector<DeprecatedString> vector;
arguments.as_array().for_each([&](auto& value) {
if (value.is_string())
vector.append(value.as_string());
@ -231,13 +231,13 @@ Vector<String> Reader::process_arguments() const
return vector;
}
Vector<String> Reader::process_environment() const
Vector<DeprecatedString> Reader::process_environment() const
{
auto process_info = this->process_info();
auto environment = process_info.get("environment"sv);
if (!environment.is_array())
return {};
Vector<String> vector;
Vector<DeprecatedString> vector;
environment.as_array().for_each([&](auto& value) {
if (value.is_string())
vector.append(value.as_string());
@ -245,7 +245,7 @@ Vector<String> Reader::process_environment() const
return vector;
}
HashMap<String, String> Reader::metadata() const
HashMap<DeprecatedString, DeprecatedString> 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<String, String> Reader::metadata() const
return {};
if (!metadata_json_value.value().is_object())
return {};
HashMap<String, String> metadata;
HashMap<DeprecatedString, DeprecatedString> 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<String, String> Reader::metadata() const
Reader::LibraryData const* Reader::library_containing(FlatPtr address) const
{
static HashMap<String, OwnPtr<LibraryData>> cached_libs;
static HashMap<DeprecatedString, OwnPtr<LibraryData>> cached_libs;
auto region = region_containing(address);
if (!region.has_value())
return {};
auto name = region->object_name();
String path = resolve_object_path(name);
DeprecatedString 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;
}
String Reader::resolve_object_path(StringView name) const
DeprecatedString 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 @@ String Reader::resolve_object_path(StringView name) const
return name;
}
Vector<String> library_search_directories;
Vector<DeprecatedString> library_search_directories;
// If LD_LIBRARY_PATH is present, check its folders first
for (auto& environment_variable : process_environment()) {
@ -336,7 +336,7 @@ String Reader::resolve_object_path(StringView name) const
void Reader::for_each_library(Function<void(LibraryInfo)> func) const
{
HashTable<String> libraries;
HashTable<DeprecatedString> 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);
String path = resolve_object_path(name);
DeprecatedString 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 {
String name;
String path;
DeprecatedString name;
DeprecatedString path;
FlatPtr base_address { 0 };
};
@ -64,21 +64,21 @@ public:
Optional<MemoryRegionInfo> region_containing(FlatPtr address) const;
struct LibraryData {
String name;
DeprecatedString name;
FlatPtr base_address { 0 };
NonnullRefPtr<Core::MappedFile> file;
ELF::Image lib_elf;
};
LibraryData const* library_containing(FlatPtr address) const;
String resolve_object_path(StringView object_name) const;
DeprecatedString resolve_object_path(StringView object_name) const;
int process_pid() const;
u8 process_termination_signal() const;
String process_executable_path() const;
Vector<String> process_arguments() const;
Vector<String> process_environment() const;
HashMap<String, String> metadata() const;
DeprecatedString process_executable_path() const;
Vector<DeprecatedString> process_arguments() const;
Vector<DeprecatedString> process_environment() const;
HashMap<DeprecatedString, DeprecatedString> metadata() const;
private:
explicit Reader(ReadonlyBytes);