Commit Graph

334 Commits

Author SHA1 Message Date
Ryan Prichard
274086bbf5 In winpty-agent, print an error message if the arguments are invalid.
* Some users might think they could run winpty-agent.exe.

 * Right now, when I run winpty-agent.exe from a cmd.exe command prompt
   window, it looks like winpty-agent.exe is segfaulting.  It *ought* to
   print an assertion failed dialog box.
2012-12-20 04:20:10 -08:00
Ryan Prichard
91ccab1443 Add a gyp project that can build winpty-agent and libwinpty.dll with MSVC.
Peter Rekdal submitted the original version of this file.  I made some
minor changes.

Update the .gitignore file to ignore files generated by building winpty
with MSVC.
2012-12-20 04:20:09 -08:00
Ryan Prichard
d02cccb256 MSVC compatibility: Remove the {Agent,WinPty}DebugClient.cc hack.
* With this hack, it's impossible to add all the .cc files to an MSVC
   project, because MSVC understandably thinks that
   agent/AgentDebugClient.cc and shared/DebugClient.cc are two separate
   C++ translation units.  I could rename DebugClient.cc, but it's better
   to just fix the problem with the Makefile.
2012-12-20 04:07:57 -08:00
Ryan Prichard
41e7c31387 MSVC compatibility: Deal with snprintf and vsnprintf.
* When building with MSVC, there is no snprintf function, but there are
   _snprintf, vsnprintf, and _vsnprintf functions (as well as many
   variations on these).  The MSVC _snprintf is not the same as C99's
   snprintf, and in particular, it does not guarantee that the buffer is
   NUL-terminated, whereas C99 does guarantee this.  I want the C99
   behavior, so add a c99_[v]snprintf functions in shared/c99_snprintf.h
   that provide C99 behavior.

 * Details:
   http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
2012-12-20 04:07:56 -08:00
Ryan Prichard
549472ec78 unix-adapter: Link statically with cyggcc_s-1.dll and cygstdc++-6.dll.
* At least for now, I'm shipping Cygwin/MSYS binaries.  On Cygwin (but
   not MSYS), the console.exe executable previously linked dynamically
   to cyggcc_s-1.dll and cygstdc++-6.dll.

   Linking dynamically with cygstdc++-6.dll seems risky for a binary
   not distributed by Cygwin, because G++'s Windows ABI is unstable, at
   least as of G++ 4.7, which turned on the __thiscall calling
   convention.  If a binary I ship ever comes into contact with a
   4.7-versioned cygstdc++-6.dll, then my binary will (very likely)
   segfault.

   So far, I've only observed this ABI incompatibility with MinGW,
   where a sufficiently upgraded MinGW configuration comes with a
   libstdc++-6.dll that is completely incompatible with every previous
   libstdc++-6.dll, so that every program built against the older
   libstdc++-6.dll segfaults immediately.  For now, Cygwin seems stuck
   at G++ 4.5, and my impression (possibly incorrect), is that G++'s
   Windows ABI was stable prior to 4.7.  I think G++'s Linux ABI is
   stable.  Presumably Cygwin will eventually update its compiler,
   though, so it makes sense to fix the problem early.

   I believe I originally chose to dynamically link the libraries
   because it was the default behavior, and I was afraid that a
   non-default option would break something.  It turns out that
   linking statically with cygstdc++-6 *does* break something -- it
   causes linker errors if the code uses std::cerr.  The workaround
   is not to use std::cerr.  This is not a problem for the
   unix-adapter, which already has to put up with MSYS' gimpy G++ 3.4
   compiler.
2012-12-20 04:07:55 -08:00
Ryan Prichard
bb42d17941 Copy the Unix environment to the Win32 environment in the unix-adapter.
This should fix issue 5.

The copying appeared to be necessary only for Cygwin, not for MSYS.  I'm
not sure why this is.  I added a call to cygwin_internal(CW_SYNC_WINENV)
for both anyway, because I didn't think it would hurt.
2012-07-29 00:35:24 +01:00
Ryan Prichard
9b09d3230f Merge pull request #4 from holtrop/master
added an "install" Makefile target
2012-07-13 00:41:04 -07:00
Josh Holtrop
31798422d2 add "install" Makefile target 2012-07-11 14:50:51 -04:00
Ryan Prichard
951729a26d Merge pull request #2 from jkells/master
README Update
2012-05-15 01:41:24 -07:00
Jared Kells
336153418e Typo / Formatting 2012-05-15 09:05:47 +10:00
Jared Kells
6fc6f89b0b Update README file. Provide details of required MinGW packages. 2012-05-14 11:13:10 +10:00
Ryan Prichard
9b66d2cb9c Add a distclean target that removes the files configure creates. 2012-04-17 09:50:19 -07:00
Ryan Prichard
2ebc715c28 Add a toplevel license file and remove the misc one. 2012-04-17 09:50:07 -07:00
Ryan Prichard
0dccfd42e1 Fix edge cases in argvToCommandLine's argument quoting.
* Quoting is needed for empty arguments (i.e. put double-quotes in the
   command line) and for arguments containing tabs because both spaces and
   tabs can separate arguments.

 * A double-quote in the argument doesn't by itself necessitate quoting.

 * As of this change, argvToCommandLine quotes an argument in the same
   cases as Python's subprocess module.
2012-04-03 01:13:08 -07:00
Ryan Prichard
794b07e526 In the unix-adapter, convert a POSIX executable path to a Win32 path. 2012-04-01 19:15:35 -07:00
Ryan Prichard
a7bc8fcf9d Rename Shared to shared and Misc to misc. 2012-04-01 02:13:21 -07:00
Ryan Prichard
17eaaadcec Use 4-space indentation in Misc/UnixEcho.cc. 2012-04-01 02:03:12 -07:00
Ryan Prichard
8eb2da5850 Fix a typo. 2012-04-01 02:00:37 -07:00
Ryan Prichard
9f26d1fc1e Remove a TODO comment for a completed task. 2012-04-01 01:42:50 -07:00
Ryan Prichard
f35e5bde74 Use 4-space indentation consistently. 2012-04-01 01:40:30 -07:00
Ryan Prichard
023d6c71f9 Realign indentation in a couple places. 2012-04-01 01:40:15 -07:00
Ryan Prichard
24196c84ea Fix an inconsistency in the README and reword a couple of sentences. 2012-04-01 01:22:04 -07:00
Ryan Prichard
3f09acdf06 Reword the readme's introduction. 2012-04-01 01:01:18 -07:00
Ryan Prichard
80d005e33e Start the agent's child process on the libwinpty client's desktop.
If I run a GUI program inside mintty using winpty, the GUI's window should
appear on the same desktop as mintty, not on the hidden desktop containing
the winpty console.

Even though STARTUPINFO.lpDesktop's type is LPTSTR (instead of LPCTSTR),
the documentation doesn't say anything about CreateProcess modifying the
lpDesktop string, so I didn't bother making a copy of desktop.c_str().
2012-03-31 00:55:49 -07:00
Ryan Prichard
68e32a2bde Use GetEnvironmentVariable instead of getenv in DebugClient.cc.
This lets libwinpty.dll read the WINPTYDBG environment variable that the
unix adapter sets using SetEnvironmentVariable.  If DebugClient.cc calls
getenv, then it seems to read a copy of the Win32 environment that the
MSVCRT initializes at startup.
2012-03-31 00:49:09 -07:00
Ryan Prichard
0d673836f2 In the DebugServer script, use sys.stdout.flush instead of "python -u".
The latter doesn't work when:
 * I'm using mintty.
 * I invoke python.exe directly, passing it the path to the script.

This came up on Windows XP testing where I installed CPython, but
python.exe wasn't in my PATH, so I couldn't run the script directly.
2012-03-30 23:49:46 -07:00
Ryan Prichard
b44bd6b655 Remove a piece of old Qt code from this Makefile. 2012-03-28 03:12:22 -07:00
Ryan Prichard
5542b37de0 Update the .gitignore file. 2012-03-28 03:12:21 -07:00
Ryan Prichard
7eae3d9e33 Send "\r" instead of "\x1b[1G" because carriage return is simpler.
There's no other motivating reason for this change.  AFAIK, both of them
work equally well and do the same thing.
2012-03-28 03:12:13 -07:00
Ryan Prichard
6a29852ace Stop sending trailing whitespace in Terminal::sendLine.
* The intent of having the length variable was to avoid sending trailing
   whitespace for each line, but the previous code never read the variable.
   Instead, every line it sent was the width of the terminal window.

 * There was a bug where running console.exe inside a TERM=cygwin terminal
   resulted in excessive line feeds.  This change mitigates that bug, but
   doesn't fix it.  The problem is that the agent assumes that after it
   writes to the last column of a line, the cursor is still on the same
   line, but this isn't true for the TERM=cygwin terminal.
2012-03-28 03:10:37 -07:00
Ryan Prichard
0427aedadd Remove unused console font code from Win32Console::setSmallFont. 2012-03-28 01:09:52 -07:00
Ryan Prichard
dbc2d51fec Select a small console font on agent startup.
This maximizes the possible console size in terms of rows * cols.
2012-03-28 01:05:26 -07:00
Ryan Prichard
6585b72375 Use STD_{INPUT,OUTPUT}_HANDLE instead of reopening CONIN$ and CONOUT$.
Reopening the files is unnecessary.
2012-03-28 01:05:14 -07:00
Ryan Prichard
67ee37396d Add a readme. 2012-03-25 19:30:47 -07:00
Ryan Prichard
46701caf39 Mark configure as executable and exit if uname -s isn't recognized. 2012-03-25 19:24:39 -07:00
Ryan Prichard
82cfc70d98 Create a configure script.
* Move the Cygwin/MSYS detection logic from config-*.mk into this new
   script.

 * Recognize either the 32-bit MinGW or the 32-bit MinGW-w64 compiler
   driver for Cygwin.
2012-03-25 15:55:03 -07:00
Ryan Prichard
71aa4a59bb Rename pconsole to winpty.
* This avoids a name conflict with an existing unrelated project.

 * I think winpty is a better name anyway.  (i) It's more obviously
   Windows-related.  (ii) I think it more accurately describes what it
   does.  A "pseudo-console" ought to mirror the console API and allow
   replacing the implementation built-in to Windows.  This project is only
   trying to provide functionality similar to using the master interface of
   a Unix pty, but for native console programs.
2012-03-25 02:29:37 -07:00
Ryan Prichard
f1842c63a1 Remove old Qt files. 2012-03-24 18:02:28 -07:00
Ryan Prichard
43fac6819b Remove the obsolete TestNet client/server code.
It won't work anymore because the agent's interface has changed.
2012-03-24 17:55:39 -07:00
Ryan Prichard
e1c4763cc4 Get the UNIX adapter working with MSYS.
* Work around UNICODE deficiencies:
    - MSYS does not have wstring.
    - mbstowcs(NULL, text, 0) returns 0 on MSYS instead of returning the
      length of the converted string.
    - printf("%ls") does not work on MSYS.
2012-03-24 17:53:43 -07:00
Ryan Prichard
35754bab98 In the UNIX adapter, remove the UNIX->Win32 environment conversion.
It doesn't work because it leaves in the Cygwin-style paths in variables
like PATH and TMP.

(Also, it doesn't build with MSYS because MSYS's old G++ toolchain lacks
std::wstring.)
2012-03-24 17:23:18 -07:00
Ryan Prichard
9ed1b5b286 Print usage in the UNIX adapter. 2012-03-24 17:20:08 -07:00
Ryan Prichard
5010f5e1a6 Print an error message when CreateProcess fails.
I suspect that the library API (pconsole_open) should not be calling exit
if it can't start the agent process, but I don't want to deal with that
right now.
2012-03-24 17:19:55 -07:00
Ryan Prichard
22f96abc03 Add comments to the pconsole.h header file. 2012-03-24 17:17:23 -07:00
Ryan Prichard
5c185c1617 In the UNIX adapter, start the child process specified on the command line.
* Also propagate the UNIX environment to Win32.  This code doesn't really
   work because variables like PATH need path-translation, but I'd like to
   save a record of it before killing it off.
2012-03-24 16:48:41 -07:00
Ryan Prichard
32627354df Work on the agent debugging code.
* Suppress debug output unless the PCONSOLEDBG enviroment variable is
   set.

 * Rename Trace to trace to be consistent with the camelCaps naming
   convention.
2012-03-24 16:43:50 -07:00
Ryan Prichard
f75800fae6 Replace assert with ASSERT. 2012-03-24 16:41:15 -07:00
Ryan Prichard
724650ac71 Add more copyright notices. 2012-03-24 16:40:18 -07:00
Ryan Prichard
0662815a3e Replace build/.placeholder with build/.gitkeep.
Apparently the convention is to name the empty directory placerholder file
.gitkeep.
2012-03-23 03:48:40 -07:00
Ryan Prichard
44554d5e9d Add an MIT copyright notice to all the source files. 2012-03-23 03:11:34 -07:00