diff options
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/infrun.c | 33 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.c | 44 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp | 126 |
5 files changed, 208 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1de9d30..9d928b0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-01-29 Tom de Vries <tdevries@suse.de> + + PR breakpoints/26063 + * infrun.c (process_event_stop_test): Reset + ecs->event_thread->current_line to 0 if is-stmt=n and frame has + changed. + 2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com> * thread.c (thr_try_catch_cmd): Replace swith_to_thread with an diff --git a/gdb/infrun.c b/gdb/infrun.c index 3f14397..e070eff 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7000,27 +7000,44 @@ process_event_stop_test (struct execution_control_state *ecs) && (ecs->event_thread->current_line != stop_pc_sal.line || ecs->event_thread->current_symtab != stop_pc_sal.symtab)) { + /* We are at a different line. */ + if (stop_pc_sal.is_stmt) { - /* We are at the start of a different line. So stop. Note that - we don't stop if we step into the middle of a different line. - That is said to make things like for (;;) statements work - better. */ + /* We are at the start of a statement. + + So stop. Note that we don't stop if we step into the middle of a + statement. That is said to make things like for (;;) statements + work better. */ infrun_debug_printf ("stepped to a different line"); end_stepping_range (ecs); return; } else if (frame_id_eq (get_frame_id (get_current_frame ()), - ecs->event_thread->control.step_frame_id)) + ecs->event_thread->control.step_frame_id)) { - /* We are at the start of a different line, however, this line is - not marked as a statement, and we have not changed frame. We - ignore this line table entry, and continue stepping forward, + /* We are not at the start of a statement, and we have not changed + frame. + + We ignore this line table entry, and continue stepping forward, looking for a better place to stop. */ refresh_step_info = false; infrun_debug_printf ("stepped to a different line, but " "it's not the start of a statement"); } + else + { + /* We are not the start of a statement, and we have changed frame. + + We ignore this line table entry, and continue stepping forward, + looking for a better place to stop. Keep refresh_step_info at + true to note that the frame has changed, but ignore the line + number to make sure we don't ignore a subsequent entry with the + same line number. */ + stop_pc_sal.line = 0; + infrun_debug_printf ("stepped to a different frame, but " + "it's not the start of a statement"); + } } /* We aren't done stepping. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 842f9a5..36ba5d0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2021-01-29 Tom de Vries <tdevries@suse.de> + PR breakpoints/26063 + * gdb.dwarf2/dw2-step-out-of-function-no-stmt.c: New test. + * gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp: New file. + +2021-01-29 Tom de Vries <tdevries@suse.de> + * gdb.opt/solib-intra-step.exp: Remove state tracking logic. 2021-01-28 Tom de Vries <tdevries@suse.de> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.c b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.c new file mode 100644 index 0000000..a8184f0 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.c @@ -0,0 +1,44 @@ +/* + Copyright 2021 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +void +foo (int x) +{ + +} + +void +bar (void) +{ + asm ("bar_label: .globl bar_label"); +} + +int +main (void) +{ + asm ("main_label: .globl main_label"); + + bar (); + + asm ("main_label_2: .globl main_label_2"); + + foo (10); + + asm ("main_label_3: .globl main_label_3"); + + return 0; +} + diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp new file mode 100644 index 0000000..9249eb5 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp @@ -0,0 +1,126 @@ +# Copyright 2021 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check whether stepping out of a function works, in case: +# - the first insn after the call has an is-stmt=no entry +# - the next insn has an is-stmt=yes entry, for the same line number +# +# This sort of thing can occur in optimized code, f.i. here a slightly more +# elaborate case with another is-stmt=no entry (the one with line number 12) +# inbetween: +# INDEX LINE ADDRESS IS-STMT +# 12 13 0x00000000004003ed +# 13 12 0x00000000004003f2 +# 14 13 0x00000000004003f4 Y + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + verbose "Skipping $gdb_test_file_name." + return 0 +} + +# The .c files use __attribute__. +if [get_compiler_info] { + return -1 +} +if !$gcc_compiled { + verbose "Skipping $gdb_test_file_name." + return 0 +} + +standard_testfile .c -dw.S + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + declare_labels Llines + global srcdir subdir srcfile + + lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \ + main_start main_len + set main_end "$main_start + $main_len" + + lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \ + bar_start bar_len + set bar_end "$bar_start + $bar_len" + + cu {} { + compile_unit { + {language @DW_LANG_C} + {name $srcfile} + {stmt_list $Llines DW_FORM_sec_offset} + } { + subprogram { + {external 1 flag} + {MACRO_AT_func {main}} + } + subprogram { + {external 1 flag} + {MACRO_AT_func {bar}} + } + } + } + + lines {version 2} Llines { + include_dir "${srcdir}/${subdir}" + file_name "$srcfile" 1 + + program { + {DW_LNE_set_address bar_label} + {line 26} + {DW_LNS_copy} + + {DW_LNE_set_address $bar_end} + {DW_LNE_end_sequence} + + {DW_LNE_set_address main_label} + {line 32} + {DW_LNS_copy} + + {DW_LNE_set_address main_label_2} + {line 36} + {DW_LNS_negate_stmt} + {DW_LNS_copy} + {DW_LNS_negate_stmt} + + {DW_LNE_set_address main_label_3} + {line 36} + {DW_LNS_copy} + + {DW_LNE_set_address $main_end} + {DW_LNE_end_sequence} + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +# Step into bar. +gdb_breakpoint "bar" +gdb_continue_to_breakpoint "bar" + +# Step out of bar. +gdb_test "step" [multi_line \ + "main \\(\\) at \[^\r\n\]*$srcfile:36" \ + "36\t\[^\r\n\]*"] + |