In asynchronous mode, commands executed from Python don't behave correctly: (gdb) set target-async on (gdb) py gdb.execute("attach PID") ; gdb.execute("where") #0 0x0000003cbd0aa47e in ?? () #1 0x0000000000000000 in ?? () 0x0000003cbd0aa47e in waitpid () from /lib64/libc.so.6 where as the behavior should be the same as synchronous mode: (gdb) set target-async off (gdb) py gdb.execute("attach PID") ; gdb.execute("where") 0x0000003cbd0aa47e in waitpid () from /lib64/libc.so.6 #0 0x0000003cbd0aa47e in waitpid () from /lib64/libc.so.6 #1 0x000000000043ede2 in ?? () #2 0x000000000044005f in wait_for () #3 0x0000000000430c45 in execute_command_internal () #4 0x0000000000430e0e in execute_command () #5 0x000000000041d526 in reader_loop () #6 0x000000000041ccde in main ()
It's not a Python issue. The issue is "attach" is not finishing in asynchronous mode before "where" is executed. If you do the below with asynchronous mode "off" (the default) it works. First the non-Python failing case. [user@localhost gdb]$ sleep & [2] 12216 [user@localhost gdb]$ gdb GNU gdb (GDB) Fedora (7.2.90.20110525-39.fc15) Copyright (C) 2011 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-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Setting up the environment for debugging gdb. (gdb) set target-async on (gdb) define at >attach 11790 >where >end (gdb) at #0 0x378ab660 in ?? () Backtrace stopped: Not enough registers or memory available to unwind further During symbol reading, corrupt probe when reading `/usr/lib/debug/lib64/libc-2.14.so.debug'. 0x00000030378ab660 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82 82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) Current language: auto The current source language is "auto; currently asm". With target-async off: [pmuldoon@localhost gdb]$ gdb GNU gdb (GDB) Fedora (7.2.90.20110525-39.fc15) Copyright (C) 2011 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-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Setting up the environment for debugging gdb. (gdb) define at >attach 11790 >where >end (gdb) at During symbol reading, corrupt probe when reading `/usr/lib/debug/lib64/libc-2.14.so.debug'. 0x00000030378ab660 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82 82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) #0 0x00000030378ab660 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82 During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x30378ab66d. #1 0x0000000000403c58 in rpl_nanosleep (requested_delay=0x7fff48c54b60, remaining_delay=0x0) at nanosleep.c:93 #2 0x00000000004032c5 in xnanosleep (seconds=<optimized out>) at xnanosleep.c:111 During symbol reading, cannot get low and high bounds for subprogram DIE at 859. #3 0x0000000000401416 in main (argc=<optimized out>, argv=<optimized out>) at sleep.c:147
Looks this bug has been fixed by this patch Flip the interpreter to synchronously wait for commands finishing, in command lists and similars http://sourceware.org/ml/gdb-patches/2011-09/msg00037.html Can we close this one?
I tried it and it worked for me. Yao - it is fine to use your best judgment and modify bugzilla. Close things if you reasonably believe them to be fixed. There isn't too much process here, and really bugzilla would benefit from more random love. I usually just give the bug a try first...