public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/gdb] gdb-17.2-rebase-f44: Use inlined func name for printing breakpoints (RH BZ 1228556, Keith Seitz).
@ 2026-06-27 23:58 Jan Kratochvil
0 siblings, 0 replies; only message in thread
From: Jan Kratochvil @ 2026-06-27 23:58 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/gdb
Branch : gdb-17.2-rebase-f44
Commit : f408ba821f8c8b5ad6564b98806666d2478f7599
Author : Jan Kratochvil <jan.kratochvil@redhat.com>
Date : 2017-10-27T21:07:50+02:00
Stats : +358/-1 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/gdb/c/f408ba821f8c8b5ad6564b98806666d2478f7599?branch=gdb-17.2-rebase-f44
Log:
Use inlined func name for printing breakpoints (RH BZ 1228556, Keith Seitz).
---
diff --git a/gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch b/gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch
new file mode 100644
index 0000000..1dcc678
--- /dev/null
+++ b/gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch
@@ -0,0 +1,136 @@
+commit 06871ae84096ed1672eb76f44cea4d5dbe79ae24
+Author: Pedro Alves <palves@redhat.com>
+Date: Wed Sep 20 16:12:54 2017 +0100
+
+ Make "list ambiguous" show symbol names too
+
+ Currently, with an ambiguous "list first,last", we get:
+
+ (gdb) list bar,main
+ Specified first line 'bar' is ambiguous:
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
+
+ This commit makes gdb's output above a bit clearer by printing the
+ symbol name as well:
+
+ (gdb) list bar,main
+ Specified first line 'bar' is ambiguous:
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
+
+ And while at it, makes gdb print the symbol name when actually listing
+ multiple locations too. I.e., before (with "set listsize 2"):
+
+ (gdb) list bar
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
+ 96
+ 97 int bar (A) { return 11; }
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
+ 97 int bar (A) { return 11; }
+ 98 int bar (B) { return 22; }
+
+ After:
+
+ (gdb) list bar
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
+ 96
+ 97 int bar (A) { return 11; }
+ file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
+ 97 int bar (A) { return 11; }
+ 98 int bar (B) { return 22; }
+
+ Currently, the result of decoding a linespec loses information about
+ the original symbol that was found. All we end up with is an address.
+ This makes it difficult to find the original symbol again to get at
+ its print name. Fix that by storing a pointer to the symbol in the
+ sal. We already store the symtab and obj_section, so it feels like a
+ natural progression to me. This avoids having to do any extra symbol
+ lookup too.
+
+ gdb/ChangeLog:
+ 2017-09-20 Pedro Alves <palves@redhat.com>
+
+ * cli/cli-cmds.c (list_command): Use print_sal_location.
+ (print_sal_location): New function.
+ (ambiguous_line_spec): Use print_sal_location.
+ * linespec.c (symbol_to_sal): Record the symbol in the sal.
+ * symtab.c (find_function_start_sal): Likewise.
+ * symtab.h (symtab_and_line::symbol): New field.
+
+ gdb/testsuite/ChangeLog:
+ 2017-09-20 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
+ symbol names in gdb's output.
+ * gdb.cp/overload.exp ("list all overloads"): Likewise.
+
+### a/gdb/ChangeLog
+### b/gdb/ChangeLog
+## -1,5 +1,14 @@
+ 2017-09-20 Pedro Alves <palves@redhat.com>
+
++ * cli/cli-cmds.c (list_command): Use print_sal_location.
++ (print_sal_location): New function.
++ (ambiguous_line_spec): Use print_sal_location.
++ * linespec.c (symbol_to_sal): Record the symbol in the sal.
++ * symtab.c (find_function_start_sal): Likewise.
++ * symtab.h (symtab_and_line::symbol): New field.
++
++2017-09-20 Pedro Alves <palves@redhat.com>
++
+ * linespec.c (minsym_found): Handle non-text minsyms.
+ (symbol_to_sal): Record a sal.pc for non-block, non-label symbols.
+
+Index: gdb-8.0.1/gdb/linespec.c
+===================================================================
+--- gdb-8.0.1.orig/gdb/linespec.c 2017-10-20 21:28:18.444609776 +0200
++++ gdb-8.0.1/gdb/linespec.c 2017-10-20 21:29:12.382094104 +0200
+@@ -3864,6 +3864,7 @@
+ {
+ init_sal (result);
+ result->symtab = symbol_symtab (sym);
++ result->symbol = sym;
+ result->line = SYMBOL_LINE (sym);
+ result->pc = SYMBOL_VALUE_ADDRESS (sym);
+ result->pspace = SYMTAB_PSPACE (result->symtab);
+@@ -3879,6 +3880,7 @@
+ /* We know its line number. */
+ init_sal (result);
+ result->symtab = symbol_symtab (sym);
++ result->symbol = sym;
+ result->line = SYMBOL_LINE (sym);
+ result->pspace = SYMTAB_PSPACE (result->symtab);
+ return 1;
+Index: gdb-8.0.1/gdb/symtab.c
+===================================================================
+--- gdb-8.0.1.orig/gdb/symtab.c 2017-10-20 21:28:18.446609794 +0200
++++ gdb-8.0.1/gdb/symtab.c 2017-10-20 21:29:51.390444377 +0200
+@@ -3478,6 +3478,7 @@
+ fixup_symbol_section (sym, NULL);
+ section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym);
+ sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0);
++ sal.symbol = sym;
+
+ if (funfirstline && sal.symtab != NULL
+ && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
+@@ -3501,6 +3502,7 @@
+ sal.pspace = current_program_space;
+ sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
+ sal.section = section;
++ sal.symbol = sym;
+ }
+
+ if (funfirstline)
+Index: gdb-8.0.1/gdb/symtab.h
+===================================================================
+--- gdb-8.0.1.orig/gdb/symtab.h 2017-10-20 21:28:21.205634569 +0200
++++ gdb-8.0.1/gdb/symtab.h 2017-10-20 21:28:40.933811716 +0200
+@@ -1420,6 +1420,7 @@
+ struct program_space *pspace;
+
+ struct symtab *symtab;
++ struct symbol *symbol = NULL;
+ struct obj_section *section;
+ /* Line number. Line numbers start at 1 and proceed through symtab->nlines.
+ 0 is never a valid line number; it is used to indicate that line number
diff --git a/gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch b/gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch
new file mode 100644
index 0000000..31e886d
--- /dev/null
+++ b/gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch
@@ -0,0 +1,212 @@
+commit 4a27f119f59a44395e0a34b1526cee709e1d3fce
+Author: Keith Seitz <keiths@redhat.com>
+Date: Fri Oct 27 10:57:23 2017 -0700
+
+ Use SaL symbol name when reporting breakpoint locations
+
+ Currently, "info break" can show some (perhaps) unexpected results when
+ setting a breakpoint on an inlined function:
+
+ (gdb) list
+ 1 #include <stdio.h>
+ 2
+ 3 static inline void foo()
+ 4 {
+ 5 printf("Hello world\n");
+ 6 }
+ 7
+ 8 int main()
+ 9 {
+ 10 foo();
+ 11 return 0;
+ 12 }
+ 13
+ (gdb) b foo
+ Breakpoint 1 at 0x400434: file foo.c, line 5.
+ (gdb) i b
+ Num Type Disp Enb Address What
+ 1 breakpoint keep y 0x0000000000400434 in main at foo.c:5
+
+ GDB reported that we understood what "foo" was, but we then report that the
+ breakpoint is actually set in main. While that is literally true, we can
+ do a little better.
+
+ This is accomplished by copying the symbol for which the breakpoint was set
+ into the bp_location. From there, print_breakpoint_location can use this
+ information to print out symbol information (if available) instead of calling
+ find_pc_sect_function.
+
+ With the patch installed,
+
+ (gdb) i b
+ Num Type Disp Enb Address What
+ 1 breakpoint keep y 0x0000000000400434 in foo at foo.c:5
+
+ gdb/ChangeLog:
+
+ * breakpoint.c (print_breakpoint_location): Use the symbol saved
+ in the bp_location, falling back to find_pc_sect_function when
+ needed.
+ (add_location_to_breakpoint): Save sal->symbol.
+ * breakpoint.h (struct bp_location) <symbol>: New field.
+ * symtab.c (find_function_start_sal): Save the symbol into the SaL.
+ * symtab.h (struct symtab_and_line) <symbol>: New field.
+
+ gdb/testsuite/ChangeLog:
+
+ * gdb.opt/inline-break.exp (break_info_1): New procedure.
+ Test "info break" for every inlined function breakpoint.
+
+### a/gdb/ChangeLog
+### b/gdb/ChangeLog
+## -1,3 +1,13 @@
++2017-10-27 Keith Seitz <keiths@redhat.com>
++
++ * breakpoint.c (print_breakpoint_location): Use the symbol saved
++ in the bp_location, falling back to find_pc_sect_function when
++ needed.
++ (add_location_to_breakpoint): Save sal->symbol.
++ * breakpoint.h (struct bp_location) <symbol>: New field.
++ * symtab.c (find_function_start_sal): Save the symbol into the SaL.
++ * symtab.h (struct symtab_and_line) <symbol>: New field.
++
+ 2017-10-26 Patrick Frants <osscontribute@gmail.com>
+
+ PR gdb/13669
+--- a/gdb/breakpoint.c
++++ b/gdb/breakpoint.c
+@@ -5956,8 +5956,11 @@ print_breakpoint_location (struct breakpoint *b,
+ uiout->field_string ("what", event_location_to_string (b->location.get ()));
+ else if (loc && loc->symtab)
+ {
+- struct symbol *sym
+- = find_pc_sect_function (loc->address, loc->section);
++ const struct symbol *sym = loc->symbol;
++
++ if (sym == NULL)
++ sym = find_pc_sect_function (loc->address, loc->section);
++
+ if (sym)
+ {
+ uiout->text ("in ");
+@@ -8743,6 +8746,7 @@ add_location_to_breakpoint (struct breakpoint *b,
+ loc->gdbarch = loc_gdbarch;
+ loc->line_number = sal->line;
+ loc->symtab = sal->symtab;
++ loc->symbol = sal->symbol;
+
+ set_breakpoint_location_function (loc,
+ sal->explicit_pc || sal->explicit_line);
+--- a/gdb/breakpoint.h
++++ b/gdb/breakpoint.h
+@@ -486,6 +486,11 @@ public:
+ to find the corresponding source file name. */
+
+ struct symtab *symtab;
++
++ /* The symbol found by the location parser, if any. This may be used to
++ ascertain when an event location was set at a different location than
++ the one originally selected by parsing, e.g., inlined symbols. */
++ const struct symbol *symbol = NULL;
+ };
+
+ /* The possible return values for print_bpstat, print_it_normal,
+### a/gdb/testsuite/ChangeLog
+### b/gdb/testsuite/ChangeLog
+## -1,3 +1,8 @@
++2017-10-27 Keith Seitz <keiths@redhat.com>
++
++ * gdb.opt/inline-break.exp (break_info_1): New procedure.
++ Test "info break" for every inlined function breakpoint.
++
+ 2017-10-27 Yao Qi <yao.qi@linaro.org>
+
+ * gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.
+--- a/gdb/testsuite/gdb.opt/inline-break.exp
++++ b/gdb/testsuite/gdb.opt/inline-break.exp
+@@ -24,6 +24,62 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ return -1
+ }
+
++# Return a string that may be used to match the output of "info break NUM".
++#
++# Optional arguments:
++#
++# source - the name of the source file
++# func - the name of the function
++# disp - the event disposition
++# enabled - enable state
++# locs - number of locations
++# line - source line number (ignored without -source)
++
++proc break_info_1 {num args} {
++ global decimal
++
++ # Column delimiter
++ set c {[\t ]+}
++
++ # Row delimiter
++ set end {[\r\n \t]+}
++
++ # Table header
++ set header "[join [list Num Type Disp Enb Address What] ${c}]"
++
++ # Get/configure any optional parameters.
++ parse_args [list {source ""} {func ".*"} {disp "keep"} \
++ {enabled "y"} {locs 1} [list line $decimal] \
++ {type "breakpoint"}]
++
++ if {$source != ""} {
++ set source "$source:$line"
++ }
++
++ # Result starts with the standard header.
++ set result "$header${end}"
++
++ # Set up for multi-location breakpoint marker.
++ if {$locs == 1} {
++ set multi ".*"
++ } else {
++ set multi "<MULTIPLE>${end}"
++ }
++ append result "[join [list $num $type $disp $enabled $multi] $c]"
++
++ # Add location info.
++ for {set i 1} {$i <= $locs} {incr i} {
++ if {$locs > 1} {
++ append result "[join [list $num.$i $enabled] $c].*"
++ }
++
++ # Add function/source file info.
++ append result "in $func at .*$source${end}"
++ }
++
++ return $result
++}
++
+ #
+ # func1 is a static inlined function that is called once.
+ # The result should be a single-location breakpoint.
+@@ -111,3 +167,22 @@ gdb_test "print func1" \
+ #
+ gdb_test "print func2" \
+ "\\\$.* = {int \\(int\\)} .* <func2>"
++
++# Test that "info break" reports the location of the breakpoints "inside"
++# the inlined functions
++
++set results(1) [break_info_1 1 -source $srcfile -func "func1"]
++set results(2) [break_info_1 2 -locs 2 -source $srcfile -func "func2"]
++set results(3) [break_info_1 3 -source $srcfile -func "func3b"]
++set results(4) [break_info_1 4 -locs 2 -source $srcfile -func "func4b"]
++set results(5) [break_info_1 5 -locs 2 -source $srcfile -func "func5b"]
++set results(6) [break_info_1 6 -locs 3 -source $srcfile -func "func6b"]
++set results(7) [break_info_1 7 -locs 2 -source $srcfile -func "func7b"]
++set results(8) [break_info_1 8 -locs 3 -source $srcfile -func "func8b"]
++
++for {set i 1} {$i <= [array size results]} {incr i} {
++ send_log "Expecting: $results($i)\n"
++ gdb_test "info break $i" $results($i)
++}
++
++unset -nocomplain results
diff --git a/gdb.spec b/gdb.spec
index 466e8c5..f59fcb7 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -26,7 +26,7 @@ Version: 8.0.1
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 29%{?dist}
+Release: 30%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
Group: Development/Debuggers
@@ -733,6 +733,10 @@ Patch1257: gdb-rhbz1498758-3of5.patch
Patch1258: gdb-rhbz1498758-4of5.patch
Patch1259: gdb-rhbz1498758-5of5.patch
+# Use inlined func name for printing breakpoints (RH BZ 1228556, Keith Seitz).
+Patch1261: gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch
+Patch1262: gdb-rhbz1228556-bpt-inlined-func-name-2of2.patch
+
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
# Patch642: gdb-readline62-ask-more-rh.patch
@@ -1145,6 +1149,8 @@ done
%patch1257 -p1
%patch1258 -p1
%patch1259 -p1
+%patch1261 -p1
+%patch1262 -p1
%patch1075 -p1
%if 0%{?rhel:1} && 0%{?rhel} <= 7
@@ -1727,6 +1733,9 @@ then
fi
%changelog
+* Fri Oct 27 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 8.0.1-30.fc26
+- Use inlined func name for printing breakpoints (RH BZ 1228556, Keith Seitz).
+
* Sat Oct 7 2017 Jan Kratochvil <jan.kratochvil@redhat.com> - 8.0.1-29.fc26
- [s390x] Backport arch14 guarded-storage register support (RH BZ 1498758).
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-27 23:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-27 23:58 [rpms/gdb] gdb-17.2-rebase-f44: Use inlined func name for printing breakpoints (RH BZ 1228556, Keith Seitz) Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox