mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
orbis: improve kevent tracing & simplify API
This commit is contained in:
parent
566ad3edd8
commit
92703954d0
|
|
@ -5,6 +5,7 @@ add_library(obj.orbis-kernel OBJECT
|
||||||
src/dmem.cpp
|
src/dmem.cpp
|
||||||
src/event.cpp
|
src/event.cpp
|
||||||
src/evf.cpp
|
src/evf.cpp
|
||||||
|
src/file.cpp
|
||||||
src/fmem.cpp
|
src/fmem.cpp
|
||||||
src/IoDevice.cpp
|
src/IoDevice.cpp
|
||||||
src/ipmi.cpp
|
src/ipmi.cpp
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ struct FileOps {
|
||||||
ptr<struct sf_hdtr> hdtr, ptr<off_t> sbytes, sint flags,
|
ptr<struct sf_hdtr> hdtr, ptr<off_t> sbytes, sint flags,
|
||||||
Thread *thread) = nullptr;
|
Thread *thread) = nullptr;
|
||||||
|
|
||||||
std::string (*toString)(File *file, Thread *thread);
|
std::string (*toString)(File *file);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct File : rx::RcBase {
|
struct File : rx::RcBase {
|
||||||
|
|
@ -83,5 +83,6 @@ struct File : rx::RcBase {
|
||||||
kvector<Dirent> dirEntries;
|
kvector<Dirent> dirEntries;
|
||||||
|
|
||||||
bool noBlock() const { return (flags & 4) != 0; }
|
bool noBlock() const { return (flags & 4) != 0; }
|
||||||
|
std::string toString();
|
||||||
};
|
};
|
||||||
} // namespace orbis
|
} // namespace orbis
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "../ipmi.hpp"
|
#include "../ipmi.hpp"
|
||||||
#include "../osem.hpp"
|
#include "../osem.hpp"
|
||||||
#include "Thread.hpp"
|
#include "Thread.hpp"
|
||||||
|
#include "rx/StaticString.hpp"
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "ProcessState.hpp"
|
#include "ProcessState.hpp"
|
||||||
#include "cpuset.hpp"
|
#include "cpuset.hpp"
|
||||||
|
|
@ -108,7 +109,7 @@ struct Process final {
|
||||||
|
|
||||||
// Named objects for debugging
|
// Named objects for debugging
|
||||||
rx::shared_mutex namedObjMutex;
|
rx::shared_mutex namedObjMutex;
|
||||||
kmap<void *, kstring> namedObjNames;
|
kmap<void *, rx::StaticString<32>> namedObjNames;
|
||||||
rx::OwningIdMap<NamedObjInfo, uint, 65535, 1> namedObjIds;
|
rx::OwningIdMap<NamedObjInfo, uint, 65535, 1> namedObjIds;
|
||||||
|
|
||||||
kmap<std::int32_t, SigAction> sigActions;
|
kmap<std::int32_t, SigAction> sigActions;
|
||||||
|
|
@ -127,6 +128,7 @@ struct Process final {
|
||||||
return ref.get(storage);
|
return ref.get(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rx::StaticString<32> getNameOfObject(ptr<const void> addr);
|
||||||
Budget *getBudget() const;
|
Budget *getBudget() const;
|
||||||
|
|
||||||
template <typename Cb>
|
template <typename Cb>
|
||||||
|
|
|
||||||
13
kernel/orbis/src/file.cpp
Normal file
13
kernel/orbis/src/file.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "file.hpp"
|
||||||
|
|
||||||
|
std::string orbis::File::toString() {
|
||||||
|
if (ops && ops->toString) {
|
||||||
|
return ops->toString(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device) {
|
||||||
|
return device->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<null device>";
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "KernelAllocator.hpp"
|
#include "KernelAllocator.hpp"
|
||||||
#include "KernelContext.hpp"
|
#include "KernelContext.hpp"
|
||||||
|
#include "rx/format-base.hpp"
|
||||||
#include "sys/sysproto.hpp"
|
#include "sys/sysproto.hpp"
|
||||||
|
|
||||||
#include "thread/Process.hpp"
|
#include "thread/Process.hpp"
|
||||||
|
|
@ -13,11 +14,98 @@
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static std::string filterToString(orbis::sshort filter) {
|
||||||
|
switch (filter) {
|
||||||
|
case orbis::kEvFiltRead:
|
||||||
|
return "Read";
|
||||||
|
case orbis::kEvFiltWrite:
|
||||||
|
return "Write";
|
||||||
|
case orbis::kEvFiltAio:
|
||||||
|
return "Aio";
|
||||||
|
case orbis::kEvFiltVnode:
|
||||||
|
return "Vnode";
|
||||||
|
case orbis::kEvFiltProc:
|
||||||
|
return "Proc";
|
||||||
|
case orbis::kEvFiltSignal:
|
||||||
|
return "Signal";
|
||||||
|
case orbis::kEvFiltTimer:
|
||||||
|
return "Timer";
|
||||||
|
case orbis::kEvFiltFs:
|
||||||
|
return "Fs";
|
||||||
|
case orbis::kEvFiltLio:
|
||||||
|
return "Lio";
|
||||||
|
case orbis::kEvFiltUser:
|
||||||
|
return "User";
|
||||||
|
case orbis::kEvFiltPolling:
|
||||||
|
return "Polling";
|
||||||
|
case orbis::kEvFiltDisplay:
|
||||||
|
return "Display";
|
||||||
|
case orbis::kEvFiltGraphicsCore:
|
||||||
|
return "GraphicsCore";
|
||||||
|
case orbis::kEvFiltHrTimer:
|
||||||
|
return "HrTimer";
|
||||||
|
case orbis::kEvFiltUvdTrap:
|
||||||
|
return "UvdTrap";
|
||||||
|
case orbis::kEvFiltVceTrap:
|
||||||
|
return "VceTrap";
|
||||||
|
case orbis::kEvFiltSdmaTrap:
|
||||||
|
return "SdmaTrap";
|
||||||
|
case orbis::kEvFiltRegEv:
|
||||||
|
return "RegEv";
|
||||||
|
case orbis::kEvFiltGpuException:
|
||||||
|
return "GpuException";
|
||||||
|
case orbis::kEvFiltGpuSystemException:
|
||||||
|
return "GpuSystemException";
|
||||||
|
case orbis::kEvFiltGpuDbgGcEv:
|
||||||
|
return "GpuDbgGcEv";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<invalid " + std::to_string(filter) + ">";
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string kqueue_toString(orbis::File *file) {
|
||||||
|
auto queue = static_cast<orbis::KQueue *>(file);
|
||||||
|
|
||||||
|
std::string result = "kqueue";
|
||||||
|
|
||||||
|
if (!queue->name.empty()) {
|
||||||
|
result += " \"";
|
||||||
|
result += queue->name;
|
||||||
|
result += "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
result += " {";
|
||||||
|
|
||||||
|
for (auto ¬e : queue->notes) {
|
||||||
|
result += " knote {";
|
||||||
|
result += filterToString(note.event.filter);
|
||||||
|
|
||||||
|
if (auto file = note.file) {
|
||||||
|
result += " ";
|
||||||
|
result += file->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
result += rx::format(
|
||||||
|
" ident {:#x}, flags {:#x} fflags {:#x}, data {:#x}, udata {}",
|
||||||
|
note.event.ident, note.event.flags, note.event.fflags, note.event.data,
|
||||||
|
note.event.udata);
|
||||||
|
result += "}";
|
||||||
|
}
|
||||||
|
result += " }";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static orbis::FileOps kqueueOps = {
|
||||||
|
.toString = kqueue_toString,
|
||||||
|
};
|
||||||
|
|
||||||
orbis::SysResult orbis::sys_kqueue(Thread *thread) {
|
orbis::SysResult orbis::sys_kqueue(Thread *thread) {
|
||||||
auto queue = knew<KQueue>();
|
auto queue = knew<KQueue>();
|
||||||
if (queue == nullptr) {
|
if (queue == nullptr) {
|
||||||
return ErrorCode::NOMEM;
|
return ErrorCode::NOMEM;
|
||||||
}
|
}
|
||||||
|
queue->ops = &kqueueOps;
|
||||||
|
|
||||||
auto fd = thread->tproc->fileDescriptors.insert(queue);
|
auto fd = thread->tproc->fileDescriptors.insert(queue);
|
||||||
ORBIS_LOG_TODO(__FUNCTION__, (int)fd);
|
ORBIS_LOG_TODO(__FUNCTION__, (int)fd);
|
||||||
|
|
@ -36,6 +124,7 @@ orbis::SysResult orbis::sys_kqueueex(Thread *thread, ptr<char> name,
|
||||||
if (name != nullptr) {
|
if (name != nullptr) {
|
||||||
queue->name = name;
|
queue->name = name;
|
||||||
}
|
}
|
||||||
|
queue->ops = &kqueueOps;
|
||||||
ORBIS_LOG_TODO(__FUNCTION__, name, flags, (int)fd);
|
ORBIS_LOG_TODO(__FUNCTION__, name, flags, (int)fd);
|
||||||
thread->retval[0] = std::to_underlying(fd);
|
thread->retval[0] = std::to_underlying(fd);
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -158,14 +158,7 @@ struct WrapImpl<Fn> {
|
||||||
result += " (";
|
result += " (";
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
if (file->ops && file->ops->toString) {
|
result += file->toString();
|
||||||
result += file->ops->toString(file.get(), thread);
|
|
||||||
} else if (file->device) {
|
|
||||||
result += file->device->toString();
|
|
||||||
} else {
|
|
||||||
result += "<null device>";
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result += "<invalid fd>";
|
result += "<invalid fd>";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,15 @@ orbis::Process *orbis::createProcess(Process *parentProcess, pid_t pid) {
|
||||||
return &result->object;
|
return &result->object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rx::StaticString<32>
|
||||||
|
orbis::Process::getNameOfObject(ptr<const void> addr) {
|
||||||
|
std::lock_guard lock(namedObjMutex);
|
||||||
|
if (auto it = namedObjNames.find(addr); it != namedObjNames.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
orbis::Budget *orbis::Process::getBudget() const {
|
orbis::Budget *orbis::Process::getBudget() const {
|
||||||
auto result = g_context->budgets.get(budgetId);
|
auto result = g_context->budgets.get(budgetId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,7 @@ orbis::ErrorCode socket_recvfrom(orbis::File *file, void *buf,
|
||||||
return orbis::ErrorCode::NOTSUP;
|
return orbis::ErrorCode::NOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string host_toString(orbis::File *file, orbis::Thread *thread) {
|
static std::string host_toString(orbis::File *file) {
|
||||||
auto hostFile = static_cast<HostFile *>(file);
|
auto hostFile = static_cast<HostFile *>(file);
|
||||||
|
|
||||||
if (!hostFile->path.empty()) {
|
if (!hostFile->path.empty()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue