• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision91950479c0d751fcb7f9720e3a479afcc80f789b (tree)
Zeit2018-04-11 06:52:50
AutorPedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

Fix resolving GNU ifunc bp locations when inferior runs resolver

I noticed that if you set a breakpoint on an ifunc before the ifunc is
resolved, and then let the program call the ifunc, thus resolving it,
GDB end up with a location for that original breakpoint that is
pointing to the ifunc target, but it is left pointing to the first
address of the function, instead of after its prologue. After
prologue is what you get if you create a new breakpoint at that point.

1) With no debug info for the target function:

1.a) Set before resolving, and then program continued passed resolving:
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400753 <final>
1.b) Breakpoint set after inferior resolved ifunc:
Num Type Disp Enb Address What
2 breakpoint keep y 0x0000000000400757 <final+4>

2) With debug info for the target function:

1.a) Set before resolving, and then program continued passed resolving:
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400753 in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:20
1.b) Breakpoint set after inferior resolved ifunc:
Num Type Disp Enb Address What
2 breakpoint keep y 0x000000000040075a in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:21

The problem is that elf_gnu_ifunc_resolver_return_stop (called by the
internal breakpoint that traps the resolver returning) does not agree
with linespec.c:minsym_found. It does not skip to the function's
start line (i.e., past the prologue). We can now use the
find_function_start_sal overload added by the previous commmit to fix
this.

New tests included, which fail before the patch, and pass afterwards.

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* elfread.c (elf_gnu_ifunc_resolver_return_stop): Use
find_function_start_sal instead of find_pc_line.

gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* gdb.base/gnu-ifunc.exp (set-break): Test that GDB resolves
ifunc breakpoint locations correctly of ifunc breakpoints set
while the program resolves the ifunc.

Ändern Zusammenfassung

Diff

--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1026,7 +1026,8 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
10261026
10271027 b->type = bp_breakpoint;
10281028 update_breakpoint_locations (b, current_program_space,
1029- find_pc_line (resolved_pc, 0), {});
1029+ find_function_start_sal (resolved_pc, NULL, true),
1030+ {});
10301031 }
10311032
10321033 /* A helper function for elf_symfile_read that reads the minimal
--- a/gdb/testsuite/gdb.base/gnu-ifunc.exp
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -106,6 +106,9 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
106106 return 1
107107 }
108108
109+ gdb_breakpoint [gdb_get_line_number "break-at-call"]
110+ gdb_continue_to_breakpoint "break-at-call" ".*break-at-call.*"
111+
109112 set ws "\[ \t\]+"
110113 set dot "\\.?"
111114
@@ -131,19 +134,21 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
131134 "Breakpoint $decimal at gnu-indirect-function resolver at $hex"
132135 gdb_test "info breakpoints" \
133136 "$decimal${ws}STT_GNU_IFUNC resolver${ws}keep${ws}y${ws}$hex <${gnu_ifunc_resolver}>"
137+
138+ # Make the breakpoint conditional on a condition that always
139+ # fails. This is so that when the ifunc-resolver breakpoint
140+ # triggers, GDB resumes the program immediately.
141+ gdb_test_no_output "condition \$bpnum 0"
134142 }
135143
136144 global final_src
137145
138146 with_test_prefix "resolve" {
139- delete_breakpoints
140147 gdb_breakpoint [gdb_get_line_number "break-at-exit"]
141148 gdb_continue_to_breakpoint "break-at-exit" ".*break-at-exit.*"
142149 }
143150
144151 with_test_prefix "after resolving" {
145- delete_breakpoints
146-
147152 if {!$final_debug} {
148153 # Set a breakpoint both at the ifunc, and at the ifunc's
149154 # target. GDB should resolve both to the same address.
@@ -176,7 +181,12 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
176181 gdb_test "break gnu_ifunc" "Breakpoint .* at $hex: file .*$final_src, line $lineno\\."
177182 set location "$decimal${ws}breakpoint${ws}keep${ws}y${ws}$hex in final at .*$final_src:$lineno"
178183 }
179- gdb_test "info breakpoints" "$location\r\n$location"
184+
185+ # The first location here is for the breakpoint that was set
186+ # before the ifunc was resolved. It should be resolved by
187+ # now, and it should have the exact same address/line as the
188+ # other two locations.
189+ gdb_test "info breakpoints" "$location\r\n.*$location\r\n$location"
180190 }
181191 }
182192