Author Topic: diff between run terminal and debug terminal???  (Read 6895 times)

Offline iamk2

  • Multiple posting newcomer
  • *
  • Posts: 12
diff between run terminal and debug terminal???
« on: October 13, 2013, 04:30:11 am »
Learing on my own =>  C++.

Using codeblocks as my IDE. Arch linux

I use the following function to clear my terminal throughout my program.

Code
void        Clear_Screen(bool RESET)
{
  if (!cur_term)
        {
            int result = 0;
            setupterm(NULL,STDOUT_FILENO,&result);
            if (result <=0)
                return;
        }
        putp(tigetstr( "clear"));
        if (RESET == true)
            putp(tigetstr( "rs1"));
}

no errors building.

whenever I run the program it works flawless!

When I use debug the "clear" does not perform as I would like but instead the output just scrolls.
This is because the "int result;" is returning a -1 when observed through the debugger - hence no clear.

I found that -1 is the return value for "An error occurred while locating the terminfo database."??

I used devilspie to find that the XTerm window opened when the program is ran - is called "CB_Console_Runner" and when in Debug it is called "sleep".

What is behind the no clear in debug??

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: diff between run terminal and debug terminal???
« Reply #1 on: October 13, 2013, 11:12:04 am »
When you use "Run" cb starts the terminal through cb_console_runner.
When you debug your program cb starts the terminal directly and executes a long sleep command in it. Then when the debugger (gdb) is started, we tell it to use the tty provided by this instance of xterm.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline iamk2

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: diff between run terminal and debug terminal???
« Reply #2 on: October 15, 2013, 03:06:10 am »
1. When my application is ran directly through XTerm with no use of CB it uses the Standard Pseudo TTY definitions set by XTerm  - or the Pseudo TTY definitions provided by whatever virtual term I use at the time - therefore setupterm() finds the terminfo database properly and 1 is returned and the rest of the functions commands operate properly because they have all the info they require??

2. When I execute it through CB with RUN and it uses cb_console_runner  does it not use the XTerm definitions also?? Therefore it would behave exactly the same as from within CB??

3. When I use debug (GDB) through CB it still goes to terminal but is held back from starting until after the debugger starts - got it - but I am reading it as it still uses the tty definitions from XTerm??? I was thinking gdb or CB was providing the tty defs therefore setuptrerm could not find what it needed???

I am missing something?  - could I get a bit more  explanation of why it is not finding the terminfo database. and the remaining commands are not working.

So confused


Offline iamk2

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: diff between run terminal and debug terminal???
« Reply #3 on: October 15, 2013, 08:24:39 pm »
Edit to #2 above - outside CB not within.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: diff between run terminal and debug terminal???
« Reply #4 on: October 15, 2013, 08:52:21 pm »
I am missing something?  - could I get a bit more  explanation of why it is not finding the terminfo database. and the remaining commands are not working.
C::B uses tty gdb command to redirect the output of your program to the terminal during debugging.
See here for details: https://sourceware.org/gdb/onlinedocs/gdb/Input_002fOutput.html
I don't know if this is the same as running your program in terminal, so you'll have to ask GDB or TermInfo people.

If you find something interesting, you can post it here. If it is something we need to do we can try to do it in C::B, if we're not doing it already.

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]