I built my trunk and 7.10 gdb configured as: $ configure --disable-nls --disable-sim --disable-gas --disable-binutils --disable-ld --disable-gprof --with-libexpat --with-lzma=no --with-python=yes --prefix=/tmp/val/build-gdb/native/7.10/install/ --with-gdb-datadir=/tmp/val/build-gdb/native/7.10/install/share/gdb on x86_64 Ubuntu 14.04 I'm trying to debug a program with gdbserver and gdb. For trunk gdb, In one terminal on host: $ gdbserver localhost:3334 ./a.out Process ./a.out created; pid = 17642 Listening on port 3334 Another terminal: $ ../build-gdb/native/trunk/install/bin/gdb -x gdb_simple.py ./a.out GNU gdb (GDB) 8.0.50.20170630-git Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./a.out...done. (gdb) Reading /lib64/ld-linux-x86-64.so.2 from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading /lib64/ld-linux-x86-64.so.2 from remote target... Reading /lib64/ld-2.19.so from remote target... warning: the debug information found in "target:/lib64/ld-2.19.so" does not match "target:/lib64/ld-linux-x86-64.so.2" (CRC mismatch). Reading /lib64/.debug/ld-2.19.so from remote target... 0x00007ffff7ddb2d0 in ?? () from target:/lib64/ld-linux-x86-64.so.2 Step returned: '' 0x00007ffff7ddb2d3 in ?? () from target:/lib64/ld-linux-x86-64.so.2 <It stops here hanging> For gdb 7.10: $ gdbserver localhost:3334 ./a.out Process ./a.out created; pid = 17642 Listening on port 3334 $ ../build-gdb/native/7.10/install/bin/gdb -x gdb_simple.py ./a.out GNU gdb (GDB) 7.10.1.20160210-cvs Copyright (C) 2015 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./a.out...done. (gdb) Reading /lib64/ld-linux-x86-64.so.2 from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading /lib64/ld-linux-x86-64.so.2 from remote target... Reading /lib64/ld-2.19.so from remote target... warning: the debug information found in "target:/lib64/ld-2.19.so" does not match "target:/lib64/ld-linux-x86-64.so.2" (CRC mismatch). Reading /lib64/.debug/ld-2.19.so from remote target... 0x00007ffff7ddb2d0 in ?? () from target:/lib64/ld-linux-x86-64.so.2 Step returned: '0x00007ffff7ddb2d3 in ?? () from target:/lib64/ld-linux-x86-64.so.2 ' Step returned: '0x00007ffff7ddea40 in ?? () from target:/lib64/ld-linux-x86-64.so.2 ' Step returned: '0x00007ffff7ddea41 in ?? () from target:/lib64/ld-linux-x86-64.so.2 ' Step returned: '0x00007ffff7ddea44 in ?? () from target:/lib64/ld-linux-x86-64.so.2 ' Step returned: '0x00007ffff7ddea46 in ?? () from target:/lib64/ld-linux-x86-64.so.2 ' Stepping successful Where gdb_simple.py is https://bugs.launchpad.net/gcc-arm-embedded/+bug/1700595/+attachment/4903671/+files/gdb_script_simple.py and a.out is a hello world compiled using 'gcc -g hello.c'
Currently, current_ui->prompt_state will keep PROMPTED value under python interface. Synchronous commands will behave like asynchronous commands and GDB will raise an exception while checking thread state before executing synchronouse commands in ensure_not_running(). Initialize current_ui->prompt_state to PROMPT_NEEDED in execute_gdb_command() to ensure synchronous commands will complete before next command under python interface.
I have prepared a patch for this bug. However, I am not sure is it reasonable to change prompt_state in execute_gdb_command() or not. Any comments? --- gdb/python/python.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/python/python.c b/gdb/python/python.c index c53e10f..49b5eff 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -589,6 +589,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) struct interp *interp; scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); + current_ui->prompt_state = PROMPT_NEEDED; scoped_restore save_uiout = make_scoped_restore (¤t_uiout); --
(In reply to Hsiangkai Wang from comment #2) > I have prepared a patch for this bug. However, I am not sure is it > reasonable to change prompt_state in execute_gdb_command() or not. Any > comments? gdb-patches@sourceware.org is the right place to discuss patches, so post your patch there. You can ask something you are not sure about there.
(In reply to Yao Qi from comment #3) > (In reply to Hsiangkai Wang from comment #2) > > I have prepared a patch for this bug. However, I am not sure is it > > reasonable to change prompt_state in execute_gdb_command() or not. Any > > comments? > > gdb-patches@sourceware.org is the right place to discuss patches, so post > your patch there. You can ask something you are not sure about there. Thanks for your reminding. I have sent a patch to gdb-patches@sourceware.org for review. https://patchwork.sourceware.org/patch/22595/
Did this patch ever go in? If not could you send a "ping" follow-up to the list?