You are not logged in.

#1 2011-01-30 11:36:58

delcypher
Member
Registered: 2010-04-17
Posts: 42

Problem using gdb in TUI mode with arrow keys

Hi I'm wondering if anyone can help with this very annoying problem I'm having with GDB. I am using "GNU gdb (GDB) 7.2"

Basically I've done the following:

1.

g++ -g test.cpp #small test program ( source code shown at end of post)

2. Then I run

gdb a.out

3. I then put gdb in TUI mode by pressing (CTRL+X a).

4. I then run the following gdb commands

(gdb) list main
(gdb) break 17

5. At this point in time I can use the up and down arrow keys to scroll through the source code.

6. Now I run the program and gdb pauses execution at line 17.

(gdb) run
Starting program: /home/dan/test/a.out 
Breakpoint 1, main (n=1, argv=0x7fffffffe5e8) at test.cpp:17

7. Now if I try to scroll through the source code using the arrow keys I CAN'T! TUI mode just became a LOT less useful.
Pressing up just makes ^[OA appear on the command line
Pressing down just make ^[OB appear on the command line
Pressing CTRL+L (refresh) just makes ^L appear on the command line
Press (CTRL+x a) to try and get out of tui mode just makes ^Xa appear on the command line.

Notably as well the source code window is all the line numbers are wrong as well.

8. If I make program execution complete by running

(gdb) continue
continue
Continuing.

Program exited normally.

Using the arrow keys is still broken!

I've noticed that if I start gdb in this way though that this problem does not happen.

gdb -tui a.out 

This is my solution for now, but this problem shouldn't happen!

This problem happens in all terminals I've tried virtual terminals (tty1,tty2, etc...) and in KDE's Konsole.

Does anyone know what's going on?

source code for test.cpp

#include <cstdio>
#include <cstdlib>

typedef struct
{
        int n;
        char* arg;

} Arg;

int hello(int i);

int main(int n, char** argv)
{
        Arg* ap;
        int test;
        if(n>1)
        {
                ap = (Arg*) malloc(n*sizeof(Arg));


                for(int counter=0; counter < n; counter++)
                {
                        ap[counter].n=counter;
                        ap[counter].arg=argv[counter];
                        test = hello(counter);
                }

        }
        return 0;
}

int hello(int i)
{
        printf("Hello I'm number %d\n",i);
        return i+1;

}

Last edited by delcypher (2011-01-30 11:37:52)

Offline

Board footer

Powered by FluxBB