cygwin 里的 gdb 没法输入重定向 (待解决)

问题

cygwin 里的 gdb 没法输入重定向
运行程序的时候用 ./my.exe <cin.txt 就好,但是 gdb 不行。
按照正常 gdb 流程:

  1. g++ ...
  2. gdb ./my.exe
  3. run < cin.txt

但是这个办法仅限 Unix ,在 cygwin的邮件列表 里找到了原因:

It's a bug in all Win32 ports of gdb.

This has to do with how GDB starts a "inferior" subprocess that it
wants to debug; on Unix, it uses the shell to do the redirection, but
on win32, gdb uses CreateProcess. Currently, the cmd arg parser in
win32/gdb doesn't look for redirection symbols, and so it doesn't do
what you'd expect. Also, someone has to write the small piece of code
that does the redirection by passing the descriptor to CreateProcess
etc.

See target.c (child_create_inferior) for how it's done on Unix boxes and
win32-nat.c (child_create_inferior) for how it's done on win32.

It can be fixed without too much trouble, but someone needs to do it.

然后……我看到日期居然是 Date: Wed, 21 Apr 1999 13:20:03 -0500 (CDT)

淦!1999年!在 StackOverflow 上找了几个问题,也是差不多 10 年前的问题了,给出的方案也都是上面那个适用 Unix 的。

解决方案

没找到,无解。只好先用 VisualStudio 了。

查了下 win32-nat.c (child_create_inferior) 结果啥也查不到……

有哪位靓仔知道该咋办的话,请务必告知,感谢!

posted @ 2020-12-24 22:16  AdjWang  阅读(141)  评论(0编辑  收藏  举报