I want to make some debug console for my application. It should output some data and take input commands. How can I do this? The best way is updating console like: drawing information and prompt for input after the data. I'm developing under Linux. For example, gdb could take input from console.
-
You want to add a kind of command prompt console to your non-console application, is that correct?John Dibling– John Dibling2010-11-19 15:24:23 +00:00Commented Nov 19, 2010 at 15:24
-
And adding on John's comment above, how is you UI arranged? what does the application do in general? And is it acceptable(maybe preferable?) that the console will be remote?Eldad Mor– Eldad Mor2010-11-19 15:28:33 +00:00Commented Nov 19, 2010 at 15:28
-
The application is a 2d game. I want to make some debug stuff from own console. It should take input data and send it into the app window and take back result data and show it.Max Frai– Max Frai2010-11-19 15:30:25 +00:00Commented Nov 19, 2010 at 15:30
1 Answer
If you're familiar with socket programming (or actually, any other kind of IPC mechanism), you might want to enable some listener within your application, and develop an external application that will do all the "console" stuff for you, while communicating with the main application.
Let's suppose you have an application that has a single button and a single text label, and every time you press that button - the text label goes up by 1, from 1 to 2 to 3 etc.
You can build a socket listener into that application. When the socket listener accepts a new incoming connection, you'd start a connection thread that can:
- Receive a "shutdown" command
- Receive a "reset counter" command
- Send an update regarding the current count on every click
- etc.
Then you build another, external application, which connects to the main application, and sends messages to it, based on console input it gets from the user. It would also listen to incoming updates and show them to the user.
Using an external application for debug-controlling your main application is extremely helpful, with the following reasons being some of the advantages:
- No matter how the debug application is buggy, it cannot hurt the release version of your main application.
- All the code that deals with the console management, which is redundant to your main application, can be kept outside of the main app.
- Making two projects out of it can make it easier to collaborate your work with someone else, as long as you are both aware of the protocol between the two sides.
- Implementing what I suggested means you can debug your application remotely, in case you don't have access to the main application (for example, if it's on a customer site).