-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gdb: implement inferior-specific breakpoints
This is a "workaround feature" which is intended to help with multi-target program debugging until a more fundamental solution is available. With this addition, the following command syntax is recognized by gdb: (gdb) b file.c:42 inferior 1 It willl only insert breakpoint locations into program space that matches inferior 1 and will only consider a breakpoint hit if the current inferior is 1. It is already possible to achieve similar results by using `if $_inferior == N` conditional breakpoint, but the major advantage of the implemented feature is that it skips insertion of breakpoints completely, which can be of a high importance for some platforms. gdb/ChangeLog: 2019-11-20 Mihails Strasuns <mihails.strasuns@intel.com> * breakpoint.h (struct breakpoint): new field 'inferior' * breakpoint.c (find_condition_and_thread): supports new break command syntax for specifying an inferior (create_breakpoint): pass breakpoint inferior argument around (decode_location_default, init_breakpoint_sal): if inferior number is present, only match location if inferior pspace matches location pspace (print_one_breakpoint_location): always print inferior for inferior-specific breakpoints * linespec.c (linespec_keywords): add "inferior" to the keyword list gdb/testsuite/ChangeLog: 2019-11-20 Mihails Strasuns <mihails.strasuns@intel.com> * gdb.base/breakpoint-inferior.exp: new test case to cover functionaity of inferior breakpoint feature * lib/completion-support.exp, gdb.linespec/explicit.exp: recognize new keyword Signed-off-by: Mihails Strasuns <mihails.strasuns@intel.com>
- Loading branch information
1 parent
7c5cad0
commit 7d87ac9
Showing
13 changed files
with
387 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* This testcase is part of GDB, the GNU debugger. | ||
Copyright 2019-2020 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/>. */ | ||
|
||
int | ||
main (void) | ||
{ | ||
int i = 1; /* break-here */ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright 2019-2020 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/>. | ||
|
||
standard_testfile | ||
|
||
# Check if start command is supported. | ||
if {[use_gdb_stub]} { | ||
return 0 | ||
} | ||
|
||
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | ||
return -1 | ||
} | ||
|
||
# Test pending inferior breakpoint | ||
|
||
gdb_test "add-inferior" | ||
set bp_loc [gdb_get_line_number "break-here"] | ||
gdb_breakpoint "$bp_loc inferior 2" {allow-pending} | ||
|
||
gdb_test "inferior 1" "Switching to inferior 1.*" "inferior 1 (pending)" | ||
if {[gdb_start_cmd] < 0} { | ||
fail "start inferior 1" | ||
return | ||
} | ||
gdb_test "" ".*reakpoint ., main .*${srcfile}.*" "run inferior 1 to main" | ||
gdb_continue_to_end "inferior 1" | ||
|
||
gdb_test "inferior 2" | ||
gdb_test "file $binfile" "Reading symbols.*" "inferior 2 symbols (pending)" | ||
if {[gdb_run_cmd] < 0} { | ||
fail "run inferior 2" | ||
return | ||
} | ||
gdb_test_multiple "" "run inferior 2 until bp" { | ||
-re -wrap "Breakpoint .*$srcfile:$bp_loc.*" { | ||
pass $gdb_test_name | ||
gdb_continue_to_end "run inferior 2 until end" | ||
} | ||
-re -wrap "exited normally" { | ||
fail $gdb_test_name | ||
} | ||
} | ||
|
||
gdb_test "inferior 1" | ||
gdb_test "remove-inferiors 2" | ||
gdb_test "info b" "No breakpoints or watchpoints." | ||
|
||
set main_addr [get_hexadecimal_valueof "&main" 0x0] | ||
gdb_breakpoint "*$main_addr inferior 1" | ||
gdb_test "add-inferior -exec $binfile" "Reading symbols.*" "inferior 3 symbols" | ||
gdb_test_multiple "info b" "only inf 1 after location update" { | ||
-re -wrap "inf ($decimal)" { | ||
set inf_no $expect_out(1,string) | ||
gdb_assert {$inf_no == 1} $gdb_test_name | ||
} | ||
} | ||
gdb_test "set schedule-multiple on" | ||
if {[gdb_run_cmd] < 0} { | ||
fail "run with addr-based bp" | ||
} else { | ||
gdb_test "" "Breakpoint ., main .*${srcfile}.*" "run with addr-based bp" | ||
} | ||
|
||
gdb_test "print \$_inferior" " = 1" | ||
gdb_continue_to_end "final run to end" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,7 @@ namespace eval $testfile { | |
"-qualified" | ||
"-source" | ||
"if" | ||
"inferior" | ||
"task" | ||
"thread" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters