Merge pull request #4847 from zhaowenlan1779/ipc-debugger

core, citra_qt: IPC Recorder
This commit is contained in:
James Rowe 2019-09-21 00:04:07 -06:00 committed by GitHub
commit 223bfc9a2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 1112 additions and 15 deletions

View file

@ -171,6 +171,7 @@ void ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context)
auto itr = handlers.find(header_code);
const FunctionInfoBase* info = itr == handlers.end() ? nullptr : &itr->second;
if (info == nullptr || info->handler_callback == nullptr) {
context.ReportUnimplemented();
return ReportUnimplementedFunction(context.CommandBuffer(), info);
}
@ -179,6 +180,14 @@ void ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context)
handler_invoker(this, info->handler_callback, context);
}
std::string ServiceFrameworkBase::GetFunctionName(u32 header) const {
if (!handlers.count(header)) {
return "";
}
return handlers.at(header).name;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Module interface

View file

@ -64,6 +64,9 @@ public:
void HandleSyncRequest(Kernel::HLERequestContext& context) override;
/// Retrieves name of a function based on the header code. For IPC Recorder.
std::string GetFunctionName(u32 header) const;
protected:
/// Member-function pointer type of SyncRequest handlers.
template <typename Self>

View file

@ -42,6 +42,7 @@ ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(
auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name);
registered_services_inverse.emplace(client_port->GetObjectId(), name);
registered_services.emplace(std::move(name), std::move(client_port));
return MakeResult(std::move(server_port));
}
@ -65,4 +66,12 @@ ResultVal<std::shared_ptr<Kernel::ClientSession>> ServiceManager::ConnectToServi
return client_port->Connect();
}
std::string ServiceManager::GetServiceNameByPortId(u32 port) const {
if (registered_services_inverse.count(port)) {
return registered_services_inverse.at(port);
}
return "";
}
} // namespace Service::SM

View file

@ -51,6 +51,8 @@ public:
unsigned int max_sessions);
ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name);
// For IPC Recorder
std::string GetServiceNameByPortId(u32 port) const;
template <typename T>
std::shared_ptr<T> GetService(const std::string& service_name) const {
@ -74,6 +76,10 @@ private:
/// Map of registered services, retrieved using GetServicePort or ConnectToService.
std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services;
// For IPC Recorder
/// client port Object id -> service name
std::unordered_map<u32, std::string> registered_services_inverse;
};
} // namespace Service::SM