diff options
author | Xavier Roirand <roirand@adacore.com> | 2017-11-07 11:00:31 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-11-07 11:00:31 +0000 |
commit | d0fe47010fc3289e081ba547a0bfcc6d07906cd2 (patch) | |
tree | cb255e0b04bb0b1e4d43bce583ca2938e08f4b7d /gdb/testsuite | |
parent | 0198d5e6fc331d50dc19b7f250ac4bc510a8dbb5 (diff) | |
download | gdb-d0fe47010fc3289e081ba547a0bfcc6d07906cd2.zip gdb-d0fe47010fc3289e081ba547a0bfcc6d07906cd2.tar.gz gdb-d0fe47010fc3289e081ba547a0bfcc6d07906cd2.tar.bz2 |
Allow enabling/disabling breakpoint location ranges
When a breakpoint has multiple locations, like e.g.:
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x080486a2 in void foo<int>()...
1.2 y 0x080486ca in void foo<double>()...
[....]
1.5 y 0x080487fa in void foo<long>()...
it's possible to enable/disable the individual locations using the
'<breakpoint_number>.<location_number>' syntax, like e.g.:
(gdb) disable 1.2 1.3 1.4 1.5
That's inconvenient when you have a long list of locations to disable,
however.
This patch adds shorthand for the above, by making it possible to
specify a range of locations with the following syntax (similar to
thread id ranges):
<breakpoint_number>.<first_location_number>-<last_location_number>
For example, the command above can now be simplified to:
(gdb) disable 1.2-5
gdb/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (map_breakpoint_number_range): New, factored out
from ...
(map_breakpoint_numbers): ... here.
(find_location_by_number): Change parameters from string to
breakpoint number and location.
(extract_bp_number_and_location): New function.
(enable_disable_bp_num_loc)
(enable_disable_breakpoint_location_range)
(enable_disable_command): New functions, factored out ...
(enable_command, disable_command): ... these functions, and
adjusted to support ranges.
* NEWS: Document enable/disable breakpoint location range feature.
gdb/doc/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* gdb.texinfo (Set Breaks): Document support for breakpoint
location ranges in the enable/disable commands.
gdb/testsuite/ChangeLog:
2017-11-07 Xavier Roirand <roirand@adacore.com>
Pedro Alves <palves@redhat.com>
* gdb.base/ena-dis-br.exp: Add reference to
gdb.cp/ena-dis-br-range.exp.
* gdb.cp/ena-dis-br-range.exp: New file.
* gdb.cp/ena-dis-br-range.cc: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/ena-dis-br.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ena-dis-br-range.cc | 66 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/ena-dis-br-range.exp | 132 |
4 files changed, 209 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 371e98b..6468e52 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-11-07 Xavier Roirand <roirand@adacore.com> + Pedro Alves <palves@redhat.com> + + * gdb.base/ena-dis-br.exp: Add reference to + gdb.cp/ena-dis-br-range.exp. + * gdb.cp/ena-dis-br-range.exp: New file. + * gdb.cp/ena-dis-br-range.cc: New file. + 2017-11-06 Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.c: New. diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index d407408..9b8d251 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -324,6 +324,9 @@ set b4 [break_at main ""] # # WHAT - the command to test (disable/enable). # +# Note: tests involving location ranges (and more) are found in +# gdb.cp/ena-dis-br-range.exp. +# proc test_ena_dis_br { what } { global b1 global b2 diff --git a/gdb/testsuite/gdb.cp/ena-dis-br-range.cc b/gdb/testsuite/gdb.cp/ena-dis-br-range.cc new file mode 100644 index 0000000..9469e34 --- /dev/null +++ b/gdb/testsuite/gdb.cp/ena-dis-br-range.cc @@ -0,0 +1,66 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2017 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/>. */ + +/* Some overloaded functions to test breakpoints with multiple + locations. */ + +class foo +{ +public: + static void overload (void); + static void overload (char); + static void overload (int); + static void overload (double); +}; + +void +foo::overload () +{ +} + +void +foo::overload (char arg) +{ +} + +void +foo::overload (int arg) +{ +} + +void +foo::overload (double arg) +{ +} + +void +marker () +{ +} + +int +main () +{ + foo::overload (); + foo::overload (111); + foo::overload ('h'); + foo::overload (3.14); + + marker (); + + return 0; +} diff --git a/gdb/testsuite/gdb.cp/ena-dis-br-range.exp b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp new file mode 100644 index 0000000..8873c4a --- /dev/null +++ b/gdb/testsuite/gdb.cp/ena-dis-br-range.exp @@ -0,0 +1,132 @@ +# Copyright 2017 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/>. + +# This file is part of the gdb testsuite. + +# Test the enable/disable commands with breakpoint location ranges. + +# Note: more tests involving involving disable/enable commands on +# multiple locations and breakpoints are found in +# gdb.base/ena-dis-br.exp. + +if { [skip_cplus_tests] } { continue } + +standard_testfile .cc + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { + return -1 +} + +if ![runto 'marker'] then { + fail "run to marker" + return -1 +} + +# Returns a buffer corresponding to what GDB replies when asking for +# 'info breakpoint'. The parameters are all the existing breakpoints +# enabled/disable value: 'n' or 'y'. + +proc make_info_breakpoint_reply_re {b1 b2 b21 b22 b23 b24} { + set ws "\[\t \]+" + return [multi_line \ + "Num Type${ws}Disp Enb Address${ws}What.*" \ + "1${ws}breakpoint keep ${b1}${ws}.* in marker\\(\\) at .*" \ + "${ws}breakpoint already hit 1 time.*" \ + "2${ws}breakpoint${ws}keep${ws}${b2}${ws}<MULTIPLE>.*" \ + "2.1${ws}${b21}.*" \ + "2.2${ws}${b22}.*" \ + "2.3${ws}${b23}.*" \ + "2.4${ws}${b24}.*" \ + ] +} + +gdb_test "break foo::overload" \ + "Breakpoint \[0-9\]+ at $hex: foo::overload. .4 locations." \ + "set breakpoint at overload" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info" + +# Test the enable/disable commands, and check the enable/disable state +# of the breakpoints/locations in the "info break" output. CMD is the +# actual disable/enable command. The bNN parameters are the same as +# make_info_breakpoint_reply_re's. +proc test_enable_disable {cmd b1 b2 b21 b22 b23 b24} { + gdb_test_no_output $cmd + + set re [make_info_breakpoint_reply_re $b1 $b2 $b21 $b22 $b23 $b24] + gdb_test "info break" $re "breakpoint info $cmd" +} + +# Check that we can disable/enable a breakpoint with a single +# location. +test_enable_disable "disable 1" n y y y y y +test_enable_disable "enable 1" y y y y y y + +# Check that we can disable/disable a breakpoint with multiple +# locations. +test_enable_disable "disable 2" y n y y y y +test_enable_disable "enable 2" y y y y y y + +# Check that we can disable/enable a single location breakpoint. +test_enable_disable "disable 2.2" y y y n y y +test_enable_disable "enable 2.2" y y y y y y + +# Check that we can disable/enable a range of breakpoint locations. +test_enable_disable "disable 2.2-3" y y y n n y +test_enable_disable "enable 2.2-3" y y y y y y + +# Check that we can disable/enable a breakpoint location range with +# START==END. +test_enable_disable "disable 2.2-2" y y y n y y +test_enable_disable "enable 2.2-2" y y y y y y + +# Check that we can disable a location breakpoint range with max > +# existing breakpoint location. +gdb_test "disable 2.3-5" "Bad breakpoint location number '5'" \ + "disable location breakpoint range with max > existing" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y n n] \ + "breakpoint info disable 2.3 to 2.5" + +# Check that we can enable a location breakpoint range with max > +# existing breakpoint location. +gdb_test "enable 2.3-5" "Bad breakpoint location number '5'" \ + "enable location breakpoint range with max > existing" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info enable 2.3 to 2.5" + +# Check that disabling an reverse location breakpoint range does not +# work. +gdb_test_no_output "disable 2.3-2" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info disable 2.3-2" + +# Check that disabling an invalid breakpoint location range does not +# cause unexpected behavior. +gdb_test "disable 2.6-7" "Bad breakpoint location number '6'" \ + "disable an unvalid location breakpoint range" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info disable 2.6-7" + +# Check that disabling an invalid breakpoint location range does not +# cause trouble. +gdb_test_no_output "disable 2.8-6" + +gdb_test "info break" [make_info_breakpoint_reply_re y y y y y y] \ + "breakpoint info disable 2.8-6" |