|
|
8f6b9e |
commit 4a27f119f59a44395e0a34b1526cee709e1d3fce
|
|
|
8f6b9e |
Author: Keith Seitz <keiths@redhat.com>
|
|
|
8f6b9e |
Date: Fri Oct 27 10:57:23 2017 -0700
|
|
|
8f6b9e |
|
|
|
8f6b9e |
Use SaL symbol name when reporting breakpoint locations
|
|
|
8f6b9e |
|
|
|
8f6b9e |
Currently, "info break" can show some (perhaps) unexpected results when
|
|
|
8f6b9e |
setting a breakpoint on an inlined function:
|
|
|
8f6b9e |
|
|
|
8f6b9e |
(gdb) list
|
|
|
8f6b9e |
1 #include <stdio.h>
|
|
|
8f6b9e |
2
|
|
|
8f6b9e |
3 static inline void foo()
|
|
|
8f6b9e |
4 {
|
|
|
8f6b9e |
5 printf("Hello world\n");
|
|
|
8f6b9e |
6 }
|
|
|
8f6b9e |
7
|
|
|
8f6b9e |
8 int main()
|
|
|
8f6b9e |
9 {
|
|
|
8f6b9e |
10 foo();
|
|
|
8f6b9e |
11 return 0;
|
|
|
8f6b9e |
12 }
|
|
|
8f6b9e |
13
|
|
|
8f6b9e |
(gdb) b foo
|
|
|
8f6b9e |
Breakpoint 1 at 0x400434: file foo.c, line 5.
|
|
|
8f6b9e |
(gdb) i b
|
|
|
8f6b9e |
Num Type Disp Enb Address What
|
|
|
8f6b9e |
1 breakpoint keep y 0x0000000000400434 in main at foo.c:5
|
|
|
8f6b9e |
|
|
|
8f6b9e |
GDB reported that we understood what "foo" was, but we then report that the
|
|
|
8f6b9e |
breakpoint is actually set in main. While that is literally true, we can
|
|
|
8f6b9e |
do a little better.
|
|
|
8f6b9e |
|
|
|
8f6b9e |
This is accomplished by copying the symbol for which the breakpoint was set
|
|
|
8f6b9e |
into the bp_location. From there, print_breakpoint_location can use this
|
|
|
8f6b9e |
information to print out symbol information (if available) instead of calling
|
|
|
8f6b9e |
find_pc_sect_function.
|
|
|
8f6b9e |
|
|
|
8f6b9e |
With the patch installed,
|
|
|
8f6b9e |
|
|
|
8f6b9e |
(gdb) i b
|
|
|
8f6b9e |
Num Type Disp Enb Address What
|
|
|
8f6b9e |
1 breakpoint keep y 0x0000000000400434 in foo at foo.c:5
|
|
|
8f6b9e |
|
|
|
8f6b9e |
gdb/ChangeLog:
|
|
|
8f6b9e |
|
|
|
8f6b9e |
* breakpoint.c (print_breakpoint_location): Use the symbol saved
|
|
|
8f6b9e |
in the bp_location, falling back to find_pc_sect_function when
|
|
|
8f6b9e |
needed.
|
|
|
8f6b9e |
(add_location_to_breakpoint): Save sal->symbol.
|
|
|
8f6b9e |
* breakpoint.h (struct bp_location) <symbol>: New field.
|
|
|
8f6b9e |
* symtab.c (find_function_start_sal): Save the symbol into the SaL.
|
|
|
8f6b9e |
* symtab.h (struct symtab_and_line) <symbol>: New field.
|
|
|
8f6b9e |
|
|
|
8f6b9e |
gdb/testsuite/ChangeLog:
|
|
|
8f6b9e |
|
|
|
8f6b9e |
* gdb.opt/inline-break.exp (break_info_1): New procedure.
|
|
|
8f6b9e |
Test "info break" for every inlined function breakpoint.
|
|
|
8f6b9e |
|
|
|
8f6b9e |
### a/gdb/ChangeLog
|
|
|
8f6b9e |
### b/gdb/ChangeLog
|
|
|
8f6b9e |
## -1,3 +1,13 @@
|
|
|
8f6b9e |
+2017-10-27 Keith Seitz <keiths@redhat.com>
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ * breakpoint.c (print_breakpoint_location): Use the symbol saved
|
|
|
8f6b9e |
+ in the bp_location, falling back to find_pc_sect_function when
|
|
|
8f6b9e |
+ needed.
|
|
|
8f6b9e |
+ (add_location_to_breakpoint): Save sal->symbol.
|
|
|
8f6b9e |
+ * breakpoint.h (struct bp_location) <symbol>: New field.
|
|
|
8f6b9e |
+ * symtab.c (find_function_start_sal): Save the symbol into the SaL.
|
|
|
8f6b9e |
+ * symtab.h (struct symtab_and_line) <symbol>: New field.
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
2017-10-26 Patrick Frants <osscontribute@gmail.com>
|
|
|
8f6b9e |
|
|
|
8f6b9e |
PR gdb/13669
|
|
|
8f6b9e |
Index: gdb-7.6.1/gdb/breakpoint.c
|
|
|
8f6b9e |
===================================================================
|
|
|
8f6b9e |
--- gdb-7.6.1.orig/gdb/breakpoint.c 2017-10-27 21:38:34.569392186 +0200
|
|
|
8f6b9e |
+++ gdb-7.6.1/gdb/breakpoint.c 2017-10-27 21:38:37.699416969 +0200
|
|
|
8f6b9e |
@@ -5703,8 +5703,11 @@
|
|
|
8f6b9e |
ui_out_field_string (uiout, "what", b->addr_string);
|
|
|
8f6b9e |
else if (loc && loc->symtab)
|
|
|
8f6b9e |
{
|
|
|
8f6b9e |
- struct symbol *sym
|
|
|
8f6b9e |
- = find_pc_sect_function (loc->address, loc->section);
|
|
|
8f6b9e |
+ const struct symbol *sym = loc->symbol;
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ if (sym == NULL)
|
|
|
8f6b9e |
+ sym = find_pc_sect_function (loc->address, loc->section);
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
if (sym)
|
|
|
8f6b9e |
{
|
|
|
8f6b9e |
ui_out_text (uiout, "in ");
|
|
|
8f6b9e |
@@ -8851,6 +8854,7 @@
|
|
|
8f6b9e |
loc->gdbarch = loc_gdbarch;
|
|
|
8f6b9e |
loc->line_number = sal->line;
|
|
|
8f6b9e |
loc->symtab = sal->symtab;
|
|
|
8f6b9e |
+ loc->symbol = sal->symbol;
|
|
|
8f6b9e |
|
|
|
8f6b9e |
set_breakpoint_location_function (loc,
|
|
|
8f6b9e |
sal->explicit_pc || sal->explicit_line);
|
|
|
8f6b9e |
Index: gdb-7.6.1/gdb/breakpoint.h
|
|
|
8f6b9e |
===================================================================
|
|
|
8f6b9e |
--- gdb-7.6.1.orig/gdb/breakpoint.h 2017-10-27 21:38:33.271381909 +0200
|
|
|
8f6b9e |
+++ gdb-7.6.1/gdb/breakpoint.h 2017-10-27 21:38:37.700416977 +0200
|
|
|
8f6b9e |
@@ -476,6 +476,11 @@
|
|
|
8f6b9e |
to find the corresponding source file name. */
|
|
|
8f6b9e |
|
|
|
8f6b9e |
struct symtab *symtab;
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ /* The symbol found by the location parser, if any. This may be used to
|
|
|
8f6b9e |
+ ascertain when an event location was set at a different location than
|
|
|
8f6b9e |
+ the one originally selected by parsing, e.g., inlined symbols. */
|
|
|
8f6b9e |
+ const struct symbol *symbol;
|
|
|
8f6b9e |
};
|
|
|
8f6b9e |
|
|
|
8f6b9e |
/* Return values for bpstat_explains_signal. Note that the order of
|
|
|
8f6b9e |
Index: gdb-7.6.1/gdb/testsuite/gdb.opt/inline-break.exp
|
|
|
8f6b9e |
===================================================================
|
|
|
8f6b9e |
--- gdb-7.6.1.orig/gdb/testsuite/gdb.opt/inline-break.exp 2013-01-01 07:41:25.000000000 +0100
|
|
|
8f6b9e |
+++ gdb-7.6.1/gdb/testsuite/gdb.opt/inline-break.exp 2017-10-27 21:41:42.869884103 +0200
|
|
|
8f6b9e |
@@ -24,6 +24,100 @@
|
|
|
8f6b9e |
return -1
|
|
|
8f6b9e |
}
|
|
|
8f6b9e |
|
|
|
8f6b9e |
+# RHEL-7:
|
|
|
8f6b9e |
+proc parse_args { argset } {
|
|
|
8f6b9e |
+ upvar args args
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ foreach argument $argset {
|
|
|
8f6b9e |
+ if {[llength $argument] == 1} {
|
|
|
8f6b9e |
+ # No default specified, so we assume that we should set
|
|
|
8f6b9e |
+ # the value to 1 if the arg is present and 0 if it's not.
|
|
|
8f6b9e |
+ # It is assumed that no value is given with the argument.
|
|
|
8f6b9e |
+ set result [lsearch -exact $args "-$argument"]
|
|
|
8f6b9e |
+ if {$result != -1} then {
|
|
|
8f6b9e |
+ uplevel 1 [list set $argument 1]
|
|
|
8f6b9e |
+ set args [lreplace $args $result $result]
|
|
|
8f6b9e |
+ } else {
|
|
|
8f6b9e |
+ uplevel 1 [list set $argument 0]
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+ } elseif {[llength $argument] == 2} {
|
|
|
8f6b9e |
+ # There are two items in the argument. The second is a
|
|
|
8f6b9e |
+ # default value to use if the item is not present.
|
|
|
8f6b9e |
+ # Otherwise, the variable is set to whatever is provided
|
|
|
8f6b9e |
+ # after the item in the args.
|
|
|
8f6b9e |
+ set arg [lindex $argument 0]
|
|
|
8f6b9e |
+ set result [lsearch -exact $args "-[lindex $arg 0]"]
|
|
|
8f6b9e |
+ if {$result != -1} then {
|
|
|
8f6b9e |
+ uplevel 1 [list set $arg [lindex $args [expr $result+1]]]
|
|
|
8f6b9e |
+ set args [lreplace $args $result [expr $result+1]]
|
|
|
8f6b9e |
+ } else {
|
|
|
8f6b9e |
+ uplevel 1 [list set $arg [lindex $argument 1]]
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+ } else {
|
|
|
8f6b9e |
+ error "Badly formatted argument \"$argument\" in argument set"
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # The remaining args should be checked to see that they match the
|
|
|
8f6b9e |
+ # number of items expected to be passed into the procedure...
|
|
|
8f6b9e |
+}
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+# Return a string that may be used to match the output of "info break NUM".
|
|
|
8f6b9e |
+#
|
|
|
8f6b9e |
+# Optional arguments:
|
|
|
8f6b9e |
+#
|
|
|
8f6b9e |
+# source - the name of the source file
|
|
|
8f6b9e |
+# func - the name of the function
|
|
|
8f6b9e |
+# disp - the event disposition
|
|
|
8f6b9e |
+# enabled - enable state
|
|
|
8f6b9e |
+# locs - number of locations
|
|
|
8f6b9e |
+# line - source line number (ignored without -source)
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+proc break_info_1 {num args} {
|
|
|
8f6b9e |
+ global decimal
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Column delimiter
|
|
|
8f6b9e |
+ set c {[\t ]+}
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Row delimiter
|
|
|
8f6b9e |
+ set end {[\r\n \t]+}
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Table header
|
|
|
8f6b9e |
+ set header "[join [list Num Type Disp Enb Address What] ${c}]"
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Get/configure any optional parameters.
|
|
|
8f6b9e |
+ parse_args [list {source ""} {func ".*"} {disp "keep"} \
|
|
|
8f6b9e |
+ {enabled "y"} {locs 1} [list line $decimal] \
|
|
|
8f6b9e |
+ {type "breakpoint"}]
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ if {$source != ""} {
|
|
|
8f6b9e |
+ set source "$source:$line"
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Result starts with the standard header.
|
|
|
8f6b9e |
+ set result "$header${end}"
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Set up for multi-location breakpoint marker.
|
|
|
8f6b9e |
+ if {$locs == 1} {
|
|
|
8f6b9e |
+ set multi ".*"
|
|
|
8f6b9e |
+ } else {
|
|
|
8f6b9e |
+ set multi "<MULTIPLE>${end}"
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+ append result "[join [list $num $type $disp $enabled $multi] $c]"
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Add location info.
|
|
|
8f6b9e |
+ for {set i 1} {$i <= $locs} {incr i} {
|
|
|
8f6b9e |
+ if {$locs > 1} {
|
|
|
8f6b9e |
+ append result "[join [list $num.$i $enabled] $c].*"
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ # Add function/source file info.
|
|
|
8f6b9e |
+ append result "in $func at .*$source${end}"
|
|
|
8f6b9e |
+ }
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+ return $result
|
|
|
8f6b9e |
+}
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
#
|
|
|
8f6b9e |
# func1 is a static inlined function that is called once.
|
|
|
8f6b9e |
# The result should be a single-location breakpoint.
|
|
|
8f6b9e |
@@ -111,3 +205,22 @@
|
|
|
8f6b9e |
#
|
|
|
8f6b9e |
gdb_test "print func2" \
|
|
|
8f6b9e |
"\\\$.* = {int \\(int\\)} .* <func2>"
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+# Test that "info break" reports the location of the breakpoints "inside"
|
|
|
8f6b9e |
+# the inlined functions
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+set results(1) [break_info_1 1 -source $srcfile -func "func1"]
|
|
|
8f6b9e |
+set results(2) [break_info_1 2 -locs 2 -source $srcfile -func "func2"]
|
|
|
8f6b9e |
+set results(3) [break_info_1 3 -source $srcfile -func "func3b"]
|
|
|
8f6b9e |
+set results(4) [break_info_1 4 -locs 2 -source $srcfile -func "func4b"]
|
|
|
8f6b9e |
+set results(5) [break_info_1 5 -locs 2 -source $srcfile -func "func5b"]
|
|
|
8f6b9e |
+set results(6) [break_info_1 6 -locs 3 -source $srcfile -func "func6b"]
|
|
|
8f6b9e |
+set results(7) [break_info_1 7 -locs 2 -source $srcfile -func "func7b"]
|
|
|
8f6b9e |
+set results(8) [break_info_1 8 -locs 3 -source $srcfile -func "func8b"]
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+for {set i 1} {$i <= [array size results]} {incr i} {
|
|
|
8f6b9e |
+ send_log "Expecting: $results($i)\n"
|
|
|
8f6b9e |
+ gdb_test "info break $i" $results($i)
|
|
|
8f6b9e |
+}
|
|
|
8f6b9e |
+
|
|
|
8f6b9e |
+unset -nocomplain results
|