diff --git a/gdb-tdep-handle-pipe2-syscall-for-amd64.patch b/gdb-tdep-handle-pipe2-syscall-for-amd64.patch new file mode 100644 index 0000000..9897641 --- /dev/null +++ b/gdb-tdep-handle-pipe2-syscall-for-amd64.patch @@ -0,0 +1,61 @@ +[gdb/tdep] Handle pipe2 syscall for amd64 + +When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed, +I run into: +... +(gdb) continue^M +Continuing.^M +Process record and replay target doesn't support syscall number 293^M +Process record: failed to record execution log.^M +^M +Program stopped.^M +0x00007ffff7daabdb in pipe () from /lib64/libc.so.6^M +(gdb) FAIL: gdb.reverse/pipe-reverse.exp: continue to breakpoint: marker2 +... + +The current glibc on Tumbleweed is 2.35, which contains commit +"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2 +is used in stead of syscall pipe. + +There is already support added for syscall pipe2 for aarch64 (which only has +syscall pipe2, not syscall pipe), so enable the same for amd64, by: +- adding amd64_sys_pipe2 in enum amd64_syscall +- translating amd64_sys_pipe2 to gdb_sys_pipe2 in amd64_canonicalize_syscall + +Tested on x86_64-linux, specifically on: +- openSUSE Tumbleweed (with glibc 2.35), and +- openSUSE Leap 15.3 (with glibc 2.31). + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056 + +--- + gdb/amd64-linux-tdep.c | 3 +++ + gdb/amd64-linux-tdep.h | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c +index 0e5194fbeee..9a0759d639c 100644 +--- a/gdb/amd64-linux-tdep.c ++++ b/gdb/amd64-linux-tdep.c +@@ -460,6 +460,9 @@ amd64_canonicalize_syscall (enum amd64_syscall syscall_number) + case amd64_x32_sys_pipe: + return gdb_sys_pipe; + ++ case amd64_sys_pipe2: ++ return gdb_sys_pipe2; ++ + case amd64_sys_select: + case amd64_x32_sys_select: + return gdb_sys_select; +diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h +index 4a41b3b8245..184b0c86f07 100644 +--- a/gdb/amd64-linux-tdep.h ++++ b/gdb/amd64-linux-tdep.h +@@ -320,6 +320,7 @@ enum amd64_syscall { + amd64_sys_sync_file_range = 277, + amd64_sys_vmsplice = 278, + amd64_sys_move_pages = 279, ++ amd64_sys_pipe2 = 293 + }; + + /* Enum that defines the syscall identifiers for x32 linux. diff --git a/gdb-tdep-support-catch-syscall-pipe2-for-i386.patch b/gdb-tdep-support-catch-syscall-pipe2-for-i386.patch new file mode 100644 index 0000000..47ef00b --- /dev/null +++ b/gdb-tdep-support-catch-syscall-pipe2-for-i386.patch @@ -0,0 +1,44 @@ +[gdb/tdep] Support catch syscall pipe2 for i386 + +With test-case gdb.base/catch-syscall.exp and target board unix/-m32, we run +into: +... +(gdb) catch syscall pipe2^M +Unknown syscall name 'pipe2'.^M +(gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: catch syscall pipe2 +... + +Fix this by: +- adding a pipe2 entry in gdb/syscalls/i386-linux.xml.in, and +- regenerating gdb/syscalls/i386-linux.xml using + "xsltproc --output i386-linux.xml apply-defaults.xsl i386-linux.xml.in". + +Tested on x86_64-linux with native and unix/-m32. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056 + +--- + gdb/syscalls/i386-linux.xml | 1 + + gdb/syscalls/i386-linux.xml.in | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/gdb/syscalls/i386-linux.xml b/gdb/syscalls/i386-linux.xml +index a783dd10af3..4a7a2345186 100644 +--- a/gdb/syscalls/i386-linux.xml ++++ b/gdb/syscalls/i386-linux.xml +@@ -334,4 +334,5 @@ + + + ++ + +diff --git a/gdb/syscalls/i386-linux.xml.in b/gdb/syscalls/i386-linux.xml.in +index e778ab54043..13c4d1d99d4 100644 +--- a/gdb/syscalls/i386-linux.xml.in ++++ b/gdb/syscalls/i386-linux.xml.in +@@ -337,4 +337,5 @@ + + + ++ + diff --git a/gdb-testsuite-fix-gdb.base-annota1.exp-with-pie.patch b/gdb-testsuite-fix-gdb.base-annota1.exp-with-pie.patch new file mode 100644 index 0000000..8824aee --- /dev/null +++ b/gdb-testsuite-fix-gdb.base-annota1.exp-with-pie.patch @@ -0,0 +1,43 @@ +[gdb/testsuite] Fix gdb.base/annota1.exp with pie + +Since commit 359efc2d894 ("[gdb/testsuite] Make gdb.base/annota1.exp more +robust") we see this fail with target board unix/-fPIE/-pie: +... +FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout) +... + +The problem is that the commit makes the number and order of matched +annotations fixed, while between target boards unix and unix/-fPIE/-pie there +is a difference: +... + \032\032post-prompt + Starting program: outputs/gdb.base/annota1/annota1 + ++\032\032breakpoints-invalid ++ + \032\032starting + + \032\032frames-invalid +... + +Fix this by optionally matching the additional annotation. + +Tested on x86_64-linux. + +--- + gdb/testsuite/gdb.base/annota1.exp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp +index 019c8048fd0..b9f80cbb6ed 100644 +--- a/gdb/testsuite/gdb.base/annota1.exp ++++ b/gdb/testsuite/gdb.base/annota1.exp +@@ -159,6 +159,8 @@ set run_re \ + "\r\n\032\032post-prompt\r\n" \ + "Starting program: $binexp \r\n" \ + $optional_re \ ++ "\(\r\n\032\032breakpoints-invalid\r\n\)?" \ ++ $optional_re \ + "\r\n\032\032starting\r\n" \ + $optional_re \ + "\r\n\032\032frames-invalid\r\n" \ diff --git a/gdb-testsuite-handle-pipe2-syscall-in-gdb.base-catch-syscall.exp.patch b/gdb-testsuite-handle-pipe2-syscall-in-gdb.base-catch-syscall.exp.patch new file mode 100644 index 0000000..6fa8daa --- /dev/null +++ b/gdb-testsuite-handle-pipe2-syscall-in-gdb.base-catch-syscall.exp.patch @@ -0,0 +1,202 @@ +[gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp + +When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed, +I run into: +... +(gdb) continue^M +Continuing.^M +^M +Catchpoint 2 (returned from syscall pipe2), in pipe () from /lib64/libc.so.6^M +(gdb) FAIL: gdb.base/catch-syscall.exp: without arguments: \ + syscall pipe has returned +... + +The current glibc on Tumbleweed is 2.35, which contains commit +"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2 +is used instead of syscall pipe. + +Fix this by detecting whether syscall pipe or pipe2 is used before running the tests. + +Tested on x86_64-linux, specifically on: +- openSUSE Tumbleweed (with glibc 2.35), and +- openSUSE Leap 15.3 (with glibc 2.31). + +On openSUSE Tumbleweed + target board unix/-m32, this exposes: +... +(gdb) catch syscall pipe2^M +Unknown syscall name 'pipe2'.^M +... +so make the test robust against this by using the syscall number instead, +while still noting that the syscall name pipe2 is not recognized: +... +FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: catch syscall pipe2 +... +which will be fixed in a folllow-up patch. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056 + +--- + gdb/testsuite/gdb.base/catch-syscall.c | 3 +- + gdb/testsuite/gdb.base/catch-syscall.exp | 100 ++++++++++++++++++++++++++++--- + 2 files changed, 93 insertions(+), 10 deletions(-) + +diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c +index 0ab96318d3e..8c252a06b20 100644 +--- a/gdb/testsuite/gdb.base/catch-syscall.c ++++ b/gdb/testsuite/gdb.base/catch-syscall.c +@@ -24,7 +24,8 @@ int chroot_syscall = SYS_chroot; + int read_syscall = SYS_read; + #ifdef SYS_pipe + int pipe_syscall = SYS_pipe; +-#else ++#endif ++#ifdef SYS_pipe2 + int pipe2_syscall = SYS_pipe2; + #endif + int write_syscall = SYS_write; +diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp +index a5dfd02411b..cc76a2cf61d 100644 +--- a/gdb/testsuite/gdb.base/catch-syscall.exp ++++ b/gdb/testsuite/gdb.base/catch-syscall.exp +@@ -185,7 +185,11 @@ proc insert_catch_syscall_with_many_args { syscalls numbers } { + set filter_str "" + + foreach name $syscalls number $numbers { +- set filter_str "${filter_str}'${name}' \\\[${number}\\\] " ++ if { [string is integer $name] } { ++ append filter_str "${name} " ++ } else { ++ append filter_str "'${name}' \\\[${number}\\\] " ++ } + } + + set filter_str [ string trimright $filter_str " " ] +@@ -662,42 +666,120 @@ proc fill_all_syscalls_numbers {} { + global all_syscalls_numbers last_syscall_number unknown_syscall_number all_syscalls + + foreach syscall $all_syscalls { +- lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1] ++ if { [string is integer $syscall] } { ++ lappend all_syscalls_numbers $syscall ++ } else { ++ lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1] ++ } + } + + set last_syscall_number [get_integer_valueof "exit_group_syscall" -1] + set unknown_syscall_number [get_integer_valueof "unknown_syscall" -1] + } + +-# Set up the vector all_syscalls. ++# Catch syscall with NAME, or if gdb doesn't support that (yet), try NR ++# instead. ++ ++proc catch_syscall_name_or_nr { name nr } { ++ global decimal ++ ++ gdb_test_multiple "catch syscall $name" "" { ++ -re -wrap "Catchpoint $decimal \\(syscall '$name' \\\[$nr\\\]\\)" { ++ pass $gdb_test_name ++ } ++ -re -wrap "Unknown syscall name '$name'\." { ++ fail $gdb_test_name ++ gdb_test "catch syscall $nr" "Catchpoint $decimal \\(syscall $nr\\)" ++ } ++ } ++} ++ ++# Set up the vector all_syscalls. Returns 1 upon success, 0 upon failure. + + proc setup_all_syscalls {} { + global all_syscalls + global gdb_prompt ++ global decimal + + # They are ordered according to the file, so do not change this. + lappend all_syscalls "close" + lappend all_syscalls "chroot" + ++ if { ![runto_main] } { ++ return 0 ++ } ++ + # SYS_pipe doesn't exist on aarch64 kernel. + set test "check SYS_pipe" ++ set have_SYS_pipe 0 + gdb_test_multiple "p pipe_syscall" $test { +- -re " = .*$gdb_prompt $" { ++ -re -wrap " = ($decimal)" { ++ pass $test ++ set have_SYS_pipe 1 ++ set SYS_pipe $expect_out(1,string) ++ } ++ -re -wrap "No symbol .*" { ++ pass $test ++ } ++ } ++ ++ set test "check SYS_pipe2" ++ set have_SYS_pipe2 0 ++ gdb_test_multiple "p pipe2_syscall" $test { ++ -re -wrap " = ($decimal)" { + pass $test +- lappend all_syscalls "pipe" ++ set have_SYS_pipe2 1 ++ set SYS_pipe2 $expect_out(1,string) + } +- -re "No symbol .*$gdb_prompt $" { ++ -re -wrap "No symbol .*" { + pass $test +- # SYS_pipe isn't defined, use SYS_pipe2 instead. +- lappend all_syscalls "pipe2" ++ } ++ } ++ ++ if { $have_SYS_pipe == 0 && $have_SYS_pipe2 == 0 } { ++ return 0 ++ } ++ ++ with_test_prefix "determine pipe syscall" { ++ set line [gdb_get_line_number "pipe (fd)"] ++ gdb_test "break $line" ++ gdb_continue_to_breakpoint "before pipe call" ++ if { $have_SYS_pipe } { ++ catch_syscall_name_or_nr pipe $SYS_pipe ++ } ++ if { $have_SYS_pipe2 } { ++ catch_syscall_name_or_nr pipe2 $SYS_pipe2 ++ } ++ set ok 0 ++ gdb_test_multiple "continue" "" { ++ -re -wrap "Catchpoint $decimal \\(call to syscall (pipe|$SYS_pipe)\\).*" { ++ lappend all_syscalls $expect_out(1,string) ++ pass $gdb_test_name ++ set ok 1 ++ } ++ -re -wrap "Catchpoint $decimal \\(call to syscall (pipe2|$SYS_pipe2)\\).*" { ++ lappend all_syscalls $expect_out(1,string) ++ pass $gdb_test_name ++ set ok 1 ++ } ++ -re -wrap "" { ++ fail $gdb_test_name ++ } ++ } ++ if { ! $ok } { ++ return 0 + } + } + + lappend all_syscalls "write" + lappend all_syscalls "read" ++ ++ return 1 + } + +-setup_all_syscalls ++if { ![setup_all_syscalls] } { ++ return -1 ++} + + # Fill all the syscalls numbers before starting anything. + fill_all_syscalls_numbers diff --git a/gdb-testsuite-make-gdb.base-annota1.exp-more-robust.patch b/gdb-testsuite-make-gdb.base-annota1.exp-more-robust.patch new file mode 100644 index 0000000..90a3768 --- /dev/null +++ b/gdb-testsuite-make-gdb.base-annota1.exp-more-robust.patch @@ -0,0 +1,127 @@ +[gdb/testsuite] Make gdb.base/annota1.exp more robust + +On openSUSE Tumbleweed I run into: +... +FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout) +... + +The problem is that the libthread_db message occurs at a location where it's +not expected: +... +Starting program: outputs/gdb.base/annota1/annota1 ^M +^M +^Z^Zstarting^M +^M +^Z^Zframes-invalid^M +[Thread debugging using libthread_db enabled]^M +Using host libthread_db library "/lib64/libthread_db.so.1".^M +^M +^Z^Zbreakpoints-invalid^M +^M +... + +Fix this by making the matching more robust: +- rewrite the regexp such that each annotation is on a single line, + starting with \r\n\032\032 and ending with \r\n +- add a regexp variable optional_re, that matches all possible optional + output, and use it as a separator in the first part of the regexp + +Tested on x86_64-linux. + +--- + gdb/testsuite/gdb.base/annota1.exp | 71 +++++++++++++++++++++++++------------- + 1 file changed, 47 insertions(+), 24 deletions(-) + +diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp +index cf0b93e01a3..019c8048fd0 100644 +--- a/gdb/testsuite/gdb.base/annota1.exp ++++ b/gdb/testsuite/gdb.base/annota1.exp +@@ -128,41 +128,64 @@ gdb_test_multiple "info break" "breakpoint info" { + set binexp [string_to_regexp $binfile] + + set warning_slow_re \ +- "warning: File transfers from remote targets can be slow\[^\r\n\]+" ++ "warning: File transfers from remote targets can be slow\[^\r\n\]+\r\n" + set warning_gdb_index_re \ + [multi_line \ + "warning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+" \ + "Do \"set use-deprecated-index-sections on\" before the file is read" \ +- "to use the section anyway\\."] ++ "to use the section anyway\\.\r\n"] + set reading_re \ +- "Reading \[^\r\n\]+" ++ "Reading \[^\r\n\]+\r\n" + set libthread_db_re \ + [multi_line \ + "\\\[Thread debugging using libthread_db enabled\\\]" \ +- "Using host libthread_db library \[^\r\n\]+"] ++ "Using host libthread_db library \[^\r\n\]+\r\n"] + +-set run_re \ ++set optional_re \ + [list \ +- "\r\n\032\032post-prompt\r\nStarting program: $binexp " \ +- "\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \ ++ "\(" \ ++ "\($reading_re)" \ ++ "|" \ ++ "\($warning_slow_re\)" \ ++ "|" \ ++ "\($libthread_db_re\)" \ ++ "|" \ + "\(\r\n$warning_gdb_index_re\)?" \ +- "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ +- "\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)|\r\n$libthread_db_re\)*" \ +- "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ +- "\032\032breakpoint 1\r\n\r\n" \ +- "Breakpoint 1, \r\n" \ +- "\032\032frame-begin 0 $hex\r\n\r\n" \ +- "\032\032frame-function-name\r\n" \ +- "main\r\n" \ +- "\032\032frame-args\r\n \\(\\)\r\n" \ +- "\032\032frame-source-begin\r\n at \r\n" \ +- "\032\032frame-source-file\r\n.*annota1.c\r\n" \ +- "\032\032frame-source-file-end\r\n:\r\n" \ +- "\032\032frame-source-line\r\n$main_line\r\n" \ +- "\032\032frame-source-end\r\n\r\n\r\n" \ +- "\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \ +- "\032\032frame-end\r\n\r\n" \ +- "\032\032stopped"] ++ "\)*"] ++set optional_re [join $optional_re ""] ++ ++set run_re \ ++ [list \ ++ "\r\n\032\032post-prompt\r\n" \ ++ "Starting program: $binexp \r\n" \ ++ $optional_re \ ++ "\r\n\032\032starting\r\n" \ ++ $optional_re \ ++ "\r\n\032\032frames-invalid\r\n" \ ++ $optional_re \ ++ "\r\n\032\032breakpoints-invalid\r\n" \ ++ $optional_re \ ++ "\r\n\032\032breakpoint 1\r\n" \ ++ "\r\n" \ ++ "Breakpoint 1, " \ ++ "\r\n\032\032frame-begin 0 $hex\r\n" \ ++ "\r\n\032\032frame-function-name\r\n" \ ++ "main" \ ++ "\r\n\032\032frame-args\r\n" \ ++ " \\(\\)" \ ++ "\r\n\032\032frame-source-begin\r\n" \ ++ " at " \ ++ "\r\n\032\032frame-source-file\r\n" \ ++ ".*annota1.c" \ ++ "\r\n\032\032frame-source-file-end\r\n" \ ++ ":" \ ++ "\r\n\032\032frame-source-line\r\n" \ ++ "$main_line" \ ++ "\r\n\032\032frame-source-end\r\n" \ ++ "\r\n" \ ++ "\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n" \ ++ "\r\n\032\032frame-end\r\n" \ ++ "\r\n\032\032stopped\r\n"] + + set run_re [join $run_re ""] + diff --git a/gdb.changes b/gdb.changes index a298cfa..e94ce1e 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Wed May 4 13:49:10 UTC 2022 - Tom de Vries + +- patches added (trunk backport): + * gdb-testsuite-make-gdb.base-annota1.exp-more-robust.patch + * gdb-testsuite-fix-gdb.base-annota1.exp-with-pie.patch +- patches added (gdb-patches ml backport): + * gdb-tdep-handle-pipe2-syscall-for-amd64.patch + * gdb-testsuite-handle-pipe2-syscall-in-gdb.base-catch-syscall.exp.patch + * gdb-tdep-support-catch-syscall-pipe2-for-i386.patch +- Maintenance script qa.sh: + * Add Leap 15.4 x86_64 to know good configs. + ------------------------------------------------------------------- Fri Apr 29 13:27:04 UTC 2022 - Martin Liška diff --git a/gdb.spec b/gdb.spec index afdbb15..d8fc237 100644 --- a/gdb.spec +++ b/gdb.spec @@ -349,6 +349,8 @@ Patch2035: gdb-r_version-check.patch Patch2036: ibm-z-add-another-arch14-instruction.patch Patch2037: ibm-z-remove-lpswey-parameter.patch Patch2038: fix-build-with-current-gcc-el_explicit-location-always-non-null.patch +Patch2039: gdb-testsuite-make-gdb.base-annota1.exp-more-robust.patch +Patch2040: gdb-testsuite-fix-gdb.base-annota1.exp-with-pie.patch # Backports from master, not yet available in next release. @@ -396,6 +398,12 @@ Patch2119: gdb-testsuite-fix-gdb.arch-i386-pkru.exp-on-linux.patch Patch2120: gdb-tdep-fix-avx512-m32-support-in-gdbserver.patch # https://sourceware.org/pipermail/gdb-patches/2021-December/184241.html Patch2121: gdb-ada-fix-assert-in-ada_is_unconstrained_packed_array_type.patch +# https://sourceware.org/pipermail/gdb-patches/2022-May/188661.html +Patch2122: gdb-tdep-handle-pipe2-syscall-for-amd64.patch +# https://sourceware.org/pipermail/gdb-patches/2022-May/188732.html +Patch2123: gdb-testsuite-handle-pipe2-syscall-in-gdb.base-catch-syscall.exp.patch +# https://sourceware.org/pipermail/gdb-patches/2022-May/188733.html +Patch2124: gdb-tdep-support-catch-syscall-pipe2-for-i386.patch BuildRequires: bison BuildRequires: flex @@ -797,6 +805,8 @@ find -name "*.info*"|xargs rm -f %patch2036 -p1 %patch2037 -p1 %patch2038 -p1 +%patch2039 -p1 +%patch2040 -p1 %patch2100 -p1 %patch2101 -p1 @@ -818,6 +828,9 @@ find -name "*.info*"|xargs rm -f %patch2119 -p1 %patch2120 -p1 %patch2121 -p1 +%patch2122 -p1 +%patch2123 -p1 +%patch2124 -p1 #unpack libipt %if 0%{have_libipt} diff --git a/qa.sh b/qa.sh index 95030ef..a9e7730 100644 --- a/qa.sh +++ b/qa.sh @@ -267,6 +267,13 @@ case $n in "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m32.sum") + # Known clean config: Leap 15.4 x86_64 + config=openSUSE_Leap_15.4.x86_64/gdb-testresults + sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" + "$config/gdb-x86_64-suse-linux-m64.sum" + "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum" + "$config/gdb-x86_64-suse-linux-m32.sum") + # Known clean config: SLE 15 x86_64. config=SLE-15.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum"