Files
MSYS2-packages/msys2-runtime/0001-Expand-CYGWIN-error_start-processing.patch
Ray Donnelly 00973e4878 msys2-runtime: Expand $MSYS error_start processing
.. so that custom commandlines can be passed to
the debugger program using '|' as an argument
delimiter and <program-name> and <process-id>
as special tokens.
2014-02-09 01:57:10 +00:00

89 lines
2.7 KiB
Diff

From 79687fb0f597abe7d33c20a92dd6d277387513df Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sun, 9 Feb 2014 01:16:08 +0000
Subject: [PATCH] Expand $CYGWIN error_start processing.
.. so that custom commandlines can be passed to the
debugger program using '|' as an argument delimiter
and <program-name> and <process-id> as special
tokens.
---
winsup/cygwin/exceptions.cc | 50 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index b4365cd..0ccc9a3 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -113,13 +113,41 @@ error_start_init (const char *buf)
return;
}
- char pgm[NT_MAX_PATH];
- if (!GetModuleFileName (NULL, pgm, NT_MAX_PATH))
+ char pgm[NT_MAX_PATH+5];
+ strcpy(pgm," \"");
+ if (!GetModuleFileName (NULL, pgm+2, NT_MAX_PATH))
strcpy (pgm, "msys-2.0.dll");
for (char *p = strchr (pgm, '\\'); p; p = strchr (p, '\\'))
*p = '/';
+ strcat(pgm,"\" ");
- __small_sprintf (debugger_command, "%s \"%s\"", buf, pgm);
+ strcpy(debugger_command, buf);
+ /* Turn all '|' into ' ' */
+ char* bar = debugger_command;
+ while ((bar = strchr(debugger_command, '|')))
+ {
+ *bar = ' ';
+ }
+
+ /* If either <program-name> or <process-id> appears then don't
+ append hardcoded arguments. */
+ int new_style = (strstr (debugger_command, "<program-name>") != NULL ||
+ strstr (debugger_command, "<process-id>" ) != NULL) ? 1 : 0;
+
+ /* Only supports one instance of <program-name> as we're space-restricted. */
+ char* pname = strstr (debugger_command, "<program-name>");
+ if (pname !=0)
+ {
+ char debugger_command_rest[2 * NT_MAX_PATH + 20];
+ strcpy (debugger_command_rest, pname + strlen("<program-name>"));
+ strcpy (pname, pgm);
+ strcat (pname, debugger_command_rest);
+ }
+
+ if (new_style == 0)
+ {
+ strcat(debugger_command, pgm);
+ }
}
void
@@ -447,7 +475,21 @@ try_to_debug (bool waitloop)
return 0;
}
- __small_sprintf (strchr (debugger_command, '\0'), " %u", GetCurrentProcessId ());
+ char* pid = strstr (debugger_command, "<process-id>");
+ if (pid != NULL)
+ {
+ int count = __small_sprintf (pid, " %u ", GetCurrentProcessId ());
+ pid += count;
+ count = strlen("<process-id>") - count;
+ while (count-->0)
+ {
+ *pid++ = ' ';
+ }
+ }
+ else
+ {
+ __small_sprintf (strchr (debugger_command, '\0'), " %u", GetCurrentProcessId ());
+ }
LONG prio = GetThreadPriority (GetCurrentThread ());
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST);
--
1.8.5.4