From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 9B8E338582BC; Mon, 20 Feb 2023 11:20:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B8E338582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676892014; bh=oL+qbnM65Pp25bS2y0MkKxMzIdQz3uG7PqckP8GdCYc=; h=From:To:Subject:Date:From; b=MYZNtiSGa+WPy0dOdXewa12HeV6Za2hYeb0K79ROEBDA2GvzwGrcSxBa4w+ZdZw6S SwWxRgwpGa6OpQx0LSlrZapC4EFFqAiydJuukfKY2AkvHMsnPs6TS3ZSeePa8Kv92V QHQUutL3pgryw8R31+eRVu8SVMdXf0P5acCkcvFg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: cb911672fb70233f3ef127f68fc0a43d7f339a62 X-Git-Newrev: 2f9f989c2b61d6556f01b2d80004f6abff46e4a3 Message-Id: <20230220112014.9B8E338582BC@sourceware.org> Date: Mon, 20 Feb 2023 11:20:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2f9f989c2b61= d6556f01b2d80004f6abff46e4a3 commit 2f9f989c2b61d6556f01b2d80004f6abff46e4a3 Author: Tom de Vries Date: Mon Feb 20 12:20:14 2023 +0100 [gdb/tdep] Fix amd64/i386_stack_frame_destroyed_p =20 The use of compunit_epilogue_unwind_valid in both amd64_stack_frame_des= troyed_p and i386_stack_frame_destroyed_p is problematic, in the sense that the functions no longer match their documented behaviour. =20 Fix this by moving the use of compunit_epilogue_unwind_valid to amd64_epilogue_frame_sniffer and i386_epilogue_frame_sniffer. No funct= ional changes. Diff: --- gdb/amd64-tdep.c | 19 ++++++++++++------- gdb/i386-tdep.c | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 08f906be123..75ab1b23ccf 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2903,9 +2903,6 @@ amd64_stack_frame_destroyed_p (struct gdbarch *gdbarc= h, CORE_ADDR pc) { gdb_byte insn; =20 - if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc))) - return 0; - if (target_read_memory (pc, &insn, 1)) return 0; /* Can't read memory at pc. */ =20 @@ -2920,11 +2917,19 @@ amd64_epilogue_frame_sniffer (const struct frame_un= wind *self, frame_info_ptr this_frame, void **this_prologue_cache) { - if (frame_relative_level (this_frame) =3D=3D 0) - return amd64_stack_frame_destroyed_p (get_frame_arch (this_frame), - get_frame_pc (this_frame)); - else + struct gdbarch *gdbarch =3D get_frame_arch (this_frame); + CORE_ADDR pc =3D get_frame_pc (this_frame); + + if (frame_relative_level (this_frame) !=3D 0) + /* We're not in the inner frame, so assume we're not in an epilogue. = */ return 0; + + if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc))) + /* Don't override the symtab unwinders. */ + return 0; + + /* Check whether we're in an epilogue. */ + return amd64_stack_frame_destroyed_p (gdbarch, pc); } =20 static struct amd64_frame_cache * diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 19358ca66b9..032fcc4dd76 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2219,10 +2219,6 @@ static int i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) { gdb_byte insn; - - if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc))) - return 0; - if (target_read_memory (pc, &insn, 1)) return 0; /* Can't read memory at pc. */ =20 @@ -2237,11 +2233,19 @@ i386_epilogue_frame_sniffer (const struct frame_unw= ind *self, frame_info_ptr this_frame, void **this_prologue_cache) { - if (frame_relative_level (this_frame) =3D=3D 0) - return i386_stack_frame_destroyed_p (get_frame_arch (this_frame), - get_frame_pc (this_frame)); - else + struct gdbarch *gdbarch =3D get_frame_arch (this_frame); + CORE_ADDR pc =3D get_frame_pc (this_frame); + + if (frame_relative_level (this_frame) !=3D 0) + /* We're not in the inner frame, so assume we're not in an epilogue. = */ + return 0; + + if (compunit_epilogue_unwind_valid (find_pc_compunit_symtab (pc))) + /* Don't override the symtab unwinders. */ return 0; + + /* Check whether we're in an epilogue. */ + return i386_stack_frame_destroyed_p (gdbarch, pc); } =20 static struct i386_frame_cache *