diff options
| author | 2018-11-26 20:05:09 +1100 | |
|---|---|---|
| committer | 2018-11-26 20:05:09 +1100 | |
| commit | 3d627df4d8a682d39e94116b0fc094b752d8d49f (patch) | |
| tree | 4d5ff16e08c9177f7c29e38fe112661fd3eb1dca /src | |
| parent | Improved error messages for SVCs (diff) | |
| download | yuzu-3d627df4d8a682d39e94116b0fc094b752d8d49f.tar.gz yuzu-3d627df4d8a682d39e94116b0fc094b752d8d49f.tar.xz yuzu-3d627df4d8a682d39e94116b0fc094b752d8d49f.zip | |
Improved error messages in AM, HwOpus and NvMap
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/service/audio/hwopus.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvmap.cpp | 26 |
3 files changed, 39 insertions, 26 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 0bd52b602..f6757adab 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -616,7 +616,7 @@ private: | |||
| 616 | 616 | ||
| 617 | const auto storage = applet->GetBroker().PopNormalDataToGame(); | 617 | const auto storage = applet->GetBroker().PopNormalDataToGame(); |
| 618 | if (storage == nullptr) { | 618 | if (storage == nullptr) { |
| 619 | LOG_ERROR(Service_AM, "storage is a nullptr"); | 619 | LOG_ERROR(Service_AM, "storage is a nullptr. There is no data in the current channel"); |
| 620 | 620 | ||
| 621 | rb.Push(ERR_NO_DATA_IN_CHANNEL); | 621 | rb.Push(ERR_NO_DATA_IN_CHANNEL); |
| 622 | return; | 622 | return; |
| @@ -647,7 +647,7 @@ private: | |||
| 647 | 647 | ||
| 648 | const auto storage = applet->GetBroker().PopInteractiveDataToGame(); | 648 | const auto storage = applet->GetBroker().PopInteractiveDataToGame(); |
| 649 | if (storage == nullptr) { | 649 | if (storage == nullptr) { |
| 650 | LOG_ERROR(Service_AM, "storage is a nullptr"); | 650 | LOG_ERROR(Service_AM, "storage is a nullptr. There is no data in the current channel"); |
| 651 | 651 | ||
| 652 | rb.Push(ERR_NO_DATA_IN_CHANNEL); | 652 | rb.Push(ERR_NO_DATA_IN_CHANNEL); |
| 653 | return; | 653 | return; |
| @@ -718,7 +718,9 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) { | |||
| 718 | const std::vector<u8> data{ctx.ReadBuffer()}; | 718 | const std::vector<u8> data{ctx.ReadBuffer()}; |
| 719 | 719 | ||
| 720 | if (data.size() > backing.buffer.size() - offset) { | 720 | if (data.size() > backing.buffer.size() - offset) { |
| 721 | LOG_ERROR(Service_AM, "offset is out of bounds"); | 721 | LOG_ERROR(Service_AM, |
| 722 | "offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}", | ||
| 723 | backing.buffer.size(), data.size(), offset); | ||
| 722 | 724 | ||
| 723 | IPC::ResponseBuilder rb{ctx, 2}; | 725 | IPC::ResponseBuilder rb{ctx, 2}; |
| 724 | rb.Push(ERR_SIZE_OUT_OF_BOUNDS); | 726 | rb.Push(ERR_SIZE_OUT_OF_BOUNDS); |
| @@ -739,7 +741,8 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) { | |||
| 739 | const std::size_t size{ctx.GetWriteBufferSize()}; | 741 | const std::size_t size{ctx.GetWriteBufferSize()}; |
| 740 | 742 | ||
| 741 | if (size > backing.buffer.size() - offset) { | 743 | if (size > backing.buffer.size() - offset) { |
| 742 | LOG_ERROR(Service_AM, "offset is out of bounds"); | 744 | LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}", |
| 745 | backing.buffer.size(), size, offset); | ||
| 743 | 746 | ||
| 744 | IPC::ResponseBuilder rb{ctx, 2}; | 747 | IPC::ResponseBuilder rb{ctx, 2}; |
| 745 | rb.Push(ERR_SIZE_OUT_OF_BOUNDS); | 748 | rb.Push(ERR_SIZE_OUT_OF_BOUNDS); |
| @@ -787,7 +790,7 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) | |||
| 787 | const auto applet = GetAppletFromId(applet_id); | 790 | const auto applet = GetAppletFromId(applet_id); |
| 788 | 791 | ||
| 789 | if (applet == nullptr) { | 792 | if (applet == nullptr) { |
| 790 | LOG_ERROR(Service_AM, "Applet doesn't exist!"); | 793 | LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id)); |
| 791 | 794 | ||
| 792 | IPC::ResponseBuilder rb{ctx, 2}; | 795 | IPC::ResponseBuilder rb{ctx, 2}; |
| 793 | rb.Push(ResultCode(-1)); | 796 | rb.Push(ResultCode(-1)); |
| @@ -825,7 +828,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex | |||
| 825 | handle); | 828 | handle); |
| 826 | 829 | ||
| 827 | if (shared_mem == nullptr) { | 830 | if (shared_mem == nullptr) { |
| 828 | LOG_ERROR(Service_AM, "shared_mem is a nullpr"); | 831 | LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle); |
| 829 | IPC::ResponseBuilder rb{ctx, 2}; | 832 | IPC::ResponseBuilder rb{ctx, 2}; |
| 830 | rb.Push(ResultCode(-1)); | 833 | rb.Push(ResultCode(-1)); |
| 831 | return; | 834 | return; |
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 832159394..5e3672dbd 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -95,13 +95,15 @@ private: | |||
| 95 | const auto start_time = std::chrono::high_resolution_clock::now(); | 95 | const auto start_time = std::chrono::high_resolution_clock::now(); |
| 96 | std::size_t raw_output_sz = output.size() * sizeof(opus_int16); | 96 | std::size_t raw_output_sz = output.size() * sizeof(opus_int16); |
| 97 | if (sizeof(OpusHeader) > input.size()) { | 97 | if (sizeof(OpusHeader) > input.size()) { |
| 98 | LOG_ERROR(Audio, "Input is smaller than the header size"); | 98 | LOG_ERROR(Audio, "Input is smaller than the header size, header_sz={}, input_sz={}", |
| 99 | sizeof(OpusHeader), input.size()); | ||
| 99 | return false; | 100 | return false; |
| 100 | } | 101 | } |
| 101 | OpusHeader hdr{}; | 102 | OpusHeader hdr{}; |
| 102 | std::memcpy(&hdr, input.data(), sizeof(OpusHeader)); | 103 | std::memcpy(&hdr, input.data(), sizeof(OpusHeader)); |
| 103 | if (sizeof(OpusHeader) + static_cast<u32>(hdr.sz) > input.size()) { | 104 | if (sizeof(OpusHeader) + static_cast<u32>(hdr.sz) > input.size()) { |
| 104 | LOG_ERROR(Audio, "Input does not fit in the opus header size"); | 105 | LOG_ERROR(Audio, "Input does not fit in the opus header size. data_sz={}, input_sz={}", |
| 106 | sizeof(OpusHeader) + static_cast<u32>(hdr.sz), input.size()); | ||
| 105 | return false; | 107 | return false; |
| 106 | } | 108 | } |
| 107 | auto frame = input.data() + sizeof(OpusHeader); | 109 | auto frame = input.data() + sizeof(OpusHeader); |
| @@ -109,14 +111,20 @@ private: | |||
| 109 | frame, static_cast<opus_int32>(input.size() - sizeof(OpusHeader)), | 111 | frame, static_cast<opus_int32>(input.size() - sizeof(OpusHeader)), |
| 110 | static_cast<opus_int32>(sample_rate)); | 112 | static_cast<opus_int32>(sample_rate)); |
| 111 | if (decoded_sample_count * channel_count * sizeof(u16) > raw_output_sz) { | 113 | if (decoded_sample_count * channel_count * sizeof(u16) > raw_output_sz) { |
| 112 | LOG_ERROR(Audio, "Decoded data does not fit into the output data"); | 114 | LOG_ERROR( |
| 115 | Audio, | ||
| 116 | "Decoded data does not fit into the output data, decoded_sz={}, raw_output_sz={}", | ||
| 117 | decoded_sample_count * channel_count * sizeof(u16), raw_output_sz); | ||
| 113 | return false; | 118 | return false; |
| 114 | } | 119 | } |
| 120 | const int frame_size = (static_cast<int>(raw_output_sz / sizeof(s16) / channel_count)); | ||
| 115 | auto out_sample_count = | 121 | auto out_sample_count = |
| 116 | opus_decode(decoder.get(), frame, hdr.sz, output.data(), | 122 | opus_decode(decoder.get(), frame, hdr.sz, output.data(), frame_size, 0); |
| 117 | (static_cast<int>(raw_output_sz / sizeof(s16) / channel_count)), 0); | ||
| 118 | if (out_sample_count < 0) { | 123 | if (out_sample_count < 0) { |
| 119 | LOG_ERROR(Audio, "Incorrect sample count received from opus_decode"); | 124 | LOG_ERROR(Audio, |
| 125 | "Incorrect sample count received from opus_decode, " | ||
| 126 | "output_sample_count={}, frame_size={}, data_sz_from_hdr={}", | ||
| 127 | out_sample_count, frame_size, hdr.sz); | ||
| 120 | return false; | 128 | return false; |
| 121 | } | 129 | } |
| 122 | const auto end_time = std::chrono::high_resolution_clock::now() - start_time; | 130 | const auto end_time = std::chrono::high_resolution_clock::now() - start_time; |
| @@ -181,8 +189,8 @@ void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) { | |||
| 181 | ASSERT_MSG(buffer_sz >= worker_sz, "Worker buffer too large"); | 189 | ASSERT_MSG(buffer_sz >= worker_sz, "Worker buffer too large"); |
| 182 | std::unique_ptr<OpusDecoder, OpusDeleter> decoder{ | 190 | std::unique_ptr<OpusDecoder, OpusDeleter> decoder{ |
| 183 | static_cast<OpusDecoder*>(operator new(worker_sz))}; | 191 | static_cast<OpusDecoder*>(operator new(worker_sz))}; |
| 184 | if (opus_decoder_init(decoder.get(), sample_rate, channel_count)) { | 192 | if (const int err = opus_decoder_init(decoder.get(), sample_rate, channel_count)) { |
| 185 | LOG_ERROR(Audio, "Failed to init opus decoder"); | 193 | LOG_ERROR(Audio, "Failed to init opus decoder with error={}", err); |
| 186 | IPC::ResponseBuilder rb{ctx, 2}; | 194 | IPC::ResponseBuilder rb{ctx, 2}; |
| 187 | // TODO(ogniK): Use correct error code | 195 | // TODO(ogniK): Use correct error code |
| 188 | rb.Push(ResultCode(-1)); | 196 | rb.Push(ResultCode(-1)); |
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index 85ba5d4b7..1ec796fc6 100644 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp | |||
| @@ -79,12 +79,12 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 79 | LOG_DEBUG(Service_NVDRV, "called, addr={:X}", params.addr); | 79 | LOG_DEBUG(Service_NVDRV, "called, addr={:X}", params.addr); |
| 80 | 80 | ||
| 81 | if (!params.handle) { | 81 | if (!params.handle) { |
| 82 | LOG_ERROR(Service_NVDRV, "Handle is zero"); | 82 | LOG_ERROR(Service_NVDRV, "Handle is 0"); |
| 83 | return static_cast<u32>(NvErrCodes::InvalidValue); | 83 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | if ((params.align - 1) & params.align) { | 86 | if ((params.align - 1) & params.align) { |
| 87 | LOG_ERROR(Service_NVDRV, "Incorrect alignment"); | 87 | LOG_ERROR(Service_NVDRV, "Incorrect alignment used, alignment={:08X}", params.align); |
| 88 | return static_cast<u32>(NvErrCodes::InvalidValue); | 88 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -95,12 +95,12 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 95 | 95 | ||
| 96 | auto object = GetObject(params.handle); | 96 | auto object = GetObject(params.handle); |
| 97 | if (!object) { | 97 | if (!object) { |
| 98 | LOG_ERROR(Service_NVDRV, "Object does not exist"); | 98 | LOG_ERROR(Service_NVDRV, "Object does not exist, handle={:08X}", params.handle); |
| 99 | return static_cast<u32>(NvErrCodes::InvalidValue); | 99 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | if (object->status == Object::Status::Allocated) { | 102 | if (object->status == Object::Status::Allocated) { |
| 103 | LOG_ERROR(Service_NVDRV, "Object is already allocated"); | 103 | LOG_ERROR(Service_NVDRV, "Object is already allocated, handle={:08X}", params.handle); |
| 104 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); | 104 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| @@ -127,7 +127,7 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 127 | 127 | ||
| 128 | auto object = GetObject(params.handle); | 128 | auto object = GetObject(params.handle); |
| 129 | if (!object) { | 129 | if (!object) { |
| 130 | LOG_ERROR(Service_NVDRV, "Object does not exist"); | 130 | LOG_ERROR(Service_NVDRV, "Object does not exist, handle={:08X}", params.handle); |
| 131 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); | 131 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| @@ -146,13 +146,13 @@ u32 nvmap::IocFromId(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 146 | auto itr = std::find_if(handles.begin(), handles.end(), | 146 | auto itr = std::find_if(handles.begin(), handles.end(), |
| 147 | [&](const auto& entry) { return entry.second->id == params.id; }); | 147 | [&](const auto& entry) { return entry.second->id == params.id; }); |
| 148 | if (itr == handles.end()) { | 148 | if (itr == handles.end()) { |
| 149 | LOG_ERROR(Service_NVDRV, "Object does not exist"); | 149 | LOG_ERROR(Service_NVDRV, "Object does not exist, handle={:08X}", params.handle); |
| 150 | return static_cast<u32>(NvErrCodes::InvalidValue); | 150 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | auto& object = itr->second; | 153 | auto& object = itr->second; |
| 154 | if (object->status != Object::Status::Allocated) { | 154 | if (object->status != Object::Status::Allocated) { |
| 155 | LOG_ERROR(Service_NVDRV, "Object is not allocated"); | 155 | LOG_ERROR(Service_NVDRV, "Object is not allocated, handle={:08X}", params.handle); |
| 156 | return static_cast<u32>(NvErrCodes::InvalidValue); | 156 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| @@ -175,12 +175,12 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 175 | 175 | ||
| 176 | auto object = GetObject(params.handle); | 176 | auto object = GetObject(params.handle); |
| 177 | if (!object) { | 177 | if (!object) { |
| 178 | LOG_ERROR(Service_NVDRV, "Object does not exist"); | 178 | LOG_ERROR(Service_NVDRV, "Object does not exist, handle={:08X}", params.handle); |
| 179 | return static_cast<u32>(NvErrCodes::InvalidValue); | 179 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | if (object->status != Object::Status::Allocated) { | 182 | if (object->status != Object::Status::Allocated) { |
| 183 | LOG_ERROR(Service_NVDRV, "Object is not allocated"); | 183 | LOG_ERROR(Service_NVDRV, "Object is not allocated, handle={:08X}", params.handle); |
| 184 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); | 184 | return static_cast<u32>(NvErrCodes::OperationNotPermitted); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| @@ -220,12 +220,14 @@ u32 nvmap::IocFree(const std::vector<u8>& input, std::vector<u8>& output) { | |||
| 220 | 220 | ||
| 221 | auto itr = handles.find(params.handle); | 221 | auto itr = handles.find(params.handle); |
| 222 | if (itr == handles.end()) { | 222 | if (itr == handles.end()) { |
| 223 | LOG_ERROR(Service_NVDRV, "Object does not exist"); | 223 | LOG_ERROR(Service_NVDRV, "Object does not exist, handle={:08X}", params.handle); |
| 224 | return static_cast<u32>(NvErrCodes::InvalidValue); | 224 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 225 | } | 225 | } |
| 226 | if (!itr->second->refcount) { | 226 | if (!itr->second->refcount) { |
| 227 | LOG_ERROR(Service_NVDRV, | 227 | LOG_ERROR( |
| 228 | "There is no references to this object. The object is already freed"); | 228 | Service_NVDRV, |
| 229 | "There is no references to this object. The object is already freed. handle={:08X}", | ||
| 230 | params.handle); | ||
| 229 | return static_cast<u32>(NvErrCodes::InvalidValue); | 231 | return static_cast<u32>(NvErrCodes::InvalidValue); |
| 230 | } | 232 | } |
| 231 | 233 | ||