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

@ -46,7 +46,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(Debug::Proces
// We need to go back to the 'call' instruction to get accurate source position information.
if (frame_index > 0)
--current_instruction;
String name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
DeprecatedString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
if (name.is_null()) {
dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_instruction, lib->name);
name = "<missing>";

View file

@ -27,7 +27,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_frames.size(); }
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
virtual String column_name(int) const override
virtual DeprecatedString column_name(int) const override
{
return "";
}
@ -37,7 +37,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
struct FrameInfo {
String function_name;
DeprecatedString function_name;
FlatPtr instruction_address { 0 };
FlatPtr frame_base { 0 };
Optional<Debug::DebugInfo::SourcePosition> m_source_position;

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#include <AK/Types.h>
namespace HackStudio {
@ -17,5 +17,5 @@ enum class BreakpointChange {
Removed,
};
using BreakpointChangeCallback = Function<void(String const& file, size_t line, BreakpointChange)>;
using BreakpointChangeCallback = Function<void(DeprecatedString const& file, size_t line, BreakpointChange)>;
}

View file

@ -105,7 +105,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode
auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data());
if (does_variable_support_writing(variable)) {
context_menu->add_action(GUI::Action::create("Change value", [&](auto&) {
String value;
DeprecatedString value;
if (GUI::InputBox::show(window(), value, "Enter new value:"sv, "Set variable value"sv) == GUI::InputBox::ExecResult::OK) {
auto& model = static_cast<VariablesModel&>(*m_variables_view->model());
model.set_variable_value(index, value, window());

View file

@ -18,7 +18,7 @@ Debugger& Debugger::the()
}
void Debugger::initialize(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback)
@ -32,7 +32,7 @@ bool Debugger::is_initialized()
}
Debugger::Debugger(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback)
@ -45,7 +45,7 @@ Debugger::Debugger(
pthread_cond_init(&m_ui_action_cond, nullptr);
}
void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type)
void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type)
{
auto position = create_source_position(file, line);
@ -77,7 +77,7 @@ void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointC
}
}
bool Debugger::set_execution_position(String const& file, size_t line)
bool Debugger::set_execution_position(DeprecatedString const& file, size_t line)
{
auto position = create_source_position(file, line);
auto session = Debugger::the().session();
@ -92,11 +92,11 @@ bool Debugger::set_execution_position(String const& file, size_t line)
return true;
}
Debug::DebugInfo::SourcePosition Debugger::create_source_position(String const& file, size_t line)
Debug::DebugInfo::SourcePosition Debugger::create_source_position(DeprecatedString const& file, size_t line)
{
if (file.starts_with('/'))
return { file, line + 1 };
return { LexicalPath::canonicalized_path(String::formatted("{}/{}", m_source_root, file)), line + 1 };
return { LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_source_root, file)), line + 1 };
}
intptr_t Debugger::start_static()

View file

@ -26,18 +26,18 @@ public:
};
static void initialize(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback);
static bool is_initialized();
void on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(String const& file, size_t line);
void on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(DeprecatedString const& file, size_t line);
void set_executable_path(String const& path) { m_executable_path = path; }
void set_source_root(String const& source_root) { m_source_root = source_root; }
void set_executable_path(DeprecatedString const& path) { m_executable_path = path; }
void set_source_root(DeprecatedString const& source_root) { m_source_root = source_root; }
Debug::DebugSession* session() { return m_debug_session.ptr(); }
@ -90,12 +90,12 @@ private:
};
explicit Debugger(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback);
Debug::DebugInfo::SourcePosition create_source_position(String const& file, size_t line);
Debug::DebugInfo::SourcePosition create_source_position(DeprecatedString const& file, size_t line);
void start();
int debugger_loop();
@ -107,7 +107,7 @@ private:
void insert_temporary_breakpoint_at_return_address(PtraceRegisters const&);
OwnPtr<Debug::DebugSession> m_debug_session;
String m_source_root;
DeprecatedString m_source_root;
DebuggingState m_state;
pthread_mutex_t m_ui_action_mutex {};
@ -116,7 +116,7 @@ private:
Vector<Debug::DebugInfo::SourcePosition> m_breakpoints;
String m_executable_path;
DeprecatedString m_executable_path;
Function<HasControlPassedToUser(PtraceRegisters const&)> m_on_stopped_callback;
Function<void()> m_on_continue_callback;

View file

@ -73,7 +73,7 @@ int DisassemblyModel::row_count(const GUI::ModelIndex&) const
return m_instructions.size();
}
String DisassemblyModel::column_name(int column) const
DeprecatedString DisassemblyModel::column_name(int column) const
{
switch (column) {
case Column::Address:
@ -94,7 +94,7 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::Address)
return String::formatted("{:p}", insn.address);
return DeprecatedString::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;
for (auto ch : insn.bytes)

View file

@ -22,7 +22,7 @@ namespace HackStudio {
struct InstructionData {
X86::Instruction insn;
String disassembly;
DeprecatedString disassembly;
StringView bytes;
FlatPtr address { 0 };
};
@ -45,7 +45,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
private:

View file

@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly()
m_unavailable_disassembly_widget->set_visible(false);
}
void DisassemblyWidget::hide_disassembly(String const& reason)
void DisassemblyWidget::hide_disassembly(DeprecatedString const& reason)
{
m_top_container->set_visible(false);
m_disassembly_view->set_visible(false);

View file

@ -21,18 +21,18 @@ class UnavailableDisassemblyWidget final : public GUI::Frame {
public:
virtual ~UnavailableDisassemblyWidget() override { }
String const& reason() const { return m_reason; }
void set_reason(String const& text) { m_reason = text; }
DeprecatedString const& reason() const { return m_reason; }
void set_reason(DeprecatedString const& text) { m_reason = text; }
private:
UnavailableDisassemblyWidget(String const& reason)
UnavailableDisassemblyWidget(DeprecatedString const& reason)
: m_reason(reason)
{
}
virtual void paint_event(GUI::PaintEvent& event) override;
String m_reason;
DeprecatedString m_reason;
};
class DisassemblyWidget final : public GUI::Widget {
@ -47,7 +47,7 @@ private:
DisassemblyWidget();
void show_disassembly();
void hide_disassembly(String const&);
void hide_disassembly(DeprecatedString const&);
RefPtr<GUI::Widget> m_top_container;
RefPtr<GUI::TableView> m_disassembly_view;

View file

@ -112,7 +112,7 @@ int RegistersModel::row_count(const GUI::ModelIndex&) const
return m_registers.size();
}
String RegistersModel::column_name(int column) const
DeprecatedString RegistersModel::column_name(int column) const
{
switch (column) {
case Column::Register:
@ -140,7 +140,7 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
if (index.column() == Column::Register)
return reg.name;
if (index.column() == Column::Value)
return String::formatted("{:p}", reg.value);
return DeprecatedString::formatted("{:p}", reg.value);
return {};
}
return {};

View file

@ -14,7 +14,7 @@
namespace HackStudio {
struct RegisterData {
String name;
DeprecatedString name;
FlatPtr value;
bool changed { false };
};
@ -41,7 +41,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
PtraceRegisters const& raw_registers() const { return m_raw_registers; }

View file

@ -55,7 +55,7 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const
return node->members.size();
}
static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address)
return "N/A";
@ -69,20 +69,20 @@ static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& var
return enumerator->constant_data.as_u32 == enumerator_value;
});
if (it.is_end())
return String::formatted("Unknown ({})", value.value());
return String::formatted("{}::{}", variable.type_name, (*it)->name);
return DeprecatedString::formatted("Unknown ({})", value.value());
return DeprecatedString::formatted("{}::{}", variable.type_name, (*it)->name);
}
if (variable.type_name == "int") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return String::formatted("{}", static_cast<int>(value.value()));
return DeprecatedString::formatted("{}", static_cast<int>(value.value()));
}
if (variable.type_name == "char") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return String::formatted("'{0:c}'", (char)value.value());
return DeprecatedString::formatted("'{0:c}'", (char)value.value());
}
if (variable.type_name == "bool") {
@ -91,13 +91,13 @@ static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& var
return (value.value() & 1) ? "true" : "false";
}
return String::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
return DeprecatedString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
}
static Optional<u32> string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.is_enum_type()) {
auto prefix_string = String::formatted("{}::", variable.type_name);
auto prefix_string = DeprecatedString::formatted("{}::", variable.type_name);
auto string_to_use = string_value;
if (string_value.starts_with(prefix_string))
string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length());
@ -143,7 +143,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView
GUI::MessageBox::show(
parent_window,
String::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
DeprecatedString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
"Set value failed"sv,
GUI::MessageBox::Type::Error);
}
@ -154,7 +154,7 @@ GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
switch (role) {
case GUI::ModelRole::Display: {
auto value_as_string = variable_value_as_string(*variable);
return String::formatted("{}: {}", variable->name, value_as_string);
return DeprecatedString::formatted("{}: {}", variable->name, value_as_string);
}
case GUI::ModelRole::Icon:
return m_variable_icon;