0

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.

3
  • You want to add a kind of command prompt console to your non-console application, is that correct? Commented 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? Commented 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. Commented Nov 19, 2010 at 15:30

1 Answer 1

5

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:

  1. Receive a "shutdown" command
  2. Receive a "reset counter" command
  3. Send an update regarding the current count on every click
  4. 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:

  1. No matter how the debug application is buggy, it cannot hurt the release version of your main application.
  2. All the code that deals with the console management, which is redundant to your main application, can be kept outside of the main app.
  3. 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.
  4. 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).
Sign up to request clarification or add additional context in comments.

2 Comments

+1 difficult to implement, but scales well and provides a nice seperation of responsibility
I'm a server-side person :-) But yes, one downside to my solution is implementation complexity in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.