Bug 21698 - Stepping from python interface broken?
Summary: Stepping from python interface broken?
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 8.0.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-01 10:22 UTC by Tejas Belagod
Modified: 2018-04-21 21:54 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux
Target:
Build: x86_64-linux
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tejas Belagod 2017-07-01 10:22:49 UTC
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'
Comment 1 Hsiangkai Wang 2017-09-03 00:14:22 UTC
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.
Comment 2 Hsiangkai Wang 2017-09-03 00:34:21 UTC
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 (&current_ui->async, 0);
+      current_ui->prompt_state = PROMPT_NEEDED;

       scoped_restore save_uiout = make_scoped_restore (&current_uiout);
--
Comment 3 Yao Qi 2017-09-05 11:45:41 UTC
(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.
Comment 4 Hsiangkai Wang 2017-09-05 13:20:21 UTC
(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/
Comment 5 Tom Tromey 2018-04-21 21:54:42 UTC
Did this patch ever go in?
If not could you send a "ping" follow-up to the list?