From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B8D4D3870891; Wed, 24 Feb 2021 09:50:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8D4D3870891 From: "andrew.burgess at embecosm dot com" To: gdb-prs@sourceware.org Subject: [Bug backtrace/27147] [GNU/Linux, sparc64] GDB is unable to print full stack trace (got "previous frame inner to this frame" errors) Date: Wed, 24 Feb 2021 09:50:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: backtrace X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andrew.burgess at embecosm dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 09:50:17 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27147 --- Comment #11 from Andrew Burgess --- The problem is that the registers that "go wrong" are part of frame #0, whi= ch are fetched when GDB first stops. As such they end up being fetched in a c= all tree that originates from the ::wait, like this: #0 sparc_supply_rwindow (regcache=3D0x10001187fa0, sp=3D8791798050576, reg= num=3D-1) at ../../src/gdb/sparc-tdep.c:1967 #1 0x000001000076171c in sparc64_supply_gregset (gregmap=3D0x10000be0b5c ,=20 regcache=3D0x10001187fa0, regnum=3D-1, gregs=3D0x7feffffd260) at ../../src/gdb/sparc64-tdep.c:1974 #2 0x0000010000751094 in sparc_fetch_inferior_registers (regcache=3D0x10001187fa0, regnum=3D80) at ../../src/gdb/sparc-nat.c:170 #3 0x00000100007593f8 in sparc64_linux_nat_target::fetch_registers ( this=3D0x10000fa0c40 , regcache=3D0x10001= 187fa0, regnum=3D80) at ../../src/gdb/sparc64-linux-nat.c:38 #4 0x0000010000813d30 in target_fetch_registers (regcache=3D0x10001187fa0, regno=3D80) at ../../src/gdb/target.c:3281 #5 0x00000100006a8194 in regcache::raw_update (this=3D0x10001187fa0, regnu= m=3D80) at ../../src/gdb/regcache.c:584 #6 0x00000100006a82cc in readable_regcache::raw_read (this=3D0x10001187fa0, regnum=3D80, buf=3D0x7feffffd7f0 "") at ../../src/gdb/regcache.c:598 #7 0x00000100006a88f0 in readable_regcache::cooked_read (this=3D0x10001187= fa0, regnum=3D80, buf=3D0x7feffffd7f0 "") at ../../src/gdb/regcache.c:690 #8 0x00000100006b1dc4 in readable_regcache::cooked_read (this=3D0x10001187fa0, regnum=3D80,=20 val=3D0x7feffffd978) at ../../src/gdb/regcache.c:777 #9 0x00000100006a907c in regcache_cooked_read_unsigned (regcache=3D0x10001187fa0, regnum=3D80, val=3D0x7feffffd978) at ../../src/gdb/regcache.c:791 #10 0x00000100006ab474 in regcache_read_pc (regcache=3D0x10001187fa0) at ../../src/gdb/regcache.c:1295 #11 0x0000010000507218 in save_stop_reason (lp=3D0x1000121f190) at ../../src/gdb/linux-nat.c:2612 #12 0x0000010000508ee0 in linux_nat_filter_event (lwpid=3D3400064, status= =3D1407) at ../../src/gdb/linux-nat.c:3049 #13 0x00000100005098ac in linux_nat_wait_1 (ptid=3D..., ourstatus=3D0x7feff= ffe920, target_options=3D...) at ../../src/gdb/linux-nat.c:3194 #14 0x000001000050aae0 in linux_nat_target::wait (this=3D0x10000fa0c40 , ptid=3D...,=20 ourstatus=3D0x7feffffe920, target_options=3D...) at ../../src/gdb/linux-nat.c:3432 #15 0x00000100007f810c in target_wait (ptid=3D..., status=3D0x7feffffe920, options=3D...) at ../../src/gdb/target.c:1994 #16 0x00000100004aba74 in do_target_wait_1 (inf=3D0x1000116b140, ptid=3D..., status=3D0x7feffffe920, options=3D...) at ../../src/gdb/infrun.c:3464 #17 0x00000100004abcb0 in operator() (__closure=3D0x7feffffe6a8, inf=3D0x1000116b140) at ../../src/gdb/infrun.c:3527 #18 0x00000100004ac0c4 in do_target_wait (wait_ptid=3D..., ecs=3D0x7feffffe= 8f8, options=3D...) at ../../src/gdb/infrun.c:3540 #19 0x00000100004ad1bc in fetch_inferior_event () at ../../src/gdb/infrun.c:3880 #20 0x0000010000484e60 in inferior_event_handler (event_type=3DINF_REG_EVEN= T) at ../../src/gdb/inf-loop.c:42 #21 0x00000100004be90c in infrun_async_inferior_event_handler (data=3D0x0) = at ../../src/gdb/infrun.c:9216 #22 0x000001000012e9bc in check_async_event_handlers () at ../../src/gdb/async-event.c:327 #23 0x0000010000ab3ed4 in gdb_do_one_event () at ../../src/gdbsupport/event-loop.cc:216 #24 0x0000010000541f78 in start_event_loop () at ../../src/gdb/main.c:348 #25 0x000001000054218c in captured_command_loop () at ../../src/gdb/main.c:= 408 #26 0x0000010000544794 in captured_main (data=3D0x7fefffff0a8) at ../../src/gdb/main.c:1242 #27 0x000001000054483c in gdb_main (args=3D0x7fefffff0a8) at ../../src/gdb/main.c:1257 #28 0x00000100000c1f14 in main (argc=3D4, argv=3D0x7fefffff468) at ../../src/gdb/gdb.c:32 When we go into the wait inferior_ptid is always set to null_ptid, which ma= kes sense, as we don't know which inferior will be giving us an event. It appe= ars that everything called from the wait, once we do know which inferior has stopped, still has inferior_ptid set to null_ptid. Having thought about my fix a little more I do wonder if we should move the setting of inferior_ptid further up the call stack. Given that inferior_pt= id does need to be set when making target_* calls, I'm tempted to say we should really set inferior_ptid possibly as early as the ::wait, once we have figu= red out which inferior the event is for. Have reviewed the test results, and it looks pretty good. Failures on spar= c64 dropped from 7k+ to ~1.5k. One further note, placing the error where I did (after the target read) has= an unfortunate effect that it prevents the target from stopping, here's a brok= en session: (gdb) b puts Breakpoint 1 at 0x108de4 (gdb) r Starting program: /home/aburgess/project/binutils-gdb/test/gdb-test.static= =20 failed to read target memory at 0x000007feffffeef0 (gdb) bt Selected thread is running. (gdb)=20 Obviously this isn't a problem once we fix the setting of inferior_ptid, bu= t it still feels kind of rubbish. I think a much better solution is: diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 4f9c679b55c..78f93b121c8 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1957,7 +1962,14 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum) { if (regnum =3D=3D i || regnum =3D=3D -1) { - target_read_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8); + if (target_read_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf= , 8) =3D=3D -1) + { + warning (_("failed to read 8 bytes of target memory at %s= for register %s"), + core_addr_to_string (sp + ((i - SPARC_L0_REGNUM)= * 8)), + gdbarch_register_name (gdbarch, i)); + regcache->raw_supply (i, nullptr); + continue; + } /* Handle StackGhost. */ if (i =3D=3D SPARC_I7_REGNUM) Now the register are just marked as unavailable. --=20 You are receiving this mail because: You are on the CC list for the bug.=