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

Use new format functions in remaining DevTools. (#3755)

* AK: Add formatter for JsonValue.

* Inspector: Use new format functions.

* Profiler: Use new format functions.

* UserspaceEmulator: Use new format functions.
This commit is contained in:
Paul Scharnofske 2020-10-13 18:34:27 +02:00 committed by GitHub
parent 626bb1be9c
commit d94f674bbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 37 deletions

View file

@ -167,11 +167,11 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
return insn.event_count;
}
if (index.column() == Column::Address)
return String::format("%#08x", insn.address);
return String::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;
for (auto ch : insn.bytes) {
builder.appendf("%02x ", (u8)ch);
builder.appendff("{:02x} ", (u8)ch);
}
return builder.to_string();
}

View file

@ -166,14 +166,14 @@ OwnPtr<Profile> Profile::load_from_perfcore_file(const StringView& path)
{
auto file = Core::File::construct(path);
if (!file->open(Core::IODevice::ReadOnly)) {
fprintf(stderr, "Unable to open %s, error: %s\n", path.to_string().characters(), file->error_string());
warnln("Unable to open {}, error: {}", path, file->error_string());
return nullptr;
}
auto json = JsonValue::from_string(file->read_all());
ASSERT(json.has_value());
if (!json.value().is_object()) {
fprintf(stderr, "Invalid perfcore format (not a JSON object)\n");
warnln("Invalid perfcore format (not a JSON object)");
return nullptr;
}
@ -182,7 +182,7 @@ OwnPtr<Profile> Profile::load_from_perfcore_file(const StringView& path)
MappedFile elf_file(executable_path);
if (!elf_file.is_valid()) {
fprintf(stderr, "Unable to open executable '%s' for symbolication.\n", executable_path.characters());
warnln("Unable to open executable '{}' for symbolication.", executable_path);
return nullptr;
}

View file

@ -74,7 +74,7 @@ int main(int argc, char** argv)
auto profile = Profile::load_from_perfcore_file(path);
if (!profile) {
fprintf(stderr, "Unable to load profile '%s'\n", path);
warnln("Unable to load profile '{}'", path);
return 1;
}
@ -170,7 +170,7 @@ bool generate_profile(pid_t pid)
if (profiling_enable(pid) < 0) {
int saved_errno = errno;
GUI::MessageBox::show(nullptr, String::format("Unable to profile PID %d: %s", pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, String::formatted("Unable to profile PID {}: {}", pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error);
return false;
}