Bug 17694 - Terminal isn't properly restored after the change to rl_callback functions
Summary: Terminal isn't properly restored after the change to rl_callback functions
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-10 12:23 UTC by Terry Guo
Modified: 2014-12-10 12:24 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Terry Guo 2014-12-10 12:23:33 UTC
Hi there,

I am working on Ubuntu 12.04 64bit and using gdb trunk for arm-none-eabi target. 

Before this change:

commit cbd6f6bf80881be4628622e369baafb337589578
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Oct 23 17:13:35 2014 +0100

    PR python/17372 - Python hangs when displaying help()
    
    This is more of a readline/terminal issue than a Python one.

My command "arm-none-eabi-gdb -x gdb.cmd coremark.axf" works fine and I can get back to a normal terminal. Now with above change, after the execution of same command, the terminal is abnormal, I can't see what I typed, but I can see the results of typed command. Looks to me the echo feature of terminal isn't properly restored. I have to use shell 'reset' command to reset the terminal.

However everything works fine if I source my script gdb.cmd in gdb terminal manually. 

This is an embedded project running on a small SOC board. I am sorry that I can't provide a test case. But I compared how those gdb_rl_callback_handler_* functions are called in above two different calling methods. Hope this can help you to understand the issue. Please let me know if further information is needed.

First thing: before above change, the readline rl_callback_handler* functions are never called in my case. I just insert printf function into those functions and never see the output. So I assume they are not called.

Now with above change, I insert three printf functions into new gdb_rl_callback_handler_* functions. With command "arm-none-eabi-gdb -x gdb.cmd coremark.axf", I got:

arm-none-eabi-gdb -x g.cmd  coremark.axf
GNU gdb (GDB) 7.8.1.20141210-cvs
<<snip it for the sake of simplicity>>
Semihosting disabled.
Breakpoint 1 at 0xa8
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, 0x000000a8 in _start ()
------I am in gdb_rl_callback_handler_reinstall function and the condition is true
------I am in gdb_rl_callback_handler_install function
Semihosting enabled.
Breakpoint 2 at 0x6258
<<snip it for the sake of simplicity>>
Correct operation validated. See readme.txt for run and reporting rules.

Breakpoint 2, 0x00006258 in _exit ()

Program received signal SIGQUIT, Quit.
0x0000626c in _kill ()

Now the command is finished and I am in terminal, but I can't see what I typed.

But if I manually source the gdb.cmd in gdb terminal, I got:

arm-none-eabi-gdb   coremark.axf
GNU gdb (GDB) 7.8.1.20141210-cvs
<<<snip it>>>
Reading symbols from coremark.axf...(no debugging symbols found)...done.
------I am in gdb_rl_callback_handler_remove function
------I am in gdb_rl_callback_handler_install function
(gdb) source g.cmd 
0x0000626c in _kill ()
Semihosting disabled.
Breakpoint 1 at 0xa8
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, 0x000000a8 in _start ()
Semihosting enabled.
Breakpoint 2 at 0x6258
<<snip it>>
Breakpoint 2, 0x00006258 in _exit ()

Program received signal SIGQUIT, Quit.
0x0000626c in _kill ()

Now the command is finished and I am in terminal. Everything is fine.