Hello community, here is the log from the commit of package gdb for openSUSE:Factory checked in at 2014-10-16 14:53:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gdb (Old) and /work/SRC/openSUSE:Factory/.gdb.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gdb" Changes: -------- --- /work/SRC/openSUSE:Factory/gdb/gdb.changes 2014-08-20 17:51:47.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.gdb.new/gdb.changes 2014-10-16 14:53:49.000000000 +0200 @@ -1,0 +2,8 @@ +Fri Oct 10 10:01:27 UTC 2014 - hrvoje.sen...@gmail.com + +- Added gdb-async-stopped-on-pid-arg-1of2.patch, + gdb-async-stopped-on-pid-arg-2of2.patch and + gdb-async-stopped-on-pid-arg-testsuite.patch to resolve + https://sourceware.org/bugzilla/show_bug.cgi?id=17347 + +------------------------------------------------------------------- New: ---- gdb-async-stopped-on-pid-arg-1of2.patch gdb-async-stopped-on-pid-arg-2of2.patch gdb-async-stopped-on-pid-arg-testsuite.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gdb.spec ++++++ --- /var/tmp/diff_new_pack.9a21Tz/_old 2014-10-16 14:53:51.000000000 +0200 +++ /var/tmp/diff_new_pack.9a21Tz/_new 2014-10-16 14:53:51.000000000 +0200 @@ -210,6 +210,9 @@ # Upstream patch to fix gcc -Werror Patch1002: gdb-6.6-buildid-locate-rpm-suse.patch +Patch1003: gdb-async-stopped-on-pid-arg-1of2.patch +Patch1004: gdb-async-stopped-on-pid-arg-2of2.patch +Patch1005: gdb-async-stopped-on-pid-arg-testsuite.patch BuildRequires: bison BuildRequires: flex @@ -468,6 +471,9 @@ #Fedora patching end %patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch1005 -p1 find -name "*.orig" | xargs rm -f ! find -name "*.rej" # Should not happen. ++++++ gdb-async-stopped-on-pid-arg-1of2.patch ++++++ http://sourceware.org/ml/gdb-patches/2014-09/msg00102.html Subject: Re: Regression: GDB stopped on run with attached process (PR 17347) [Re: [pushed+7.8] Re: [PATCH] Fix "attach" command vs user input race On 09/03/2014 08:58 AM, Jan Kratochvil wrote: > https://sourceware.org/bugzilla/show_bug.cgi?id=17347 Thanks Jan. Here's a fix, test included. Comments? Thanks, Pedro Alves -------------------------- [PATCH] gdb/17347 - Regression: GDB stopped on run with attached process Doing: gdb --pid=PID -ex run Results in GDB getting a SIGTTIN, and thus ending stopped. That's usually indicative of a missing target_terminal_ours call. E.g., from the PR: $ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run [1] 28263 [1] Killed sleep 1h [2]+ Stopped gdb -batch sleep $p -ex run The workaround is doing: gdb -ex "attach $PID" -ex "run" instead of gdb [-p] $PID -ex "run" With the former, gdb waits for the attach command to complete before moving on to the "run" command, because the interpreter is in sync mode at this point, within execute_command. But for the latter, attach_command is called directly from captured_main, and thus misses that waiting. IOW, "run" is running before the attach continuation has run, before the program stops and attach completes. The broken terminal settings are just one symptom of that. Any command that queries or requires input results in the same. The fix is to wait in catch_command_errors (which is specific to main.c nowadays), just like we wait in execute_command. gdb/ChangeLog: 2014-09-03 Pedro Alves <pal...@redhat.com> PR gdb/17347 * main.c: Include "infrun.h". (catch_command_errors, catch_command_errors_const): Wait for the foreground command to complete. * top.c (maybe_wait_sync_command_done): New function, factored out from ... (maybe_wait_sync_command_done): ... here. * top.h (maybe_wait_sync_command_done): New declaration. gdb/testsuite/ChangeLog: 2014-09-03 Pedro Alves <pal...@redhat.com> PR gdb/17347 * gdb.base/attach.exp (spawn_test_prog): New, factored out from ... (do_attach_tests, do_call_attach_tests, do_command_attach_tests): ... here. (gdb_spawn_with_cmdline_opts): New procedure. (test_command_line_attach_run): New procedure. (top level): Call it. --- gdb/main.c | 9 +++ gdb/testsuite/gdb.base/attach.exp | 118 ++++++++++++++++++++++++++------------ gdb/top.c | 26 +++++---- gdb/top.h | 8 +++ 4 files changed, 114 insertions(+), 47 deletions(-) Index: gdb-7.8/gdb/main.c =================================================================== --- gdb-7.8.orig/gdb/main.c 2014-09-07 19:12:45.066981588 +0200 +++ gdb-7.8/gdb/main.c 2014-09-07 19:14:22.613095201 +0200 @@ -47,6 +47,7 @@ #include "filenames.h" #include "filestuff.h" #include "event-top.h" +#include "infrun.h" /* The selected interpreter. This will be used as a set command variable, so it should always be malloc'ed - since @@ -350,7 +351,11 @@ catch_command_errors (catch_command_erro TRY_CATCH (e, mask) { + int was_sync = sync_execution; + command (arg, from_tty); + + maybe_wait_sync_command_done (was_sync); } return handle_command_errors (e); } @@ -369,7 +374,11 @@ catch_command_errors_const (catch_comman TRY_CATCH (e, mask) { + int was_sync = sync_execution; + command (arg, from_tty); + + maybe_wait_sync_command_done (was_sync); } return handle_command_errors (e); } Index: gdb-7.8/gdb/testsuite/gdb.base/attach.exp =================================================================== --- gdb-7.8.orig/gdb/testsuite/gdb.base/attach.exp 2014-09-07 19:12:45.067981589 +0200 +++ gdb-7.8/gdb/testsuite/gdb.base/attach.exp 2014-09-07 19:12:48.601985706 +0200 @@ -58,6 +58,37 @@ if [get_compiler_info] { return -1 } +# Start the program running and then wait for a bit, to be sure that +# it can be attached to. Return the process's PID. + +proc spawn_test_prog { executable } { + set testpid [eval exec $executable &] + exec sleep 2 + if { [istarget "*-*-cygwin*"] } { + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be + # different due to the way fork/exec works. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] + } + + return $testpid +} + +# Spawn GDB with CMDLINE_FLAGS appended to the GDBFLAGS global. + +proc gdb_spawn_with_cmdline_opts { cmdline_flags } { + global GDBFLAGS + + set saved_gdbflags $GDBFLAGS + + append GDBFLAGS $cmdline_flags + + set res [gdb_spawn] + + set GDBFLAGS $saved_gdbflags + + return $res +} + proc do_attach_tests {} { global gdb_prompt global binfile @@ -70,13 +101,7 @@ proc do_attach_tests {} { # Start the program running and then wait for a bit, to be sure # that it can be attached to. - set testpid [eval exec $binfile &] - exec sleep 2 - if { [istarget "*-*-cygwin*"] } { - # testpid is the Cygwin PID, GDB uses the Windows PID, which might be - # different due to the way fork/exec works. - set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] - } + set testpid [spawn_test_prog $binfile] # Verify that we cannot attach to nonsense. @@ -279,16 +304,7 @@ proc do_attach_tests {} { remote_exec build "kill -9 ${testpid}" - # Start the program running and then wait for a bit, to be sure - # that it can be attached to. - - set testpid [eval exec $binfile &] - exec sleep 2 - if { [istarget "*-*-cygwin*"] } { - # testpid is the Cygwin PID, GDB uses the Windows PID, which might be - # different due to the way fork/exec works. - set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] - } + set testpid [spawn_test_prog $binfile] # Verify that we can attach to the process, and find its a.out # when we're cd'd to some directory that doesn't contain the @@ -335,16 +351,7 @@ proc do_call_attach_tests {} { global gdb_prompt global binfile2 - # Start the program running and then wait for a bit, to be sure - # that it can be attached to. - - set testpid [eval exec $binfile2 &] - exec sleep 2 - if { [istarget "*-*-cygwin*"] } { - # testpid is the Cygwin PID, GDB uses the Windows PID, which might be - # different due to the way fork/exec works. - set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] - } + set testpid [spawn_test_prog $binfile2] # Attach @@ -397,16 +404,7 @@ proc do_command_attach_tests {} { return 0 } - # Start the program running and then wait for a bit, to be sure - # that it can be attached to. - - set testpid [eval exec $binfile &] - exec sleep 2 - if { [istarget "*-*-cygwin*"] } { - # testpid is the Cygwin PID, GDB uses the Windows PID, which might be - # different due to the way fork/exec works. - set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] - } + set testpid [spawn_test_prog $binfile] gdb_exit if $verbose>1 then { @@ -429,6 +427,50 @@ proc do_command_attach_tests {} { remote_exec build "kill -9 ${testpid}" } +# Test ' gdb --pid PID -ex "run" '. GDB used to have a bug where +# "run" would run before the attach finished - PR17347. + +proc test_command_line_attach_run {} { + global gdb_prompt + global binfile + global verbose + global GDB + global INTERNAL_GDBFLAGS + + if ![isnative] then { + unsupported "commandline attach run test" + return 0 + } + + with_test_prefix "cmdline attach run" { + set testpid [spawn_test_prog $binfile] + + set test "run to prompt" + gdb_exit + set res [gdb_spawn_with_cmdline_opts "--pid=$testpid -ex \"start\""] + if { $res != 0} { + fail $test + return $res + } + gdb_test_multiple "" $test { + -re {Attaching to.*Start it from the beginning\? \(y or n\) } { + pass $test + } + } + + send_gdb "y\n" + + set test "run to main" + gdb_test_multiple "" $test { + -re "Temporary breakpoint .* main .*$gdb_prompt $" { + pass $test + } + } + + # Get rid of the process + remote_exec build "kill -9 ${testpid}" + } +} # Start with a fresh gdb @@ -453,4 +495,6 @@ do_call_attach_tests do_command_attach_tests +test_command_line_attach_run + return 0 Index: gdb-7.8/gdb/top.c =================================================================== --- gdb-7.8.orig/gdb/top.c 2014-09-07 19:12:45.067981589 +0200 +++ gdb-7.8/gdb/top.c 2014-09-07 19:12:48.601985706 +0200 @@ -375,6 +375,21 @@ check_frame_language_change (void) } } +void +maybe_wait_sync_command_done (int was_sync) +{ + /* If the interpreter is in sync mode (we're running a user + command's list, running command hooks or similars), and we + just ran a synchronous command that started the target, wait + for that command to end. */ + if (!interpreter_async && !was_sync && sync_execution) + { + while (gdb_do_one_event () >= 0) + if (!sync_execution) + break; + } +} + /* Execute the line P as a command, in the current user context. Pass FROM_TTY as second argument to the defining function. */ @@ -461,16 +476,7 @@ execute_command (char *p, int from_tty) else cmd_func (c, arg, from_tty); - /* If the interpreter is in sync mode (we're running a user - command's list, running command hooks or similars), and we - just ran a synchronous command that started the target, wait - for that command to end. */ - if (!interpreter_async && !was_sync && sync_execution) - { - while (gdb_do_one_event () >= 0) - if (!sync_execution) - break; - } + maybe_wait_sync_command_done (was_sync); /* If this command has been post-hooked, run the hook last. */ execute_cmd_post_hook (c); Index: gdb-7.8/gdb/top.h =================================================================== --- gdb-7.8.orig/gdb/top.h 2014-09-07 19:12:45.068981590 +0200 +++ gdb-7.8/gdb/top.h 2014-09-07 19:12:48.601985706 +0200 @@ -42,6 +42,14 @@ extern void quit_command (char *, int); extern void quit_cover (void); extern void execute_command (char *, int); +/* If the interpreter is in sync mode (we're running a user command's + list, running command hooks or similars), and we just ran a + synchronous command that started the target, wait for that command + to end. WAS_SYNC indicates whether sync_execution was set before + the command was run. */ + +extern void maybe_wait_sync_command_done (int was_sync); + extern void check_frame_language_change (void); /* Prepare for execution of a command. ++++++ gdb-async-stopped-on-pid-arg-2of2.patch ++++++ http://sourceware.org/ml/gdb-patches/2014-09/msg00174.html Subject: Re: Regression: GDB stopped on run with attached process (PR 17347) [Re: [pushed+7.8] Re: [PATCH] Fix "attach" command vs user input race --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, 03 Sep 2014 22:11:03 +0200, Pedro Alves wrote: > On 09/03/2014 08:58 AM, Jan Kratochvil wrote: > > > https://sourceware.org/bugzilla/show_bug.cgi?id=17347 > > Thanks Jan. > > Here's a fix, test included. Comments? In the testsuite run from the Fedora rpm packaging I get: GNU gdb (GDB) Fedora 7.8-21.fc21^M Copyright (C) 2014 Free Software Foundation, Inc.^M License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>^M This is free software: you are free to change and redistribute it.^M There is NO WARRANTY, to the extent permitted by law. Type "show copying"^M and "show warranty" for details.^M This GDB was configured as "i686-redhat-linux-gnu".^M Type "show configuration" for configuration details.^M For bug reporting instructions, please see:^M <http://www.gnu.org/software/gdb/bugs/>.^M Find the GDB manual and other documentation resources online at:^M <http://www.gnu.org/software/gdb/documentation/>.^M For help, type "help".^M Type "apropos word" to search for commands related to "word".^M Attaching to process 27028^M Reading symbols from /unsafebuild-i686-redhat-linux-gnu/gdb/testsuite.unix.-m32/outputs/gdb.base/attach/attach...done.^M Reading symbols from /lib/libm.so.6...Reading symbols from /usr/lib/debug/usr/lib/libm-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/libm.so.6^M Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/usr/lib/libc-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/libc.so.6^M Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/usr/lib/ld-2.19.90.so.debug...done.^M done.^M Loaded symbols for /lib/ld-linux.so.2^M main ()^M at gdb/testsuite/gdb.base/attach.c:15^M 15 while (! should_exit)^M The program being debugged has been started already.^M Start it from the beginning? (y or n) PASS: gdb.base/attach.exp: cmdline attach run: run to prompt y^M ^M Temporary breakpoint 1 at 0x8048481: file gdb/testsuite/gdb.base/attach.c, line 13.^M Starting program: /unsafe/home/jkratoch/hammock/20140907fedorarel21-f21/fedora-2---Type <return> to continue, or q <return> to quit---ERROR: Window too small. UNRESOLVED: gdb.base/attach.exp: cmdline attach run: run to main While I do not fully understand why that happens in every run of that Fedora testsuite while it never happens during my reproducibility attempts by hand I find it understandable and the Fedora testsuite issues does get fixed by the attached patch. > --- a/gdb/testsuite/gdb.base/attach.exp > +++ b/gdb/testsuite/gdb.base/attach.exp > @@ -58,6 +58,37 @@ if [get_compiler_info] { > return -1 > } > > +# Start the program running and then wait for a bit, to be sure that > +# it can be attached to. Return the process's PID. > + > +proc spawn_test_prog { executable } { > + set testpid [eval exec $executable &] > + exec sleep 2 Unrelated to this patch - this patch only moved the code. Also the code move could be a separate patch: I do not see why the testsuite commonly uses "exec sleep" while it also uses "sleep" itself which also works fine. > + if { [istarget "*-*-cygwin*"] } { > + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be > + # different due to the way fork/exec works. > + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] > + } > + > + return $testpid > +} [...] > @@ -429,6 +427,50 @@ proc do_command_attach_tests {} { > remote_exec build "kill -9 ${testpid}" > } > > +# Test ' gdb --pid PID -ex "run" '. GDB used to have a bug where > +# "run" would run before the attach finished - PR17347. > + > +proc test_command_line_attach_run {} { > + global gdb_prompt > + global binfile > + global verbose > + global GDB > + global INTERNAL_GDBFLAGS These 3 lines are unused. > + > + if ![isnative] then { > + unsupported "commandline attach run test" > + return 0 > + } > + > + with_test_prefix "cmdline attach run" { > + set testpid [spawn_test_prog $binfile] > + > + set test "run to prompt" > + gdb_exit > + set res [gdb_spawn_with_cmdline_opts "--pid=$testpid -ex \"start\""] Here see the attachment. > + if { $res != 0} { > + fail $test > + return $res > + } > + gdb_test_multiple "" $test { > + -re {Attaching to.*Start it from the beginning\? \(y or n\) } { > + pass $test > + } > + } > + > + send_gdb "y\n" > + > + set test "run to main" > + gdb_test_multiple "" $test { > + -re "Temporary breakpoint .* main .*$gdb_prompt $" { > + pass $test > + } > + } > + > + # Get rid of the process > + remote_exec build "kill -9 ${testpid}" > + } > +} > > # Start with a fresh gdb > > @@ -453,4 +495,6 @@ do_call_attach_tests > > do_command_attach_tests > > +test_command_line_attach_run > + > return 0 > diff --git a/gdb/top.c b/gdb/top.c > index fc2b84d..ba71f8f 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -373,6 +373,21 @@ check_frame_language_change (void) > } > } > Missing: /* See top.h. */ Unless that rule from me has been abandoned. > +void > +maybe_wait_sync_command_done (int was_sync) > +{ > + /* If the interpreter is in sync mode (we're running a user > + command's list, running command hooks or similars), and we > + just ran a synchronous command that started the target, wait > + for that command to end. */ > + if (!interpreter_async && !was_sync && sync_execution) > + { > + while (gdb_do_one_event () >= 0) > + if (!sync_execution) > + break; > + } > +} > + > /* Execute the line P as a command, in the current user context. > Pass FROM_TTY as second argument to the defining function. */ > Thanks, Jan --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=1 diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index c94c127..6e566a3 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -447,7 +444,8 @@ proc test_command_line_attach_run {} { set test "run to prompt" gdb_exit - set res [gdb_spawn_with_cmdline_opts "--pid=$testpid -ex \"start\""] + set res [gdb_spawn_with_cmdline_opts \ + "-iex set\\ height\\ 0 -iex set\\ width\\ 0 --pid=$testpid -ex \"start\""] if { $res != 0} { fail $test return $res --a8Wt8u1KmwUX3Y2C-- ++++++ gdb-async-stopped-on-pid-arg-testsuite.patch ++++++ http://sourceware.org/ml/gdb-patches/2014-09/msg00381.html Subject: [testsuite patch] runaway attach processes [Re: Regression: GDB stopped on run with attached process (PR 17347)] --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, 11 Sep 2014 14:35:53 +0200, Pedro Alves wrote: > Thanks, pushed to both master and 7.8. I have started seeing occasional runaway 'attach' processes these days. I cannot be certain it is really caused by this patch, for example grep 'FAIL.*cmdline attach run' does not show anything in my logs. But as I remember this 'attach' runaway process always happened in GDB (but I do not remember it in the past months) I think it would be most safe to just solve it forever by [attached]. Jan --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=1 gdb/testsuite/ 2014-09-12 Jan Kratochvil <jan.kratoch...@redhat.com> * gdb.base/attach.c: Include unistd.h. (main): Call alarm. Add label postloop. * gdb.base/attach.exp (do_attach_tests): Use gdb_get_line_number, gdb_breakpoint, gdb_continue_to_breakpoint. (test_command_line_attach_run): Kill ${testpid} in one exit path. diff --git a/gdb/testsuite/gdb.base/attach.c b/gdb/testsuite/gdb.base/attach.c index 0041b47..91b180c 100644 --- a/gdb/testsuite/gdb.base/attach.c +++ b/gdb/testsuite/gdb.base/attach.c @@ -5,6 +5,7 @@ exit unless/until gdb sets the variable to non-zero.) */ #include <stdio.h> +#include <unistd.h> int should_exit = 0; @@ -12,9 +13,11 @@ int main () { int local_i = 0; + alarm (60); + while (! should_exit) { local_i++; } - return 0; + return 0; /* postloop */ } diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 6340496..5fb5c53 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -256,11 +256,8 @@ proc do_attach_tests {} { # Verify that the modification really happened. - gdb_test "tbreak 19" "Temporary breakpoint .*at.*$srcfile, line 19.*" \ - "after attach2, set tbreak postloop" - - gdb_test "continue" "main.*at.*$srcfile:19.*" \ - "after attach2, reach tbreak postloop" + gdb_breakpoint [gdb_get_line_number "postloop"] temporary + gdb_continue_to_breakpoint "postloop" ".* postloop .*" # Allow the test process to exit, to cleanup after ourselves. @@ -451,6 +448,7 @@ proc test_command_line_attach_run {} { "-iex set\\ height\\ 0 -iex set\\ width\\ 0 --pid=$testpid -ex \"start\""] if { $res != 0} { fail $test + remote_exec build "kill -9 ${testpid}" return $res } gdb_test_multiple "" $test { --RnlQjJ0d97Da+TV1-- -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org