Use whichever mount gives the longest result. This change is because argv[0] of MSYS2 programs was /bin/foo.exe when it should be /usr/bin/foo.exe and this caused all sorts of issues with relocation (as e.g. PREFIX is /usr and that is expected to be found as the prefix of argv[0]). For example, from cmd.exe: "C:\msys64\usr\bin\g++.exe -print-prog-name=cc1plus" .. gave: "cc1plus" .. before this patch, when it should have given: "/usr/lib/gcc/x86_64-pc-msys/4.8.2/cc1plus.exe"
89 lines
2.7 KiB
Diff
89 lines
2.7 KiB
Diff
From 9c3ee76d20fbc0ad4714f74b1ae0c04d24b0e8c6 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 1/3] 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 a243041..f21da5c 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
|
|
@@ -450,7 +478,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);
|
|
--
|
|
2.1.0
|
|
|