UserspaceEmulator: Remove remaining printf calls.

This commit is contained in:
asynts 2020-10-04 16:23:41 +02:00 committed by Andreas Kling
parent d5ffb51a83
commit e089855af0
Notes: sideshowbarker 2024-07-19 02:04:21 +09:00
4 changed files with 6 additions and 17 deletions

View file

@ -217,12 +217,11 @@ void Emulator::dump_backtrace(const Vector<FlatPtr>& backtrace)
u32 offset = 0;
String symbol = m_elf->symbolicate(address, &offset);
auto source_position = m_debug_info->get_source_position(address);
report("==%d== %#08x %s", getpid(), address, symbol.characters());
new_warn("=={}== {:p} {}", getpid(), address, symbol);
if (source_position.has_value())
report(" (\033[34;1m%s\033[0m:%zu)", LexicalPath(source_position.value().file_path).basename().characters(), source_position.value().line_number);
warnln(" (\033[34;1m{}\033[0m:{})", LexicalPath(source_position.value().file_path).basename(), source_position.value().line_number);
else
report(" +%#x", offset);
report("\n");
warnln(" +{:x}", offset);
}
}
@ -897,7 +896,7 @@ u32 Emulator::virt$read(int fd, FlatPtr buffer, ssize_t size)
void Emulator::virt$exit(int status)
{
report("\n==%d== \033[33;1mSyscall: exit(%d)\033[0m, shutting down!\n", getpid(), status);
warnln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!", getpid(), status);
m_exit_status = status;
m_shutdown = true;
}
@ -1239,14 +1238,6 @@ void Emulator::dispatch_one_pending_signal()
m_cpu.set_eip(m_signal_trampoline);
}
void report(const char* format, ...)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
}
// Make sure the compiler doesn't "optimize away" this function:
extern void signal_trampoline_dummy(void);
void signal_trampoline_dummy(void)

View file

@ -171,6 +171,4 @@ private:
FlatPtr m_signal_trampoline { 0 };
};
void report(const char*, ...);
}

View file

@ -36,7 +36,7 @@
#define TODO_INSN() \
do { \
report("\n==%d== Unimplemented instruction: %s\n", getpid(), __FUNCTION__); \
warnln("\n=={}== Unimplemented instruction: {}\n", getpid(), __FUNCTION__); \
m_emulator.dump_backtrace(); \
_exit(0); \
} while (0)

View file

@ -78,7 +78,7 @@ int main(int argc, char** argv, char** env)
}
int rc = pthread_setname_np(pthread_self(), builder.to_string().characters());
if (rc != 0) {
fprintf(stderr, "pthread_setname_np: %s\n", strerror(rc));
warnln("pthread_setname_np: {}", strerror(rc));
return 1;
}
return emulator.exec();