Created attachment 6407 [details] preprocessed source Hi, I compiled coreutils' src/id.c using F17's gcc (gcc-4.7.0-4.fc17.x86_64 -- same result when using today's gcc snapshot) with CFLAGS='-ggdb3 -O1', then ran this gdb on the binary: $ rpm -q gdb gdb-7.4.50.20120120-42.fc17.x86_64 $ gdb src/id Reading symbols from /h/j/w/co/cu/src/id...done. (gdb) b main Breakpoint 1 at 0x401a00: file id.c, line 107. (gdb) r Starting program: /h/j/w/co/cu/src/id Breakpoint 1, main (argc=1, argv=0x7fffffffd9f8) at id.c:107 107 { (gdb) watch context Hardware watchpoint 2: context (gdb) c Continuing. Hardware watchpoint 2: context Old value = (security_context_t) 0x0 New value = (security_context_t) 0x6080a0 "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023" selinux_raw_to_trans_context_internal ( raw=0x6090b0 "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", transp=transp@entry=0x6075b0) at setrans_client.c:347 347 if (*transp) { (gdb) fin Run till exit from #0 selinux_raw_to_trans_context_internal ( raw=0x6090b0 "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", transp=transp@entry=0x6075b0) at setrans_client.c:347 getprocattrcon (context=context@entry=0x6075b0, pid=pid@entry=0, attr=attr@entry=0x3135e17293 "current") at procattr.c:84 84 freecon(rcontext); Value returned is $1 = 0 (gdb) fin Run till exit from #0 getprocattrcon (context=context@entry=0x6075b0, pid=pid@entry=0, attr=attr@entry=0x3135e17293 "current") at procattr.c:84 ../../gdb/breakpoint.c:7207: internal-error: set_momentary_breakpoint: Assertion `!frame_id_inlined_p (frame_id)' failed. A problem internal to GDB has been detected, further debugging may prove unreliable.
Worked in 7.3, fails in 7.4+
The fundamental issue here is that frame_id_inlined_p and skip_inline_frames disagree about whether a tailcall frame is "inlined".
Created attachment 6579 [details] patch for testing I'm testing this patch. It works on the original test case. I'm not really convinced this is correct, though.
I believe 'finish' should step out of inlined frames one frame at a time. The same like 'step' steps in one frame at a time, also without changing PC. The same should apply to tailcall frames (just step-in is irrelevant for them). In general GDB should behave for -O2 -g inferior as much the same as to the same inferior built with -O0 -g.
(In reply to comment #4) > I believe 'finish' should step out of inlined frames one frame at a time. > The same like 'step' steps in one frame at a time, also without changing PC. > The same should apply to tailcall frames (just step-in is irrelevant for them). I wouldn't mind it, but I don't plan to do it myself. I think perhaps the fix here ought to just ignore tailcall frames rather than both tail- and inlined- frames.
[patch+7.5?] Fix GDB-return into TAILCALL_FRAME (PR 14119) http://sourceware.org/ml/gdb-patches/2012-09/msg00218.html
CVSROOT: /cvs/src Module name: src Changes by: jkratoch@sourceware.org 2012-09-17 07:15:48 Modified files: gdb : ChangeLog frame.c infcmd.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.arch: amd64-tailcall-ret.S amd64-tailcall-ret.c amd64-tailcall-ret.exp gdb/testsuite/gdb.reverse: amd64-tailcall-reverse.S amd64-tailcall-reverse.c amd64-tailcall-reverse.exp Log message: gdb/ PR 14119 * frame.c (skip_inlined_frames): Skip also TAILCALL_FRAME frames. (frame_pop): Drop also TAILCALL_FRAME frames. * infcmd.c (finish_command): Ignore also TAILCALL_FRAME frames. gdb/testsuite/ PR 14119 * gdb.arch/amd64-tailcall-ret.S: New file. * gdb.arch/amd64-tailcall-ret.c: New file. * gdb.arch/amd64-tailcall-ret.exp: New file. * gdb.reverse/amd64-tailcall-reverse.S: New file. * gdb.reverse/amd64-tailcall-reverse.c: New file. * gdb.reverse/amd64-tailcall-reverse.exp: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.14663&r2=1.14664 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/frame.c.diff?cvsroot=src&r1=1.309&r2=1.310 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/infcmd.c.diff?cvsroot=src&r1=1.312&r2=1.313 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3375&r2=1.3376 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.S.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.S.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.c.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp.diff?cvsroot=src&r1=NONE&r2=1.1
CVSROOT: /cvs/src Module name: src Branch: gdb_7_5-branch Changes by: jkratoch@sourceware.org 2012-09-17 07:17:28 Modified files: gdb : ChangeLog frame.c infcmd.c gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.arch: amd64-tailcall-ret.S amd64-tailcall-ret.c amd64-tailcall-ret.exp gdb/testsuite/gdb.reverse: amd64-tailcall-reverse.S amd64-tailcall-reverse.c amd64-tailcall-reverse.exp Log message: gdb/ PR 14119 * frame.c (skip_inlined_frames): Skip also TAILCALL_FRAME frames. (frame_pop): Drop also TAILCALL_FRAME frames. * infcmd.c (finish_command): Ignore also TAILCALL_FRAME frames. gdb/testsuite/ PR 14119 * gdb.arch/amd64-tailcall-ret.S: New file. * gdb.arch/amd64-tailcall-ret.c: New file. * gdb.arch/amd64-tailcall-ret.exp: New file. * gdb.reverse/amd64-tailcall-reverse.S: New file. * gdb.reverse/amd64-tailcall-reverse.c: New file. * gdb.reverse/amd64-tailcall-reverse.exp: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.14469.2.32&r2=1.14469.2.33 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/frame.c.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.306&r2=1.306.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/infcmd.c.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.306&r2=1.306.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=1.3295.2.22&r2=1.3295.2.23 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.S.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.c.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.S.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.c.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp.diff?cvsroot=src&only_with_tag=gdb_7_5-branch&r1=NONE&r2=1.1.2.1
Checked in for 7.5.1.