mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-04 07:38:47 +00:00 
			
		
		
		
	Logging: Log all called service functions (under trace). Compile out all trace logs under release for performance.
This commit is contained in:
		
							parent
							
								
									083072de56
								
							
						
					
					
						commit
						228843c43e
					
				
					 12 changed files with 30 additions and 57 deletions
				
			
		| 
						 | 
				
			
			@ -52,8 +52,6 @@ void Initialize(Service::Interface* self) {
 | 
			
		|||
    Kernel::ReleaseMutex(lock_handle);
 | 
			
		||||
 | 
			
		||||
    cmd_buff[1] = 0; // No error
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Service_APT, "called");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GetLockHandle(Service::Interface* self) {
 | 
			
		||||
| 
						 | 
				
			
			@ -194,8 +192,6 @@ void AppletUtility(Service::Interface* self) {
 | 
			
		|||
 *      4 : Handle to shared font memory
 | 
			
		||||
 */
 | 
			
		||||
void GetSharedFont(Service::Interface* self) {
 | 
			
		||||
    LOG_TRACE(Kernel_SVC, "called");
 | 
			
		||||
 | 
			
		||||
    u32* cmd_buff = Kernel::GetCommandBuffer();
 | 
			
		||||
 | 
			
		||||
    if (!shared_font.empty()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,8 +27,6 @@ static void Initialize(Service::Interface* self) {
 | 
			
		|||
    // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per
 | 
			
		||||
    // http://3dbrew.org/wiki/FS:Initialize#Request
 | 
			
		||||
    cmd_buff[1] = RESULT_SUCCESS.raw;
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Service_FS, "called");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -408,8 +406,6 @@ static void IsSdmcDetected(Service::Interface* self) {
 | 
			
		|||
 | 
			
		||||
    cmd_buff[1] = 0;
 | 
			
		||||
    cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Service_FS, "called");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -331,9 +331,6 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
 | 
			
		|||
 | 
			
		||||
/// This triggers handling of the GX command written to the command buffer in shared memory.
 | 
			
		||||
static void TriggerCmdReqQueue(Service::Interface* self) {
 | 
			
		||||
 | 
			
		||||
    LOG_TRACE(Service_GSP, "called");
 | 
			
		||||
 | 
			
		||||
    // Iterate through each thread's command queue...
 | 
			
		||||
    for (unsigned thread_id = 0; thread_id < 0x4; ++thread_id) {
 | 
			
		||||
        CommandBuffer* command_buffer = (CommandBuffer*)GetCommandBuffer(thread_id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,8 +163,6 @@ static void GetIPCHandles(Service::Interface* self) {
 | 
			
		|||
    cmd_buff[6] = event_accelerometer;
 | 
			
		||||
    cmd_buff[7] = event_gyroscope;
 | 
			
		||||
    cmd_buff[8] = event_debug_pad;
 | 
			
		||||
 | 
			
		||||
    LOG_TRACE(Service_HID, "called");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Interface::FunctionInfo FunctionTable[] = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,8 +76,6 @@ static void GetShellState(Service::Interface* self) {
 | 
			
		|||
 | 
			
		||||
    cmd_buff[1] = 0;
 | 
			
		||||
    cmd_buff[2] = shell_open ? 1 : 0;
 | 
			
		||||
 | 
			
		||||
    LOG_TRACE(Service_PTM, "PTM_U::GetShellState called");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,22 @@ class Interface  : public Kernel::Session {
 | 
			
		|||
    // processes.
 | 
			
		||||
 | 
			
		||||
    friend class Manager;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a function string for logging, complete with the name (or header code, depending 
 | 
			
		||||
     * on what's passed in) the port name, and all the cmd_buff arguments.
 | 
			
		||||
     */
 | 
			
		||||
    std::string MakeFunctionString(const std::string& name, const std::string& port_name, const u32* cmd_buff) {
 | 
			
		||||
        // Number of params == bits 0-5 + bits 6-11
 | 
			
		||||
        int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
 | 
			
		||||
 | 
			
		||||
        std::string function_string = Common::StringFromFormat("function '%s': port=%s", name.c_str(), port_name.c_str());
 | 
			
		||||
        for (int i = 1; i <= num_params; ++i) {
 | 
			
		||||
            function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]);
 | 
			
		||||
        }
 | 
			
		||||
        return function_string;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    std::string GetName() const override { return GetPortName(); }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -72,21 +88,14 @@ public:
 | 
			
		|||
        auto itr = m_functions.find(cmd_buff[0]);
 | 
			
		||||
 | 
			
		||||
        if (itr == m_functions.end() || itr->second.func == nullptr) {
 | 
			
		||||
            // Number of params == bits 0-5 + bits 6-11
 | 
			
		||||
            int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
 | 
			
		||||
 | 
			
		||||
            std::string error = "unknown/unimplemented function '%s': port=%s";
 | 
			
		||||
            for (int i = 1; i <= num_params; ++i) {
 | 
			
		||||
                error += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            std::string name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
 | 
			
		||||
 | 
			
		||||
            LOG_ERROR(Service, error.c_str(), name.c_str(), GetPortName().c_str());
 | 
			
		||||
            std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
 | 
			
		||||
            LOG_ERROR(Service, "%s %s", "unknown/unimplemented", MakeFunctionString(function_name, GetPortName(), cmd_buff).c_str());
 | 
			
		||||
 | 
			
		||||
            // TODO(bunnei): Hack - ignore error
 | 
			
		||||
            cmd_buff[1] = 0;
 | 
			
		||||
            return MakeResult<bool>(false);
 | 
			
		||||
        } else {
 | 
			
		||||
            LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName(), cmd_buff).c_str());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        itr->second.func(this);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,16 +14,12 @@ namespace SRV {
 | 
			
		|||
static Handle g_event_handle = 0;
 | 
			
		||||
 | 
			
		||||
static void Initialize(Service::Interface* self) {
 | 
			
		||||
    LOG_DEBUG(Service_SRV, "called");
 | 
			
		||||
 | 
			
		||||
    u32* cmd_buff = Kernel::GetCommandBuffer();
 | 
			
		||||
 | 
			
		||||
    cmd_buff[1] = 0; // No error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void GetProcSemaphore(Service::Interface* self) {
 | 
			
		||||
    LOG_TRACE(Service_SRV, "called");
 | 
			
		||||
 | 
			
		||||
    u32* cmd_buff = Kernel::GetCommandBuffer();
 | 
			
		||||
 | 
			
		||||
    // TODO(bunnei): Change to a semaphore once these have been implemented
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue