From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 4943838708D5 for ; Thu, 27 Aug 2020 20:57:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4943838708D5 X-ASG-Debug-ID: 1598561846-0c856e180d6536c0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 08SlqmTbL3eMqKOE (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Aug 2020 16:57:26 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by smtp.ebox.ca (Postfix) with ESMTP id 97290441D66; Thu, 27 Aug 2020 16:57:26 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 173.246.6.90 X-Barracuda-Effective-Source-IP: 173-246-6-90.qc.cable.ebox.net[173.246.6.90] X-Barracuda-Apparent-Source-IP: 173.246.6.90 To: gdb-patches@sourceware.org Cc: Zoran.Zaric@amd.com, Tony.Tye@amd.com, Scott.Linder@amd.com, Simon Marchi Subject: [PATCH v2 2/3] gdb: introduce explicit outer frame id kind Date: Thu, 27 Aug 2020 16:57:23 -0400 X-ASG-Orig-Subj: [PATCH v2 2/3] gdb: introduce explicit outer frame id kind Message-Id: <20200827205724.409603-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200827205724.409603-1-simon.marchi@polymtl.ca> References: <20200827205724.409603-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1598561846 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 5064 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.84209 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2020 20:57:39 -0000 From: Simon Marchi In the following patch, we'll need to easily differentiate the frame_id of the outer frame (or the frame id of a frame inlined into the outer frame) from a simply invalid frame id. Currently, the frame id of the outer frame has `stack_status` set to FID_STACK_INVALID plus special_addr_p set. A frame inlined into the outer frame would also have `artificial_depth` set to greater than one. That makes the job of differntiating the frame id of the outer frame (or a frame inlined into the outer frame) cumbersome. To make it easier, give the outer frame id its own frame_id_stack_status enum value. outer_frame_id then becomes very similar to sentinel_frame_id, another "special" frame id value. In frame_id_p, we don't need a special case for the outer frame id, as it's no long a special case of FID_STACK_INVALID. Same goes for frame_id_eq. So in the end, FID_STACK_OUTER isn't even used (except in fprint_frame_id). But that's expected: all the times we wanted to identify an outer frame was to differentiate it from an otherwise invalid frame. Since their frame_id_stack_status value is different now, that is done naturally. gdb/ChangeLog: * frame.h (enum frame_id_stack_status) : New. * frame.c (fprint_frame_id): Handle FID_STACK_OUTER. (outer_frame_id): Use FID_STACK_OUTER instead of FID_STACK_INVALID. (frame_id_p): Don't check for outer_frame_id. Change-Id: I654e7f936349debc4f04f7f684b15e71a0c37619 --- gdb/frame.c | 19 +++++-------------- gdb/frame.h | 9 +++++++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index ccaf97dc7e91..54f4c613c9e8 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -396,8 +396,11 @@ fprint_frame_id (struct ui_file *file, struct frame_id id) fprintf_unfiltered (file, "stack="); else if (id.stack_status == FID_STACK_SENTINEL) fprintf_unfiltered (file, "stack="); + else if (id.stack_status == FID_STACK_OUTER) + fprintf_unfiltered (file, "stack="); else fprintf_unfiltered (file, "stack=%s", hex_string (id.stack_addr)); + fprintf_unfiltered (file, ","); fprint_field (file, "code", id.code_addr_p, id.code_addr); @@ -672,7 +675,7 @@ frame_unwind_caller_id (struct frame_info *next_frame) const struct frame_id null_frame_id = { 0 }; /* All zeros. */ const struct frame_id sentinel_frame_id = { 0, 0, 0, FID_STACK_SENTINEL, 0, 1, 0 }; -const struct frame_id outer_frame_id = { 0, 0, 0, FID_STACK_INVALID, 0, 1, 0 }; +const struct frame_id outer_frame_id = { 0, 0, 0, FID_STACK_OUTER, 0, 1, 0 }; struct frame_id frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr, @@ -746,10 +749,6 @@ frame_id_p (frame_id l) /* The frame is valid iff it has a valid stack address. */ bool p = l.stack_status != FID_STACK_INVALID; - /* outer_frame_id is also valid. */ - if (!p && memcmp (&l, &outer_frame_id, sizeof (l)) == 0) - p = true; - if (frame_debug) { fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l="); @@ -774,15 +773,7 @@ frame_id_eq (frame_id l, frame_id r) { bool eq; - if (l.stack_status == FID_STACK_INVALID && l.special_addr_p - && r.stack_status == FID_STACK_INVALID && r.special_addr_p) - /* The outermost frame marker is equal to itself. This is the - dodgy thing about outer_frame_id, since between execution steps - we might step into another function - from which we can't - unwind either. More thought required to get rid of - outer_frame_id. */ - eq = true; - else if (l.stack_status == FID_STACK_INVALID + if (l.stack_status == FID_STACK_INVALID || r.stack_status == FID_STACK_INVALID) /* Like a NaN, if either ID is invalid, the result is false. Note that a frame ID is invalid iff it is the null frame ID. */ diff --git a/gdb/frame.h b/gdb/frame.h index 1c6afad1ae95..3ceb7b32effa 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -85,8 +85,7 @@ struct frame_print_options; enum frame_id_stack_status { - /* Stack address is invalid. E.g., this frame is the outermost - (i.e., _start), and the stack hasn't been setup yet. */ + /* Stack address is invalid. */ FID_STACK_INVALID = 0, /* Stack address is valid, and is found in the stack_addr field. */ @@ -95,6 +94,12 @@ enum frame_id_stack_status /* Sentinel frame. */ FID_STACK_SENTINEL = 2, + /* Outer frame. Since a frame's stack address is typically defined as the + value the stack pointer had prior to the activation of the frame, an outer + frame doesn't have a stack address. The frame ids of frames inlined in the + outer frame are also of this type. */ + FID_STACK_OUTER = 3, + /* Stack address is unavailable. I.e., there's a valid stack, but we don't know where it is (because memory or registers we'd compute it from were not collected). */ -- 2.28.0