1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:37:44 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -85,7 +85,7 @@ Vector<ELF::AuxiliaryValue> Emulator::generate_auxiliary_vector(FlatPtr load_bas
auxv.append({ ELF::AuxiliaryValue::Entry, (void*)entry_eip });
// FIXME: Don't hard code this? We might support other platforms later.. (e.g. x86_64)
auxv.append({ ELF::AuxiliaryValue::Platform, "i386" });
auxv.append({ ELF::AuxiliaryValue::Platform, "i386"sv });
auxv.append({ ELF::AuxiliaryValue::ExecFilename, executable_path });
@ -154,7 +154,7 @@ bool Emulator::load_elf()
{
auto file_or_error = Core::MappedFile::map(m_executable_path);
if (file_or_error.is_error()) {
reportln("Unable to map {}: {}", m_executable_path, file_or_error.error());
reportln("Unable to map {}: {}"sv, m_executable_path, file_or_error.error());
return false;
}
@ -169,7 +169,7 @@ bool Emulator::load_elf()
StringBuilder interpreter_path_builder;
auto result_or_error = ELF::validate_program_headers(*(Elf32_Ehdr const*)elf_image_data.data(), elf_image_data.size(), elf_image_data, &interpreter_path_builder);
if (result_or_error.is_error() || !result_or_error.value()) {
reportln("failed to validate ELF file");
reportln("failed to validate ELF file"sv);
return false;
}
auto interpreter_path = interpreter_path_builder.string_view();
@ -229,7 +229,7 @@ int Emulator::exec()
size_t instructions_until_next_profile_dump = profile_instruction_interval();
if (is_profiling() && m_loader_text_size.has_value())
emit_profile_event(profile_stream(), "mmap", String::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size));
emit_profile_event(profile_stream(), "mmap"sv, String::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size));
while (!m_shutdown) {
if (m_steps_til_pause) [[likely]] {
@ -493,7 +493,7 @@ String Emulator::create_backtrace_line(FlatPtr address)
void Emulator::dump_backtrace(Vector<FlatPtr> const& backtrace)
{
for (auto const& address : backtrace) {
reportln("{}", create_backtrace_line(address));
reportln("{}"sv, create_backtrace_line(address));
}
}
@ -511,7 +511,7 @@ void Emulator::emit_profile_sample(AK::OutputStream& output)
gettimeofday(&tv, nullptr);
builder.appendff(R"~(, {{"type": "sample", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [)~", getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000);
builder.join(',', raw_backtrace());
builder.append("]}\n");
builder.append("]}\n"sv);
output.write_or_error(builder.string_view().bytes());
}
@ -626,7 +626,7 @@ void Emulator::dispatch_one_pending_signal()
auto action = default_signal_action(signum);
if (action == DefaultSignalAction::Ignore)
return;
reportln("\n=={}== Got signal {} ({}), no handler registered", getpid(), signum, strsignal(signum));
reportln("\n=={}== Got signal {} ({}), no handler registered"sv, getpid(), signum, strsignal(signum));
dump_backtrace();
m_shutdown = true;
return;
@ -637,7 +637,7 @@ void Emulator::dispatch_one_pending_signal()
return;
}
reportln("\n=={}== Got signal {} ({}), handler at {:p}", getpid(), signum, strsignal(signum), handler.handler);
reportln("\n=={}== Got signal {} ({}), handler at {:p}"sv, getpid(), signum, strsignal(signum), handler.handler);
auto old_esp = m_cpu->esp().value();
@ -762,7 +762,7 @@ void Emulator::setup_signal_trampoline()
void Emulator::dump_regions() const
{
const_cast<SoftMMU&>(m_mmu).for_each_region([&](Region const& region) {
reportln("{:p}-{:p} {:c}{:c}{:c} {} {}{}{} ",
reportln("{:p}-{:p} {:c}{:c}{:c} {} {}{}{} "sv,
region.base(),
region.end() - 1,
region.is_readable() ? 'R' : '-',

View file

@ -38,7 +38,7 @@ namespace UserspaceEmulator {
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
{
if constexpr (SPAM_DEBUG)
reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function);
reportln("Syscall: {} ({:x})"sv, Syscall::to_string((Syscall::Function)function), function);
switch (function) {
case SC_accept4:
return virt$accept4(arg1);
@ -261,7 +261,7 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
case SC_write:
return virt$write(arg1, arg2, arg3);
default:
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function);
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}"sv, getpid(), Syscall::to_string((Syscall::Function)function), function);
dump_backtrace();
TODO();
}
@ -297,7 +297,7 @@ FlatPtr Emulator::virt$perf_event(int event, FlatPtr arg1, FlatPtr arg2)
if (event == PERF_EVENT_SIGNPOST) {
if (is_profiling()) {
if (profiler_string_id_map().size() > arg1)
emit_profile_event(profile_stream(), "signpost", String::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2));
emit_profile_event(profile_stream(), "signpost"sv, String::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2));
syscall(SC_perf_event, PERF_EVENT_SIGNPOST, profiler_string_id_map().at(arg1), arg2);
} else {
syscall(SC_perf_event, PERF_EVENT_SIGNPOST, arg1, arg2);
@ -846,7 +846,7 @@ static void round_to_page_size(FlatPtr& address, size_t& size)
u32 Emulator::virt$munmap(FlatPtr address, size_t size)
{
if (is_profiling())
emit_profile_event(profile_stream(), "munmap", String::formatted("\"ptr\": {}, \"size\": {}", address, size));
emit_profile_event(profile_stream(), "munmap"sv, String::formatted("\"ptr\": {}, \"size\": {}", address, size));
round_to_page_size(address, size);
Vector<Region*, 4> marked_for_deletion;
bool has_non_mmap_region = false;
@ -894,7 +894,7 @@ u32 Emulator::virt$mmap(u32 params_addr)
} else {
// mmap(nullptr, …, MAP_FIXED) is technically okay, but tends to be a bug.
// Therefore, refuse to be helpful.
reportln("\n=={}== \033[31;1mTried to mmap at nullptr with MAP_FIXED.\033[0m, {:#x} bytes.", getpid(), params.size);
reportln("\n=={}== \033[31;1mTried to mmap at nullptr with MAP_FIXED.\033[0m, {:#x} bytes."sv, getpid(), params.size);
dump_backtrace();
}
} else {
@ -916,7 +916,7 @@ u32 Emulator::virt$mmap(u32 params_addr)
}
if (is_profiling())
emit_profile_event(profile_stream(), "mmap", String::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str));
emit_profile_event(profile_stream(), "mmap"sv, String::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str));
if (params.flags & MAP_ANONYMOUS) {
mmu().add_region(MmapRegion::create_anonymous(final_address, final_size, params.prot, move(name_str)));
@ -1082,7 +1082,7 @@ void Emulator::virt$sync()
void Emulator::virt$exit(int status)
{
reportln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!", getpid(), status);
reportln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!"sv, getpid(), status);
m_exit_status = status;
m_shutdown = true;
}
@ -1173,7 +1173,7 @@ int Emulator::virt$ioctl([[maybe_unused]] int fd, unsigned request, [[maybe_unus
return syscall(SC_ioctl, fd, request, &enabled);
}
default:
reportln("Unsupported ioctl: {}", request);
reportln("Unsupported ioctl: {}"sv, request);
dump_backtrace();
TODO();
}
@ -1245,10 +1245,10 @@ int Emulator::virt$execve(FlatPtr params_addr)
copy_string_list(arguments, params.arguments);
copy_string_list(environment, params.environment);
reportln("\n=={}== \033[33;1mSyscall:\033[0m execve", getpid());
reportln("=={}== @ {}", getpid(), path);
reportln("\n=={}== \033[33;1mSyscall:\033[0m execve"sv, getpid());
reportln("=={}== @ {}"sv, getpid(), path);
for (auto& argument : arguments)
reportln("=={}== - {}", getpid(), argument);
reportln("=={}== - {}"sv, getpid(), argument);
if (access(path.characters(), X_OK) < 0) {
if (errno == ENOENT || errno == EACCES)
@ -1336,7 +1336,7 @@ int Emulator::virt$gethostname(FlatPtr buffer, ssize_t buffer_size)
int Emulator::virt$sigaction(int signum, FlatPtr act, FlatPtr oldact)
{
if (signum == SIGKILL) {
reportln("Attempted to sigaction() with SIGKILL");
reportln("Attempted to sigaction() with SIGKILL"sv);
return -EINVAL;
}

View file

@ -130,8 +130,8 @@ void MallocTracer::target_did_free(Badge<Emulator>, FlatPtr address)
if (auto* mallocation = find_mallocation(address)) {
if (mallocation->freed) {
reportln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address);
reportln("=={}== Address {} has already been passed to free()", getpid(), address);
reportln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}"sv, getpid(), address);
reportln("=={}== Address {} has already been passed to free()"sv, getpid(), address);
m_emulator.dump_backtrace();
} else {
mallocation->freed = true;
@ -140,8 +140,8 @@ void MallocTracer::target_did_free(Badge<Emulator>, FlatPtr address)
return;
}
reportln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address);
reportln("=={}== Address {} has never been returned by malloc()", getpid(), address);
reportln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}"sv, getpid(), address);
reportln("=={}== Address {} has never been returned by malloc()"sv, getpid(), address);
m_emulator.dump_backtrace();
}
@ -228,19 +228,19 @@ void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size
auto* mallocation = find_mallocation(region, address);
if (!mallocation) {
reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}"sv, getpid(), size, address);
m_emulator.dump_backtrace();
auto* mallocation_before = find_mallocation_before(address);
auto* mallocation_after = find_mallocation_after(address);
size_t distance_to_mallocation_before = mallocation_before ? (address - mallocation_before->address - mallocation_before->size) : 0;
size_t distance_to_mallocation_after = mallocation_after ? (mallocation_after->address - address) : 0;
if (mallocation_before && (!mallocation_after || distance_to_mallocation_before < distance_to_mallocation_after)) {
reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address);
reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address);
m_emulator.dump_backtrace(mallocation_before->malloc_backtrace);
return;
}
if (mallocation_after && (!mallocation_before || distance_to_mallocation_after < distance_to_mallocation_before)) {
reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address);
reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address);
m_emulator.dump_backtrace(mallocation_after->malloc_backtrace);
}
return;
@ -249,11 +249,11 @@ void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size
size_t offset_into_mallocation = address - mallocation->address;
if (mallocation->freed) {
reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}"sv, getpid(), size, address);
m_emulator.dump_backtrace();
reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:"sv, getpid(), offset_into_mallocation, mallocation->size);
m_emulator.dump_backtrace(mallocation->malloc_backtrace);
reportln("=={}== Later freed at:", getpid());
reportln("=={}== Later freed at:"sv, getpid());
m_emulator.dump_backtrace(mallocation->free_backtrace);
return;
}
@ -274,19 +274,19 @@ void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t siz
auto* mallocation = find_mallocation(region, address);
if (!mallocation) {
reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}"sv, getpid(), size, address);
m_emulator.dump_backtrace();
auto* mallocation_before = find_mallocation_before(address);
auto* mallocation_after = find_mallocation_after(address);
size_t distance_to_mallocation_before = mallocation_before ? (address - mallocation_before->address - mallocation_before->size) : 0;
size_t distance_to_mallocation_after = mallocation_after ? (mallocation_after->address - address) : 0;
if (mallocation_before && (!mallocation_after || distance_to_mallocation_before < distance_to_mallocation_after)) {
reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address);
reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address);
m_emulator.dump_backtrace(mallocation_before->malloc_backtrace);
return;
}
if (mallocation_after && (!mallocation_before || distance_to_mallocation_after < distance_to_mallocation_before)) {
reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address);
reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address);
m_emulator.dump_backtrace(mallocation_after->malloc_backtrace);
}
return;
@ -295,11 +295,11 @@ void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t siz
size_t offset_into_mallocation = address - mallocation->address;
if (mallocation->freed) {
reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}"sv, getpid(), size, address);
m_emulator.dump_backtrace();
reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:"sv, getpid(), offset_into_mallocation, mallocation->size);
m_emulator.dump_backtrace(mallocation->malloc_backtrace);
reportln("=={}== Later freed at:", getpid());
reportln("=={}== Later freed at:"sv, getpid());
m_emulator.dump_backtrace(mallocation->free_backtrace);
return;
}
@ -329,7 +329,7 @@ void MallocTracer::populate_memory_graph()
auto other_address = value.value();
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
if constexpr (REACHABLE_DEBUG)
reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.address);
reportln("region/mallocation {:p} is reachable from other mallocation {:p}"sv, other_address, mallocation.address);
edges_from_mallocation.edges_from_node.append(other_address);
}
}
@ -357,7 +357,7 @@ void MallocTracer::populate_memory_graph()
auto other_address = value.value();
if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) {
if constexpr (REACHABLE_DEBUG)
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1);
reportln("region/mallocation {:p} is reachable from region {:p}-{:p}"sv, other_address, region.base(), region.end() - 1);
m_memory_graph.find(other_address)->value.is_reachable = true;
reachable_mallocations.append(other_address);
}
@ -417,14 +417,14 @@ void MallocTracer::dump_leak_report()
return IterationDecision::Continue;
++leaks_found;
bytes_leaked += mallocation.size;
reportln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address);
reportln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}"sv, getpid(), mallocation.size, mallocation.address);
m_emulator.dump_backtrace(mallocation.malloc_backtrace);
return IterationDecision::Continue;
});
if (!leaks_found)
reportln("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid());
reportln("\n=={}== \033[32;1mNo leaks found!\033[0m"sv, getpid());
else
reportln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked);
reportln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m"sv, getpid(), leaks_found, bytes_leaked);
}
}

View file

@ -65,7 +65,7 @@ MmapRegion::~MmapRegion()
ValueWithShadow<u8> MmapRegion::read8(FlatPtr offset)
{
if (!is_readable()) {
reportln("8-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("8-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -82,7 +82,7 @@ ValueWithShadow<u8> MmapRegion::read8(FlatPtr offset)
ValueWithShadow<u16> MmapRegion::read16(u32 offset)
{
if (!is_readable()) {
reportln("16-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("16-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -103,7 +103,7 @@ ValueWithShadow<u16> MmapRegion::read16(u32 offset)
ValueWithShadow<u32> MmapRegion::read32(u32 offset)
{
if (!is_readable()) {
reportln("32-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("32-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -124,7 +124,7 @@ ValueWithShadow<u32> MmapRegion::read32(u32 offset)
ValueWithShadow<u64> MmapRegion::read64(u32 offset)
{
if (!is_readable()) {
reportln("64-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("64-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -145,7 +145,7 @@ ValueWithShadow<u64> MmapRegion::read64(u32 offset)
ValueWithShadow<u128> MmapRegion::read128(u32 offset)
{
if (!is_readable()) {
reportln("128-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("128-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -165,7 +165,7 @@ ValueWithShadow<u128> MmapRegion::read128(u32 offset)
ValueWithShadow<u256> MmapRegion::read256(u32 offset)
{
if (!is_readable()) {
reportln("256-bit read from unreadable MmapRegion @ {:p}", base() + offset);
reportln("256-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -185,7 +185,7 @@ ValueWithShadow<u256> MmapRegion::read256(u32 offset)
void MmapRegion::write8(u32 offset, ValueWithShadow<u8> value)
{
if (!is_writable()) {
reportln("8-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("8-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -203,7 +203,7 @@ void MmapRegion::write8(u32 offset, ValueWithShadow<u8> value)
void MmapRegion::write16(u32 offset, ValueWithShadow<u16> value)
{
if (!is_writable()) {
reportln("16-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("16-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -221,7 +221,7 @@ void MmapRegion::write16(u32 offset, ValueWithShadow<u16> value)
void MmapRegion::write32(u32 offset, ValueWithShadow<u32> value)
{
if (!is_writable()) {
reportln("32-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("32-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -240,7 +240,7 @@ void MmapRegion::write32(u32 offset, ValueWithShadow<u32> value)
void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value)
{
if (!is_writable()) {
reportln("64-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("64-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -259,7 +259,7 @@ void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value)
void MmapRegion::write128(u32 offset, ValueWithShadow<u128> value)
{
if (!is_writable()) {
reportln("128-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("128-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}
@ -277,7 +277,7 @@ void MmapRegion::write128(u32 offset, ValueWithShadow<u128> value)
void MmapRegion::write256(u32 offset, ValueWithShadow<u256> value)
{
if (!is_writable()) {
reportln("256-bit write from unwritable MmapRegion @ {:p}", base() + offset);
reportln("256-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset);
emulator().dump_backtrace();
TODO();
}

View file

@ -19,11 +19,11 @@
# pragma GCC optimize("O3")
#endif
#define TODO_INSN() \
do { \
reportln("\n=={}== Unimplemented instruction: {}\n", getpid(), __FUNCTION__); \
m_emulator.dump_backtrace(); \
_exit(0); \
#define TODO_INSN() \
do { \
reportln("\n=={}== Unimplemented instruction: {}\n"sv, getpid(), __FUNCTION__); \
m_emulator.dump_backtrace(); \
_exit(0); \
} while (0)
#define FPU_INSTRUCTION(name) \
@ -55,7 +55,7 @@ template<typename T>
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message)
{
if (value_with_shadow.is_uninitialized()) [[unlikely]] {
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message);
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n"sv, message);
Emulator::the().dump_backtrace();
}
}
@ -63,7 +63,7 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* messag
ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(char const* message) const
{
if (m_flags_tainted) [[unlikely]] {
reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message);
reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n"sv, getpid(), message);
Emulator::the().dump_backtrace();
}
}
@ -108,7 +108,7 @@ void SoftCPU::update_code_cache()
VERIFY(region);
if (!region->is_executable()) {
reportln("SoftCPU::update_code_cache: Non-executable region @ {:p}", eip());
reportln("SoftCPU::update_code_cache: Non-executable region @ {:p}"sv, eip());
Emulator::the().dump_backtrace();
TODO();
}
@ -1388,13 +1388,13 @@ void SoftCPU::DIV_RM16(const X86::Instruction& insn)
{
auto divisor = insn.modrm().read16(*this, insn);
if (divisor.value() == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
u32 dividend = ((u32)dx().value() << 16) | ax().value();
auto quotient = dividend / divisor.value();
if (quotient > NumericLimits<u16>::max()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}
@ -1409,13 +1409,13 @@ void SoftCPU::DIV_RM32(const X86::Instruction& insn)
{
auto divisor = insn.modrm().read32(*this, insn);
if (divisor.value() == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
u64 dividend = ((u64)edx().value() << 32) | eax().value();
auto quotient = dividend / divisor.value();
if (quotient > NumericLimits<u32>::max()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}
@ -1430,13 +1430,13 @@ void SoftCPU::DIV_RM8(const X86::Instruction& insn)
{
auto divisor = insn.modrm().read8(*this, insn);
if (divisor.value() == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
u16 dividend = ax().value();
auto quotient = dividend / divisor.value();
if (quotient > NumericLimits<u8>::max()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}
@ -1451,7 +1451,7 @@ void SoftCPU::ENTER32(const X86::Instruction&) { TODO_INSN(); }
void SoftCPU::ESCAPE(const X86::Instruction&)
{
reportln("FIXME: x87 floating-point support");
reportln("FIXME: x87 floating-point support"sv);
m_emulator.dump_backtrace();
TODO();
}
@ -1582,13 +1582,13 @@ void SoftCPU::IDIV_RM16(const X86::Instruction& insn)
auto divisor_with_shadow = insn.modrm().read16(*this, insn);
auto divisor = (i16)divisor_with_shadow.value();
if (divisor == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
i32 dividend = (i32)(((u32)dx().value() << 16) | (u32)ax().value());
i32 result = dividend / divisor;
if (result > NumericLimits<i16>::max() || result < NumericLimits<i16>::min()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}
@ -1602,13 +1602,13 @@ void SoftCPU::IDIV_RM32(const X86::Instruction& insn)
auto divisor_with_shadow = insn.modrm().read32(*this, insn);
auto divisor = (i32)divisor_with_shadow.value();
if (divisor == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
i64 dividend = (i64)(((u64)edx().value() << 32) | (u64)eax().value());
i64 result = dividend / divisor;
if (result > NumericLimits<i32>::max() || result < NumericLimits<i32>::min()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}
@ -1622,13 +1622,13 @@ void SoftCPU::IDIV_RM8(const X86::Instruction& insn)
auto divisor_with_shadow = insn.modrm().read8(*this, insn);
auto divisor = (i8)divisor_with_shadow.value();
if (divisor == 0) {
reportln("Divide by zero");
reportln("Divide by zero"sv);
TODO();
}
i16 dividend = ax().value();
i16 result = dividend / divisor;
if (result > NumericLimits<i8>::max() || result < NumericLimits<i8>::min()) {
reportln("Divide overflow");
reportln("Divide overflow"sv);
TODO();
}

View file

@ -20,18 +20,18 @@
# pragma GCC optimize("O3")
#endif
#define TODO_INSN() \
do { \
reportln("\n=={}== Unimplemented instruction: {}\n", getpid(), __FUNCTION__); \
m_emulator.dump_backtrace(); \
_exit(0); \
#define TODO_INSN() \
do { \
reportln("\n=={}== Unimplemented instruction: {}\n"sv, getpid(), __FUNCTION__); \
m_emulator.dump_backtrace(); \
_exit(0); \
} while (0)
template<typename T>
ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message)
{
if (value_with_shadow.is_uninitialized()) [[unlikely]] {
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message);
reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n"sv, message);
UserspaceEmulator::Emulator::the().dump_backtrace();
}
}
@ -41,14 +41,14 @@ namespace UserspaceEmulator { // NOLINT(readability-implicit-bool-conversion) 0/
ALWAYS_INLINE void SoftFPU::warn_if_mmx_absolute(u8 index) const
{
if (m_reg_is_mmx[index]) [[unlikely]] {
reportln("\033[31;1mWarning! Use of an MMX register as an FPU value ({} abs)\033[0m\n", index);
reportln("\033[31;1mWarning! Use of an MMX register as an FPU value ({} abs)\033[0m\n"sv, index);
m_emulator.dump_backtrace();
}
}
ALWAYS_INLINE void SoftFPU::warn_if_fpu_absolute(u8 index) const
{
if (!m_reg_is_mmx[index]) [[unlikely]] {
reportln("\033[31;1mWarning! Use of an FPU value ({} abs) as an MMX register\033[0m\n", index);
reportln("\033[31;1mWarning! Use of an FPU value ({} abs) as an MMX register\033[0m\n"sv, index);
m_emulator.dump_backtrace();
}
}
@ -161,7 +161,7 @@ ALWAYS_INLINE void SoftFPU::fpu_set_exception(FPU_Exception ex)
// the previous eip
// FIXME: Call FPU Exception handler
reportln("Trying to call Exception handler from {}", fpu_exception_string(ex));
reportln("Trying to call Exception handler from {}"sv, fpu_exception_string(ex));
fpu_dump_env();
m_emulator.dump_backtrace();
TODO();

View file

@ -87,7 +87,7 @@ private:
void fpu_dump_env()
{
reportln("Exceptions: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{} #SF:{} Summary:{}",
reportln("Exceptions: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{} #SF:{} Summary:{}"sv,
m_fpu_error_invalid,
m_fpu_error_denorm,
m_fpu_error_zero_div,
@ -96,18 +96,18 @@ private:
m_fpu_error_precision,
m_fpu_error_stackfault,
m_fpu_error_summary);
reportln("Masks: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{}",
reportln("Masks: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{}"sv,
m_fpu_cw.mask_invalid,
m_fpu_cw.mask_denorm,
m_fpu_cw.mask_zero_div,
m_fpu_cw.mask_overflow,
m_fpu_cw.mask_underflow,
m_fpu_cw.mask_precision);
reportln("C0:{} C1:{} C2:{} C3:{}", c0(), c1(), c2(), c3());
reportln("fpu-stacktop: {}", m_fpu_stack_top);
reportln("fpu-stack /w stacktop (real):");
reportln("C0:{} C1:{} C2:{} C3:{}"sv, c0(), c1(), c2(), c3());
reportln("fpu-stacktop: {}"sv, m_fpu_stack_top);
reportln("fpu-stack /w stacktop (real):"sv);
for (u8 i = 0; i < 8; ++i) {
reportln("\t{} ({}): fp {} ({}), mmx {:016x}",
reportln("\t{} ({}): fp {} ({}), mmx {:016x}"sv,
i, (u8)((m_fpu_stack_top + i) % 8),
m_storage[(m_fpu_stack_top + i) % 8].fp, fpu_is_set(i) ? "set" : "free",
m_storage[(m_fpu_stack_top + i) % 8].mmx.raw);
@ -142,14 +142,14 @@ private:
ALWAYS_INLINE void fpu_set_stack_overflow()
{
reportln("Stack Overflow");
reportln("Stack Overflow"sv);
set_c1(1);
fpu_set_exception(FPU_Exception::StackFault);
}
ALWAYS_INLINE void fpu_set_stack_underflow()
{
reportln("Stack Underflow");
reportln("Stack Underflow"sv);
set_c1(0);
fpu_set_exception(FPU_Exception::StackFault);
}

View file

@ -94,13 +94,13 @@ ValueWithShadow<u8> SoftMMU::read8(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read8: No region for @ {:p}", address.offset());
reportln("SoftMMU::read8: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read8: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read8: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -112,13 +112,13 @@ ValueWithShadow<u16> SoftMMU::read16(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read16: No region for @ {:p}", address.offset());
reportln("SoftMMU::read16: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read16: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read16: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -130,13 +130,13 @@ ValueWithShadow<u32> SoftMMU::read32(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read32: No region for @ {:04x}:{:p}", address.selector(), address.offset());
reportln("SoftMMU::read32: No region for @ {:04x}:{:p}"sv, address.selector(), address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read32: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read32: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -148,13 +148,13 @@ ValueWithShadow<u64> SoftMMU::read64(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read64: No region for @ {:p}", address.offset());
reportln("SoftMMU::read64: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read64: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read64: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -166,13 +166,13 @@ ValueWithShadow<u128> SoftMMU::read128(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read128: No region for @ {:p}", address.offset());
reportln("SoftMMU::read128: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read128: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read128: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -184,13 +184,13 @@ ValueWithShadow<u256> SoftMMU::read256(X86::LogicalAddress address)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read256: No region for @ {:p}", address.offset());
reportln("SoftMMU::read256: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read256: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read256: Non-readable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -202,13 +202,13 @@ void SoftMMU::write8(X86::LogicalAddress address, ValueWithShadow<u8> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write8: No region for @ {:p}", address.offset());
reportln("SoftMMU::write8: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write8: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write8: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -219,13 +219,13 @@ void SoftMMU::write16(X86::LogicalAddress address, ValueWithShadow<u16> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write16: No region for @ {:p}", address.offset());
reportln("SoftMMU::write16: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write16: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write16: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -237,13 +237,13 @@ void SoftMMU::write32(X86::LogicalAddress address, ValueWithShadow<u32> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write32: No region for @ {:p}", address.offset());
reportln("SoftMMU::write32: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write32: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write32: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -255,13 +255,13 @@ void SoftMMU::write64(X86::LogicalAddress address, ValueWithShadow<u64> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write64: No region for @ {:p}", address.offset());
reportln("SoftMMU::write64: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write64: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write64: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -273,13 +273,13 @@ void SoftMMU::write128(X86::LogicalAddress address, ValueWithShadow<u128> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write128: No region for @ {:p}", address.offset());
reportln("SoftMMU::write128: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write128: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write128: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
@ -291,13 +291,13 @@ void SoftMMU::write256(X86::LogicalAddress address, ValueWithShadow<u256> value)
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::write256: No region for @ {:p}", address.offset());
reportln("SoftMMU::write256: No region for @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}
if (!region->is_writable()) {
reportln("SoftMMU::write256: Non-writable region @ {:p}", address.offset());
reportln("SoftMMU::write256: Non-writable region @ {:p}"sv, address.offset());
m_emulator.dump_backtrace();
TODO();
}

View file

@ -37,13 +37,13 @@ public:
{
auto* region = find_region(address);
if (!region) {
reportln("SoftMMU::read256: No region for @ {:p}", address.offset());
reportln("SoftMMU::read256: No region for @ {:p}"sv, address.offset());
dump_backtrace();
TODO();
}
if (!region->is_readable()) {
reportln("SoftMMU::read256: Non-readable region @ {:p}", address.offset());
reportln("SoftMMU::read256: Non-readable region @ {:p}"sv, address.offset());
dump_backtrace();
TODO();
}

View file

@ -51,7 +51,7 @@ int main(int argc, char** argv, char** env)
else
executable_path = Core::find_executable_in_path(arguments[0]);
if (executable_path.is_empty()) {
reportln("Cannot find executable for '{}'.", arguments[0]);
reportln("Cannot find executable for '{}'."sv, arguments[0]);
return 1;
}
@ -98,7 +98,7 @@ int main(int argc, char** argv, char** env)
return 1;
StringBuilder builder;
builder.append("(UE) ");
builder.append("(UE) "sv);
builder.append(LexicalPath::basename(arguments[0]));
if (set_process_name(builder.string_view().characters_without_null_termination(), builder.string_view().length()) < 0) {
perror("set_process_name");
@ -106,7 +106,7 @@ int main(int argc, char** argv, char** env)
}
int rc = pthread_setname_np(pthread_self(), builder.to_string().characters());
if (rc != 0) {
reportln("pthread_setname_np: {}", strerror(rc));
reportln("pthread_setname_np: {}"sv, strerror(rc));
return 1;
}