CLion run program in separate system terminal

匆匆过客 提交于 2019-12-10 01:36:39

问题


I have an ncurses program that I'd like to interactively debug using CLion. The problem is that when I run the program in CLion to debug it, the inbuilt console where the program is run doesn't display the output of the ncurses program properly.

I'd like to have the program run in my systems terminal so I can see the output properly whilst debugging the program with CLions debugger.

Is there any way to do this?


回答1:


The best way to accomplish this is to use GDB now it can be really frustrating to get started so Ill show you how I accomplished it in linux

  1. open a terminal and go to your project debug file and type gdbserver localhost:1234 ./myFile
  2. open clion to myFile project and in the upper right corner you should see a build all (or your projects name) click it and go to "edit configurations"
  3. in the upper left corner you should see a plus sign, click it and press "GDB remote debug"
  4. then in "target remote" type tcp:127.0.0.1:1234
  5. Next in "path mappings" press the plus and type /location/to/file/myFile (same file as in 1.) in both Remote and Location
  6. Press OK and in the upper right corner select the name of the configuration that you just made and press debug

you might need to try to restart the gdbserver one more time for this to work but if you did all the steps above you should see a debug prompt come up and on the terminal you should see your project running.

There are some limitations with this for example you always have to run gdbserver localhost:1234 ./myFile command on your terminal for it to work.

Some Video/documentation that helped me:

  • Debugging with GDB at 33:35 (Video by JetBrain)
  • GDB documentation on Jetbrain

I hope this helped :)




回答2:


In other debuggers, you would do this by running the ncurses application in a terminal, and attaching the debugger to the process using ncurses.

Doing that avoids interference between ncurses (which changes the terminal I/O modes) and the debugger's command-line.

The attach feature is a recently released feature of the CLions debugger:

Further reading:

  • More power to debug: Attach to local process (January 20, 2016)
  • CLion 1.2 roadmap (August 31, 2015)
  • Debugging in CLion (May 8, 2015 )
  • CLion answers frequently asked questions (September 16, 2014)
  • Debugging ncurses application with gdb
  • Using GNU's GDB Debugger: Debugging Ncurses Programs


来源:https://stackoverflow.com/questions/36281187/clion-run-program-in-separate-system-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!