* [PATCH] Fix backtrace limit stopping on inline frame [not found] <20240106141735.2330-1-ssbssa.ref@yahoo.de> @ 2024-01-06 14:17 ` Hannes Domani 2024-01-17 16:05 ` [PING] " Hannes Domani 2024-01-29 10:55 ` Andrew Burgess 0 siblings, 2 replies; 5+ messages in thread From: Hannes Domani @ 2024-01-06 14:17 UTC (permalink / raw) To: gdb-patches If you have set up a backtrace limit, and the backtrace stops because of this in an inline frame with arguments, you get an assertion failure: ``` (gdb) bt #0 normal_frame (i=0) at gdb-29865.c:4 #1 0x000000013fe3162a in inline_frame (i=0) at gdb-29865.c:9 #2 main () at gdb-29865.c:14 (gdb) set backtrace limit 2 (gdb) bt #0 normal_frame (i=0) at gdb-29865.c:4 #1 0x000000013fe3162a in inline_frame ( C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed. ``` And if this one if fixed, there is another one as well: ``` (gdb) bt #0 normal_frame (i=0) at gdb-29865.c:4 #1 0x000000013fdf162a in inline_frame ( C:/src/repos/binutils-gdb.git/gdb/dwarf2/loc.c:1160: internal-error: dwarf_expr_reg_to_entry_parameter: Assertion `frame != NULL' failed. ``` The reason for both of them is this kind of loop: ``` while (get_frame_type (frame) == INLINE_FRAME) frame = get_prev_frame (frame); ``` Since get_prev_frame respects the backtrace limit, it will return NULL, and from there on you can't continue. This changes these loops to use get_prev_frame_always instead, so you always get a non-inline frame in the end. With this backtrace works: ``` (gdb) bt #0 normal_frame (i=0) at gdb-29865.c:4 #1 0x000000013fd4162a in inline_frame (i=0) at gdb-29865.c:9 (gdb) ``` Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29865 --- gdb/dwarf2/frame.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/testsuite/gdb.opt/inline-bt.c | 8 ++++---- gdb/testsuite/gdb.opt/inline-bt.exp | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index d3d1ecdf1f5..143b934e5ef 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -1423,7 +1423,7 @@ dwarf2_frame_cfa (frame_info_ptr this_frame) _("cfa not available for record btrace target")); while (get_frame_type (this_frame) == INLINE_FRAME) - this_frame = get_prev_frame (this_frame); + this_frame = get_prev_frame_always (this_frame); if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE) throw_error (NOT_AVAILABLE_ERROR, _("can't compute CFA for this frame: " diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index c15221eb7a2..b1f188bf9c5 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1156,7 +1156,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, while (get_frame_type (frame) == INLINE_FRAME) { - frame = get_prev_frame (frame); + frame = get_prev_frame_always (frame); gdb_assert (frame != NULL); } diff --git a/gdb/testsuite/gdb.opt/inline-bt.c b/gdb/testsuite/gdb.opt/inline-bt.c index 8dac8d30300..0dad0f47e6e 100644 --- a/gdb/testsuite/gdb.opt/inline-bt.c +++ b/gdb/testsuite/gdb.opt/inline-bt.c @@ -28,15 +28,15 @@ volatile int result; void bar(void); -inline ATTR int func1(void) +inline ATTR int func1(int s) { bar (); - return x * y; + return x * y + s; } inline ATTR int func2(void) { - return x * func1 (); + return x * func1 (1); } int main (void) @@ -47,7 +47,7 @@ int main (void) y = 8; bar (); - val = func1 (); + val = func1 (2); result = val; val = func2 (); diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp index 501b24109e3..b0e5f61a5c7 100644 --- a/gdb/testsuite/gdb.opt/inline-bt.exp +++ b/gdb/testsuite/gdb.opt/inline-bt.exp @@ -65,3 +65,4 @@ gdb_test "up" "#1 .*func1.*" "up from bar (4)" gdb_test "info frame" ".*in func1.*" "info frame still works" # Verify the user visible limit works as expected. gdb_test "up" "Initial frame selected; you cannot go up." "up hits limit" +gdb_test "backtrace" "#0 bar.*#1 .*func1.*" "backtrace hits limit" -- 2.35.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PING] [PATCH] Fix backtrace limit stopping on inline frame 2024-01-06 14:17 ` [PATCH] Fix backtrace limit stopping on inline frame Hannes Domani @ 2024-01-17 16:05 ` Hannes Domani 2024-01-26 17:05 ` Hannes Domani 2024-01-29 10:55 ` Andrew Burgess 1 sibling, 1 reply; 5+ messages in thread From: Hannes Domani @ 2024-01-17 16:05 UTC (permalink / raw) To: gdb-patches Ping. On 06.01.2024 15:17, Hannes Domani wrote: > If you have set up a backtrace limit, and the backtrace stops > because of this in an inline frame with arguments, you get an > assertion failure: > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fe3162a in inline_frame (i=0) at gdb-29865.c:9 > #2 main () at gdb-29865.c:14 > (gdb) set backtrace limit 2 > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fe3162a in inline_frame ( > C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed. > ``` > > And if this one if fixed, there is another one as well: > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fdf162a in inline_frame ( > C:/src/repos/binutils-gdb.git/gdb/dwarf2/loc.c:1160: internal-error: dwarf_expr_reg_to_entry_parameter: Assertion `frame != NULL' failed. > ``` > > The reason for both of them is this kind of loop: > ``` > while (get_frame_type (frame) == INLINE_FRAME) > frame = get_prev_frame (frame); > ``` > Since get_prev_frame respects the backtrace limit, it will return > NULL, and from there on you can't continue. > This changes these loops to use get_prev_frame_always instead, so > you always get a non-inline frame in the end. > > With this backtrace works: > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fd4162a in inline_frame (i=0) at gdb-29865.c:9 > (gdb) > ``` > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29865 > --- > gdb/dwarf2/frame.c | 2 +- > gdb/dwarf2/loc.c | 2 +- > gdb/testsuite/gdb.opt/inline-bt.c | 8 ++++---- > gdb/testsuite/gdb.opt/inline-bt.exp | 1 + > 4 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c > index d3d1ecdf1f5..143b934e5ef 100644 > --- a/gdb/dwarf2/frame.c > +++ b/gdb/dwarf2/frame.c > @@ -1423,7 +1423,7 @@ dwarf2_frame_cfa (frame_info_ptr this_frame) > _("cfa not available for record btrace target")); > > while (get_frame_type (this_frame) == INLINE_FRAME) > - this_frame = get_prev_frame (this_frame); > + this_frame = get_prev_frame_always (this_frame); > if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE) > throw_error (NOT_AVAILABLE_ERROR, > _("can't compute CFA for this frame: " > diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c > index c15221eb7a2..b1f188bf9c5 100644 > --- a/gdb/dwarf2/loc.c > +++ b/gdb/dwarf2/loc.c > @@ -1156,7 +1156,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, > > while (get_frame_type (frame) == INLINE_FRAME) > { > - frame = get_prev_frame (frame); > + frame = get_prev_frame_always (frame); > gdb_assert (frame != NULL); > } > > diff --git a/gdb/testsuite/gdb.opt/inline-bt.c b/gdb/testsuite/gdb.opt/inline-bt.c > index 8dac8d30300..0dad0f47e6e 100644 > --- a/gdb/testsuite/gdb.opt/inline-bt.c > +++ b/gdb/testsuite/gdb.opt/inline-bt.c > @@ -28,15 +28,15 @@ volatile int result; > > void bar(void); > > -inline ATTR int func1(void) > +inline ATTR int func1(int s) > { > bar (); > - return x * y; > + return x * y + s; > } > > inline ATTR int func2(void) > { > - return x * func1 (); > + return x * func1 (1); > } > > int main (void) > @@ -47,7 +47,7 @@ int main (void) > y = 8; > bar (); > > - val = func1 (); > + val = func1 (2); > result = val; > > val = func2 (); > diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp > index 501b24109e3..b0e5f61a5c7 100644 > --- a/gdb/testsuite/gdb.opt/inline-bt.exp > +++ b/gdb/testsuite/gdb.opt/inline-bt.exp > @@ -65,3 +65,4 @@ gdb_test "up" "#1 .*func1.*" "up from bar (4)" > gdb_test "info frame" ".*in func1.*" "info frame still works" > # Verify the user visible limit works as expected. > gdb_test "up" "Initial frame selected; you cannot go up." "up hits limit" > +gdb_test "backtrace" "#0 bar.*#1 .*func1.*" "backtrace hits limit" ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PING] [PATCH] Fix backtrace limit stopping on inline frame 2024-01-17 16:05 ` [PING] " Hannes Domani @ 2024-01-26 17:05 ` Hannes Domani 0 siblings, 0 replies; 5+ messages in thread From: Hannes Domani @ 2024-01-26 17:05 UTC (permalink / raw) To: gdb-patches Ping. Am Mittwoch, 17. Januar 2024, 17:06:12 MEZ hat Hannes Domani <ssbssa@yahoo.de> Folgendes geschrieben: > Ping. > > > On 06.01.2024 15:17, Hannes Domani wrote: > > If you have set up a backtrace limit, and the backtrace stops > > because of this in an inline frame with arguments, you get an > > assertion failure: > > ``` > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fe3162a in inline_frame (i=0) at gdb-29865.c:9 > > #2 main () at gdb-29865.c:14 > > (gdb) set backtrace limit 2 > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fe3162a in inline_frame ( > > C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed. > > ``` > > > > And if this one if fixed, there is another one as well: > > ``` > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fdf162a in inline_frame ( > > C:/src/repos/binutils-gdb.git/gdb/dwarf2/loc.c:1160: internal-error: dwarf_expr_reg_to_entry_parameter: Assertion `frame != NULL' failed. > > ``` > > > > The reason for both of them is this kind of loop: > > ``` > > while (get_frame_type (frame) == INLINE_FRAME) > > frame = get_prev_frame (frame); > > ``` > > Since get_prev_frame respects the backtrace limit, it will return > > NULL, and from there on you can't continue. > > This changes these loops to use get_prev_frame_always instead, so > > you always get a non-inline frame in the end. > > > > With this backtrace works: > > ``` > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fd4162a in inline_frame (i=0) at gdb-29865.c:9 > > (gdb) > > ``` > > > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29865 > > --- > > gdb/dwarf2/frame.c | 2 +- > > gdb/dwarf2/loc.c | 2 +- > > gdb/testsuite/gdb.opt/inline-bt.c | 8 ++++---- > > gdb/testsuite/gdb.opt/inline-bt.exp | 1 + > > 4 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c > > index d3d1ecdf1f5..143b934e5ef 100644 > > --- a/gdb/dwarf2/frame.c > > +++ b/gdb/dwarf2/frame.c > > @@ -1423,7 +1423,7 @@ dwarf2_frame_cfa (frame_info_ptr this_frame) > > _("cfa not available for record btrace target")); > > > > while (get_frame_type (this_frame) == INLINE_FRAME) > > - this_frame = get_prev_frame (this_frame); > > + this_frame = get_prev_frame_always (this_frame); > > if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE) > > throw_error (NOT_AVAILABLE_ERROR, > > _("can't compute CFA for this frame: " > > diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c > > index c15221eb7a2..b1f188bf9c5 100644 > > --- a/gdb/dwarf2/loc.c > > +++ b/gdb/dwarf2/loc.c > > @@ -1156,7 +1156,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, > > > > while (get_frame_type (frame) == INLINE_FRAME) > > { > > - frame = get_prev_frame (frame); > > + frame = get_prev_frame_always (frame); > > gdb_assert (frame != NULL); > > } > > > > diff --git a/gdb/testsuite/gdb.opt/inline-bt.c b/gdb/testsuite/gdb.opt/inline-bt.c > > index 8dac8d30300..0dad0f47e6e 100644 > > --- a/gdb/testsuite/gdb.opt/inline-bt.c > > +++ b/gdb/testsuite/gdb.opt/inline-bt.c > > @@ -28,15 +28,15 @@ volatile int result; > > > > void bar(void); > > > > -inline ATTR int func1(void) > > +inline ATTR int func1(int s) > > { > > bar (); > > - return x * y; > > + return x * y + s; > > } > > > > inline ATTR int func2(void) > > { > > - return x * func1 (); > > + return x * func1 (1); > > } > > > > int main (void) > > @@ -47,7 +47,7 @@ int main (void) > > y = 8; > > bar (); > > > > - val = func1 (); > > + val = func1 (2); > > result = val; > > > > val = func2 (); > > diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp > > index 501b24109e3..b0e5f61a5c7 100644 > > --- a/gdb/testsuite/gdb.opt/inline-bt.exp > > +++ b/gdb/testsuite/gdb.opt/inline-bt.exp > > @@ -65,3 +65,4 @@ gdb_test "up" "#1 .*func1.*" "up from bar (4)" > > gdb_test "info frame" ".*in func1.*" "info frame still works" > > # Verify the user visible limit works as expected. > > gdb_test "up" "Initial frame selected; you cannot go up." "up hits limit" > > +gdb_test "backtrace" "#0 bar.*#1 .*func1.*" "backtrace hits limit" ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix backtrace limit stopping on inline frame 2024-01-06 14:17 ` [PATCH] Fix backtrace limit stopping on inline frame Hannes Domani 2024-01-17 16:05 ` [PING] " Hannes Domani @ 2024-01-29 10:55 ` Andrew Burgess 2024-01-29 14:35 ` Hannes Domani 1 sibling, 1 reply; 5+ messages in thread From: Andrew Burgess @ 2024-01-29 10:55 UTC (permalink / raw) To: Hannes Domani, gdb-patches Hannes Domani <ssbssa@yahoo.de> writes: > If you have set up a backtrace limit, and the backtrace stops > because of this in an inline frame with arguments, you get an > assertion failure: > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fe3162a in inline_frame (i=0) at gdb-29865.c:9 > #2 main () at gdb-29865.c:14 > (gdb) set backtrace limit 2 > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fe3162a in inline_frame ( > C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed. > ``` > > And if this one if fixed, there is another one as well: s/one if fixed/one is fixed/. Otherwise, looks good. Thanks for fixing this. Approved-By: Andrew Burgess <aburgess@redhat.com> Thanks, Andrew > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fdf162a in inline_frame ( > C:/src/repos/binutils-gdb.git/gdb/dwarf2/loc.c:1160: internal-error: dwarf_expr_reg_to_entry_parameter: Assertion `frame != NULL' failed. > ``` > > The reason for both of them is this kind of loop: > ``` > while (get_frame_type (frame) == INLINE_FRAME) > frame = get_prev_frame (frame); > ``` > Since get_prev_frame respects the backtrace limit, it will return > NULL, and from there on you can't continue. > This changes these loops to use get_prev_frame_always instead, so > you always get a non-inline frame in the end. > > With this backtrace works: > ``` > (gdb) bt > #0 normal_frame (i=0) at gdb-29865.c:4 > #1 0x000000013fd4162a in inline_frame (i=0) at gdb-29865.c:9 > (gdb) > ``` > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29865 > --- > gdb/dwarf2/frame.c | 2 +- > gdb/dwarf2/loc.c | 2 +- > gdb/testsuite/gdb.opt/inline-bt.c | 8 ++++---- > gdb/testsuite/gdb.opt/inline-bt.exp | 1 + > 4 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c > index d3d1ecdf1f5..143b934e5ef 100644 > --- a/gdb/dwarf2/frame.c > +++ b/gdb/dwarf2/frame.c > @@ -1423,7 +1423,7 @@ dwarf2_frame_cfa (frame_info_ptr this_frame) > _("cfa not available for record btrace target")); > > while (get_frame_type (this_frame) == INLINE_FRAME) > - this_frame = get_prev_frame (this_frame); > + this_frame = get_prev_frame_always (this_frame); > if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE) > throw_error (NOT_AVAILABLE_ERROR, > _("can't compute CFA for this frame: " > diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c > index c15221eb7a2..b1f188bf9c5 100644 > --- a/gdb/dwarf2/loc.c > +++ b/gdb/dwarf2/loc.c > @@ -1156,7 +1156,7 @@ dwarf_expr_reg_to_entry_parameter (frame_info_ptr frame, > > while (get_frame_type (frame) == INLINE_FRAME) > { > - frame = get_prev_frame (frame); > + frame = get_prev_frame_always (frame); > gdb_assert (frame != NULL); > } > > diff --git a/gdb/testsuite/gdb.opt/inline-bt.c b/gdb/testsuite/gdb.opt/inline-bt.c > index 8dac8d30300..0dad0f47e6e 100644 > --- a/gdb/testsuite/gdb.opt/inline-bt.c > +++ b/gdb/testsuite/gdb.opt/inline-bt.c > @@ -28,15 +28,15 @@ volatile int result; > > void bar(void); > > -inline ATTR int func1(void) > +inline ATTR int func1(int s) > { > bar (); > - return x * y; > + return x * y + s; > } > > inline ATTR int func2(void) > { > - return x * func1 (); > + return x * func1 (1); > } > > int main (void) > @@ -47,7 +47,7 @@ int main (void) > y = 8; > bar (); > > - val = func1 (); > + val = func1 (2); > result = val; > > val = func2 (); > diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp > index 501b24109e3..b0e5f61a5c7 100644 > --- a/gdb/testsuite/gdb.opt/inline-bt.exp > +++ b/gdb/testsuite/gdb.opt/inline-bt.exp > @@ -65,3 +65,4 @@ gdb_test "up" "#1 .*func1.*" "up from bar (4)" > gdb_test "info frame" ".*in func1.*" "info frame still works" > # Verify the user visible limit works as expected. > gdb_test "up" "Initial frame selected; you cannot go up." "up hits limit" > +gdb_test "backtrace" "#0 bar.*#1 .*func1.*" "backtrace hits limit" > -- > 2.35.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix backtrace limit stopping on inline frame 2024-01-29 10:55 ` Andrew Burgess @ 2024-01-29 14:35 ` Hannes Domani 0 siblings, 0 replies; 5+ messages in thread From: Hannes Domani @ 2024-01-29 14:35 UTC (permalink / raw) To: gdb-patches, Andrew Burgess Am Montag, 29. Januar 2024 um 11:55:14 MEZ hat Andrew Burgess <aburgess@redhat.com> Folgendes geschrieben: > Hannes Domani <ssbssa@yahoo.de> writes: > > > If you have set up a backtrace limit, and the backtrace stops > > because of this in an inline frame with arguments, you get an > > assertion failure: > > ``` > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fe3162a in inline_frame (i=0) at gdb-29865.c:9 > > #2 main () at gdb-29865.c:14 > > (gdb) set backtrace limit 2 > > (gdb) bt > > #0 normal_frame (i=0) at gdb-29865.c:4 > > #1 0x000000013fe3162a in inline_frame ( > > C:/src/repos/binutils-gdb.git/gdb/frame.c:3346: internal-error: reinflate: Assertion `m_cached_level >= -1' failed. > > ``` > > > > And if this one if fixed, there is another one as well: > > s/one if fixed/one is fixed/. > > Otherwise, looks good. Thanks for fixing this. > > Approved-By: Andrew Burgess <aburgess@redhat.com> Pushed with this typo fixed, thanks. Hannes ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-29 14:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20240106141735.2330-1-ssbssa.ref@yahoo.de> 2024-01-06 14:17 ` [PATCH] Fix backtrace limit stopping on inline frame Hannes Domani 2024-01-17 16:05 ` [PING] " Hannes Domani 2024-01-26 17:05 ` Hannes Domani 2024-01-29 10:55 ` Andrew Burgess 2024-01-29 14:35 ` Hannes Domani
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).