Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 【已解决】QProcess 调用 GDB 无法弹出重定向输入窗口

【已解决】QProcess 调用 GDB 无法弹出重定向输入窗口

Scheduled Pinned Locked Moved Chinese
3 Posts 2 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saki
    wrote on last edited by
    #1

    我们现在在用Qt写一个很简单的单文件IDE(只对单文件编译运行,只运行命令行程序)。在写调试功能的时候遇到了点麻烦:我们用QProcess去调用GDB(使用Machine Interface)并且通过readyReadStandardOutput接收消息。我们希望和多数IDE一样:能弹出程序terminal进行输入输出。但是现在弹不出来这个窗口。
    例如:我们写了个很简单的a.c:

    #include <stdio.h>
    int main()
    {
    printf("Hello World!\n");
    return 0;
    }

    然后编译成a.exe,之后我们用QProcess启动GDB去调试a.exe。正常情况下IDE此时能弹出一个terminal窗口来显示Hello World,但是我们现在显示不出来。

    我们在代码里是这么写的:

       QStringList _arg;
        _arg<<filePath<<"--interpreter"<<"mi";
                SIGNAL(readyReadStandardOutput()),
                this,
                SLOT(readGdbStandardOutput()));
        connect(gdbProcess.data(),
                SIGNAL(readyReadStandardError()),
                this,
                SLOT(readGdbStandardError()));
        gdbProcess->start(gdbPath,_arg);
    

    后来我看了下Qt Creator的代码,我理解里面用了tty进行重定向,并且使用了自己写的QMLJS终端。但是QMLJS的移植成本太高了。而且我们还找到一个IDE:Manna,它的另一个版本也叫做GUIDE(Gait Universal IDE)。使用Qt 4写的。里面没有任何额外的重定向却也能弹出命令行终端窗口。这个项目的GDB部分代码在这里可以找到:
    https://www.assembla.com/code/manna/subversion/nodes/3/trunk/Manna/src/gdbdebug.cpp
    请教一下社区的各位:如何才能弹出terminal窗口?是GDB的调用参数有问题么?那Manna的实现是怎么做到的?这个问题困扰我好久了。希望大家能帮帮我解决这个问题。谢谢!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Saki
      wrote on last edited by
      #2

      问题解决了,Windows下使用set new-console on即可。Linux下使用tty。

      1 Reply Last reply
      0
      • A Offline
        A Offline
        along_has
        wrote on last edited by
        #3

        老哥你好,你做的小型ide怎么样了,能够发我一份学习一下吗

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved