public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] * winsup/cygwin/exceptions.cc: 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.
  2014-02-09  0:26 [PATCH] Expand $CYGWIN error_start processing Ray Donnelly
@ 2014-02-09  0:26 ` Ray Donnelly
  2014-02-09 20:33 ` [PATCH] Expand $CYGWIN error_start processing Christopher Faylor
  1 sibling, 0 replies; 4+ messages in thread
From: Ray Donnelly @ 2014-02-09  0:26 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Ray Donnelly

---
 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 ceddbbc..99392a7 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, "cygwin1.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.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Expand $CYGWIN error_start processing
@ 2014-02-09  0:26 Ray Donnelly
  2014-02-09  0:26 ` [PATCH] * winsup/cygwin/exceptions.cc: 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 Ray Donnelly
  2014-02-09 20:33 ` [PATCH] Expand $CYGWIN error_start processing Christopher Faylor
  0 siblings, 2 replies; 4+ messages in thread
From: Ray Donnelly @ 2014-02-09  0:26 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Ray Donnelly

I want to use QtCreator as my debugger but the hardcoded
nature of error_start makes that impossible.

This change allows a formatted commandline to be used where
'|' is used to represent spaces and <program-name> and
<process-id> are special tokens.

In my case, I set my CYGWIN env. var to
error_start:C:/Qt/bin/qtcreator.exe|-debug|<process-id>

.. note, QtCreator doesn't work if passed the program name
and must be invoked with the -debug option.

Ray Donnelly (1):
  * winsup/cygwin/exceptions.cc: 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(-)

-- 
1.8.5.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Expand $CYGWIN error_start processing
  2014-02-09  0:26 [PATCH] Expand $CYGWIN error_start processing Ray Donnelly
  2014-02-09  0:26 ` [PATCH] * winsup/cygwin/exceptions.cc: 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 Ray Donnelly
@ 2014-02-09 20:33 ` Christopher Faylor
  2014-02-19 17:53   ` Ray Donnelly
  1 sibling, 1 reply; 4+ messages in thread
From: Christopher Faylor @ 2014-02-09 20:33 UTC (permalink / raw)
  To: cygwin-patches

On Sun, Feb 09, 2014 at 12:25:40AM +0000, Ray Donnelly wrote:
>I want to use QtCreator as my debugger but the hardcoded
>nature of error_start makes that impossible.
>
>This change allows a formatted commandline to be used where
>'|' is used to represent spaces and <program-name> and
><process-id> are special tokens.
>
>In my case, I set my CYGWIN env. var to
>error_start:C:/Qt/bin/qtcreator.exe|-debug|<process-id>
>
>.. note, QtCreator doesn't work if passed the program name
>and must be invoked with the -debug option.
>
>Ray Donnelly (1):
>  * winsup/cygwin/exceptions.cc: 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(-)

Thanks for the patch but adding a new argument delimiter or way to quote
is not something that I'm too keen on.

I have just added, in CVS, the ability to do this:

set CYGWIN=error_start="blah whatever \"more stuff'" and more"

(The above is CMD quoting style of course)

cgf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Expand $CYGWIN error_start processing
  2014-02-09 20:33 ` [PATCH] Expand $CYGWIN error_start processing Christopher Faylor
@ 2014-02-19 17:53   ` Ray Donnelly
  0 siblings, 0 replies; 4+ messages in thread
From: Ray Donnelly @ 2014-02-19 17:53 UTC (permalink / raw)
  To: cygwin-patches

What about the token side of things? <program-name> and <process-id>?
For my use case, its important that I can do something like that too.

On Sun, Feb 9, 2014 at 8:33 PM, Christopher Faylor <> wrote:
> On Sun, Feb 09, 2014 at 12:25:40AM +0000, Ray Donnelly wrote:
>>I want to use QtCreator as my debugger but the hardcoded
>>nature of error_start makes that impossible.
>>
>>This change allows a formatted commandline to be used where
>>'|' is used to represent spaces and <program-name> and
>><process-id> are special tokens.
>>
>>In my case, I set my CYGWIN env. var to
>>error_start:C:/Qt/bin/qtcreator.exe|-debug|<process-id>
>>
>>.. note, QtCreator doesn't work if passed the program name
>>and must be invoked with the -debug option.
>>
>>Ray Donnelly (1):
>>  * winsup/cygwin/exceptions.cc: 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(-)
>
> Thanks for the patch but adding a new argument delimiter or way to quote
> is not something that I'm too keen on.

I didn't add a new way to quote (not that any way existed before), just
a substitute argument delimiter using '|'. It's difficult to get double
quotes and spaces into env. vars, so I worked around that
difficulty in what I think is a sensible way.

>
> I have just added, in CVS, the ability to do this:
>
> set CYGWIN=error_start="blah whatever \"more stuff'" and more"
>

Great, but what about <program-name> and <process-id>, that is the substantial
part of the patch. I can't hook up QtCreator with the fixed arguments that are
added currently, QtCreator doesn't care for the program-name and only works if
presented with <-debug process-id>

> (The above is CMD quoting style of course)
>
> cgf

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-19 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-09  0:26 [PATCH] Expand $CYGWIN error_start processing Ray Donnelly
2014-02-09  0:26 ` [PATCH] * winsup/cygwin/exceptions.cc: 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 Ray Donnelly
2014-02-09 20:33 ` [PATCH] Expand $CYGWIN error_start processing Christopher Faylor
2014-02-19 17:53   ` Ray Donnelly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).