From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id 3E9113857C4D for ; Tue, 18 Aug 2020 10:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E9113857C4D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x444.google.com with SMTP id r2so17754624wrs.8 for ; Tue, 18 Aug 2020 03:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OXPHNzOu9bN5+kQhMYbBaTlCYvMKpGfYu2xVPuXSYCU=; b=MDqjAC7LzuRZnGO5D5A6FkqQkT+saKEjavE4yexNUbiRQ/sb/MJ3jLvwU6qAgjBfgj eIUOLPI/AXGVeFS5PvP9GsihDFY3CuSc/uOhLPepVnLFqhe5xZ98T68LNMMNjKQRz+RY 4mR0Kj8B/ez8BDfsnFSPeTYAr9o+Bd7YMBg23SRRlviw3M+BGxqdUF4+9aaplYuokI9Q dwWwgWmriEx9puWMWzoWoTTQvTHi3a1smWtgc6OnzEWpo9VRxqRpcl/2OhKT0EGQEfJV HavXZEk1qbZylX5N/2J5ivBAhE3YBTAen6B7Gf0SNSTKO7niGNo4L/QnTwjnooLsdYpS xevg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OXPHNzOu9bN5+kQhMYbBaTlCYvMKpGfYu2xVPuXSYCU=; b=l83jnoLu/p9qMHEsZnitEAAEJTHYBSL6ojvc43WWAoCQITCwlczvwBndchr788rw2z ayko0RjS81IEbZP8xfj9da+sPSrHdz62CKUc3knAdePkWIzR3fz+ewN1uXkRvPvNCU1V zkHhG6Nzgorq5uaRS+V6UCewqcl4hF7QTKYVgZ7rhv6xv7orf5/G2zOio8RqIqK30Vcw hoHL3IVuFTulYp9YiFJXGfuS0/WRQE6bKvy4BVeLEtJFbIrDUpyhM8diX194KkXjGyRS l0GAHUeBNt7bJJCVArmZIcJfkNRFqLCekL487AKXIBa5ORH3zjyFiGxbVj2nDSZyQq02 FEUg== X-Gm-Message-State: AOAM5325C4F0lwMDNBh6R/oFa4ahtpTiDHovw3M+QWiDYEZk32rFMu0f me3eqskY+y7PphPui95Jjy07FA== X-Google-Smtp-Source: ABdhPJxFrTN9ERqhBtAqCDP97T9Sv1DidtvQfi7ddVj6YfMWiQu2bKJzqN8pv/JnqjtGRV//h3Ds0g== X-Received: by 2002:a05:6000:118c:: with SMTP id g12mr19361231wrx.212.1597746545138; Tue, 18 Aug 2020 03:29:05 -0700 (PDT) Received: from localhost (host86-130-161-98.range86-130.btcentralplus.com. [86.130.161.98]) by smtp.gmail.com with ESMTPSA id y84sm33844549wmg.38.2020.08.18.03.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 03:29:04 -0700 (PDT) Date: Tue, 18 Aug 2020 11:29:03 +0100 From: Andrew Burgess To: "Sharma, Alok Kumar" Cc: "gdb-patches@sourceware.org" , "George, Jini Susan" , "Achra, Nitika" Subject: Re: [PATCH] Fix for incorrect breakpoint set in case of flang compiled binary Message-ID: <20200818102903.GL853475@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.6.15-200.fc31.x86_64 (x86_64) X-Uptime: 11:23:44 up 30 days, 19:38, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Tue, 18 Aug 2020 10:29:07 -0000 * Sharma, Alok Kumar [2020-08-17 15:17:02 +0000]: > Hi All, > > I request you all to please review this patch. Below are the details. > > Problem Description: > Currently, GDB is not able to set a breakpoint at subprogram post > prologue for flang generated binaries. This is due to clang having > two line notes one before and another after the prologue. > Resolution: > Now the end of prologue is determined using symbol table, which was > the way for clang generated binaries already. Since clang and flang > both share same back-end it is true for flang as well. > > gdb/ChangeLog > > * amd64-tdep.c (amd64_skip_prologue): Using symbol table > to find the end of prologue for flang compiled binaries. > * arm-tdep.c (arm_skip_prologue): Likewise. > * i386-tdep.c (i386_skip_prologue): Likewise. > > gdb/testsuite/ChangeLog > > * gdb.fortran/vla-type.exp: Skip commands not required for > the Flang compiled binaries after prologue fix. > > Regards, > Alok > > > From 6f578b992c789196478742b71af6b75fb76573f3 Mon Sep 17 00:00:00 2001 > From: Alok Kumar Sharma > Date: Mon, 17 Aug 2020 17:04:11 +0530 > Subject: [PATCH] Fix for incorrect breakpoint set in case of flang compiled > binary > > Currently, GDB is not able to set a breakpoint at subprogram post > prologue for flang generated binaries. This is due to clang having > two line notes one before and another after the prologue. > Now the end of prologue is determined using symbol table, which was > the way for clang generated binaries already. Since clang and flang > both share same back-end it is true for flang as well. > > gdb/ChangeLog > > * amd64-tdep.c (amd64_skip_prologue): Using symbol table > to find the end of prologue for flang compiled binaries. > * arm-tdep.c (arm_skip_prologue): Likewise. > * i386-tdep.c (i386_skip_prologue): Likewise. > > gdb/testsuite/ChangeLog > > * gdb.fortran/vla-type.exp: Skip commands not required for > the Flang compiled binaries after prologue fix. > > Change-Id: I5609f979315effc213feeb6dde6a01a024e0c487 > --- > gdb/ChangeLog | 7 +++++++ > gdb/amd64-tdep.c | 5 +++-- > gdb/arm-tdep.c | 3 ++- > gdb/i386-tdep.c | 5 +++-- > gdb/testsuite/ChangeLog | 5 +++++ > gdb/testsuite/gdb.fortran/vla-type.exp | 8 ++++++-- > 6 files changed, 26 insertions(+), 7 deletions(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 3e733a73f0..3eb07cb5d0 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,10 @@ > +2020-08-14 Alok Kumar Sharma > + > + * amd64-tdep.c (amd64_skip_prologue): Using symbol table > + to find the end of prologue for flang compiled binaries. > + * arm-tdep.c (arm_skip_prologue): Likewise. > + * i386-tdep.c (i386_skip_prologue): Likewise. > + > 2020-08-17 Tom de Vries > > PR gdb/26393 > diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c > index 768fe63bdd..6f05f60548 100644 > --- a/gdb/amd64-tdep.c > +++ b/gdb/amd64-tdep.c > @@ -2547,12 +2547,13 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) > = skip_prologue_using_sal (gdbarch, func_addr); > struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr); > > - /* Clang always emits a line note before the prologue and another > + /* Clang/Flang always emit a line note before the prologue and another > one after. We trust clang to emit usable line notes. */ > if (post_prologue_pc > && (cust != NULL > && COMPUNIT_PRODUCER (cust) != NULL > - && startswith (COMPUNIT_PRODUCER (cust), "clang "))) > + && (startswith (COMPUNIT_PRODUCER (cust), "clang ") > + || startswith(COMPUNIT_PRODUCER(cust), " F90 Flang")))) > return std::max (start_pc, post_prologue_pc); We have the files producer.{c,h} that wrap up tests just like this one. If feels like we should add a new test to those files that matches all clang backend based compilers, then make use of this new test throughout. I'd keep the name of the test fairly generic, the important thing here is the backend technology right, not the frontend language? So if I added a new language with a clang backend I'd likely run into the same issues. Thanks, Andrew > } > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 9cedcc8575..27a8b519ed 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -1351,7 +1351,8 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) > && (cust == NULL > || COMPUNIT_PRODUCER (cust) == NULL > || startswith (COMPUNIT_PRODUCER (cust), "GNU ") > - || startswith (COMPUNIT_PRODUCER (cust), "clang "))) > + || startswith (COMPUNIT_PRODUCER (cust), "clang ") > + || startswith (COMPUNIT_PRODUCER (cust), " F90 Flang"))) > return post_prologue_pc; > > if (post_prologue_pc != 0) > diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c > index 9b905c1996..4c1cf3acd7 100644 > --- a/gdb/i386-tdep.c > +++ b/gdb/i386-tdep.c > @@ -1847,12 +1847,13 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) > = skip_prologue_using_sal (gdbarch, func_addr); > struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr); > > - /* Clang always emits a line note before the prologue and another > + /* Clang/Flang always emit a line note before the prologue and another > one after. We trust clang to emit usable line notes. */ > if (post_prologue_pc > && (cust != NULL > && COMPUNIT_PRODUCER (cust) != NULL > - && startswith (COMPUNIT_PRODUCER (cust), "clang "))) > + && (startswith (COMPUNIT_PRODUCER (cust), "clang ") > + || startswith (COMPUNIT_PRODUCER (cust), " F90 Flang")))) > return std::max (start_pc, post_prologue_pc); > } > > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index f0b7949fd6..9d6e42ad39 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,3 +1,8 @@ > +2020-08-14 Alok Kumar Sharma > + > + * gdb.fortran/vla-type.exp: Skip commands not required for > + the Flang compiled binaries after prologue fix. > + > 2020-08-16 Tom de Vries > > PR gdb/25350 > diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp > index 925c583edc..e2b8d71b4c 100755 > --- a/gdb/testsuite/gdb.fortran/vla-type.exp > +++ b/gdb/testsuite/gdb.fortran/vla-type.exp > @@ -33,8 +33,12 @@ set int [fortran_int4] > > # Check if not allocated VLA in type does not break > # the debugger when accessing it. > -gdb_breakpoint [gdb_get_line_number "before-allocated"] > -gdb_continue_to_breakpoint "before-allocated" > +# break main for Flang compiler already breaks here > +if ![test_compiler_info "clang-*"] { > + gdb_breakpoint [gdb_get_line_number "before-allocated"] > + gdb_continue_to_breakpoint "before-allocated" > +} > + > gdb_test "print twov" " = \\\( ivla1 = , ivla2 = \\\)" \ > "print twov before allocated" > gdb_test "print twov%ivla1" " = " \ > -- > 2.17.1