From a9413fb189d8d61829bd51b30b456ceb99384617 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Fri, 26 May 2023 16:45:32 +0800 Subject: [PATCH] Fix debugger crash when there are non-ASCII chars in the file path. --- core/debuggerstate.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/debuggerstate.cpp b/core/debuggerstate.cpp index 14cedd2d..6df346ca 100644 --- a/core/debuggerstate.cpp +++ b/core/debuggerstate.cpp @@ -745,7 +745,22 @@ DebuggerState::DebuggerState(BinaryViewRef data, DebuggerController* controller) m_workingDirectory = metadata->GetString(); if (m_workingDirectory == "") - m_workingDirectory = filesystem::path(m_executablePath).parent_path().string(); + { + // This mitigates https://github.com/Vector35/debugger/issues/469. However, it is NOT a proper fix since the + // debugger still will not be able to launch the target properly. We will need to deal with the charset issue + // to get this really fixed. + try + { + m_workingDirectory = filesystem::path(m_executablePath).parent_path().string(); + } + catch (const exception&) + { + LogWarn("Cannot get the default working directory for the input file. " + "There might be special characters in the file path. " + "The debugger may not be able to launch the target correctly. " + "You can try changing the file path to ASCII allow."); + } + } metadata = m_controller->GetData()->QueryMetadata("debugger.remote_host"); if (metadata && metadata->IsString())