Merge pull request #1968 from x1nixmzeng/fix-debugger-launch
Fix for starting with debugger
This commit is contained in:
commit
ea7007090c
|
@ -42,11 +42,6 @@ file (GLOB SOURCES
|
|||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.resx"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/PatchManager.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Program.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/AssemblyInfo.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Resources.Designer.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Resources.resx"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Settings.Designer.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Settings.settings"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Resources/BreakpointDisable_16x_24.bmp"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Resources/BreakpointEnable_16x_24.bmp"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Resources/Pause_16x_24.bmp"
|
||||
|
@ -92,10 +87,8 @@ file (GLOB SOURCES
|
|||
"${CXBXR_DEBUGGER_SRC_DIR}/Win32/Windows/NativeMethods.cs"
|
||||
)
|
||||
|
||||
csharp_set_windows_forms_properties(
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.Designer.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.resx"
|
||||
file (GLOB PROPERTIES
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Settings.settings"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/AssemblyInfo.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Resources.Designer.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Resources.resx"
|
||||
|
@ -103,6 +96,16 @@ csharp_set_windows_forms_properties(
|
|||
"${CXBXR_DEBUGGER_SRC_DIR}/Properties/Settings.settings"
|
||||
)
|
||||
|
||||
csharp_set_windows_forms_properties(
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.Designer.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.cs"
|
||||
"${CXBXR_DEBUGGER_SRC_DIR}/Form1.resx"
|
||||
)
|
||||
|
||||
csharp_set_designer_cs_properties(
|
||||
${PROPERTIES}
|
||||
)
|
||||
|
||||
set_source_files_properties("${CXBXR_DEBUGGER_SRC_DIR}/Form1.cs"
|
||||
VS_CSHARP_SubType "Form"
|
||||
)
|
||||
|
@ -113,7 +116,7 @@ set_source_files_properties("${CXBXR_DEBUGGER_SRC_DIR}/RicherTextBox.cs"
|
|||
|
||||
source_group(TREE ${CXBXR_ROOT_DIR} FILES ${SOURCES})
|
||||
|
||||
add_executable(cxbxr-debugger WIN32 ${SOURCES} #Test WIN32 like cxbx does if doesn't need compile option set
|
||||
add_executable(cxbxr-debugger WIN32 ${SOURCES} ${PROPERTIES} #Test WIN32 like cxbx does if doesn't need compile option set
|
||||
)
|
||||
|
||||
set_target_properties(cxbxr-debugger PROPERTIES
|
||||
|
|
|
@ -71,30 +71,29 @@ namespace CxbxDebugger
|
|||
Init();
|
||||
}
|
||||
|
||||
public Debugger(string[] x_args)
|
||||
public Debugger(string[] launchArgs)
|
||||
{
|
||||
Init();
|
||||
|
||||
if (x_args == null)
|
||||
return;
|
||||
|
||||
// Copy all arguments
|
||||
args = x_args;
|
||||
|
||||
// Keep quotes for any strings that may contain spaces
|
||||
int scratch;
|
||||
for (int i = 0; i < args.Length; ++i)
|
||||
// Copy XBE path without the quotes
|
||||
var loadArg = Array.FindIndex(launchArgs, x => x == "/load");
|
||||
if (loadArg != -1)
|
||||
{
|
||||
if (int.TryParse(args[i], out scratch) == false)
|
||||
{
|
||||
args[i] = string.Format("\"{0}\"", args[i]);
|
||||
}
|
||||
Target = launchArgs[loadArg + 1].Trim(new char[] { '"' });
|
||||
}
|
||||
|
||||
// Copy XBE path without the quotes
|
||||
if(x_args.Length > 2)
|
||||
args = new string[launchArgs.Length];
|
||||
|
||||
for (int i = 0; i < launchArgs.Length; ++i)
|
||||
{
|
||||
Target = x_args[2].Trim(new char[] { '"' });
|
||||
var arg = launchArgs[i];
|
||||
|
||||
if (arg.Contains(" "))
|
||||
{
|
||||
arg = string.Format($"\"{arg}\"");
|
||||
}
|
||||
|
||||
args[i] = arg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,11 +175,13 @@ namespace CxbxDebugger
|
|||
var DebugCreationFlags =
|
||||
WinProcesses.ProcessCreationFlags.DEBUG_ONLY_THIS_PROCESS |
|
||||
WinProcesses.ProcessCreationFlags.CREATE_NEW_CONSOLE;
|
||||
|
||||
|
||||
var launchArgs = new StringBuilder(string.Join(" ", args));
|
||||
|
||||
bool bRet = WinProcesses.NativeMethods.CreateProcess
|
||||
(
|
||||
null,
|
||||
new StringBuilder(string.Join(" ", args)),
|
||||
launchArgs,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
|
@ -201,6 +202,10 @@ namespace CxbxDebugger
|
|||
|
||||
State = RunState.Running;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Failed to launch loader '{launchArgs}'");
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace CxbxDebugger
|
|||
{
|
||||
Thread DebuggerWorkerThread;
|
||||
Debugger DebuggerInst;
|
||||
string[] CachedArgs;
|
||||
string[] StartupArgs;
|
||||
string CachedTitle = "";
|
||||
bool SuspendedOnBp = false;
|
||||
|
||||
|
@ -45,13 +45,9 @@ namespace CxbxDebugger
|
|||
throw new Exception("Incorrect usage");
|
||||
}
|
||||
|
||||
var items = new List<string>(args.Length - 1);
|
||||
for (int i = 1; i < args.Length; ++i)
|
||||
{
|
||||
items.Add(args[i]);
|
||||
}
|
||||
|
||||
CachedArgs = items.ToArray();
|
||||
StartupArgs = new string[args.Length - 1];
|
||||
Array.Copy(args, 1, StartupArgs, 0, args.Length - 1);
|
||||
|
||||
DebugEvents = new DebuggerFormEvents(this);
|
||||
|
||||
|
@ -104,7 +100,7 @@ namespace CxbxDebugger
|
|||
if (Create)
|
||||
{
|
||||
// Create debugger instance
|
||||
DebuggerInst = new Debugger(CachedArgs);
|
||||
DebuggerInst = new Debugger(StartupArgs);
|
||||
DebuggerInst.RegisterEventInterfaces(DebugEvents);
|
||||
DebuggerInst.RegisterEventInterfaces(patchMan);
|
||||
|
||||
|
|
Loading…
Reference in New Issue