From: Andrew Burgess <andrew.burgess@embecosm.com>
To: "Sharma, Alok Kumar" <AlokKumar.Sharma@amd.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
"George, Jini Susan" <JiniSusan.George@amd.com>,
"Achra, Nitika" <Nitika.Achra@amd.com>
Subject: Re: [PATCH] Fix for incorrect breakpoint set in case of flang compiled binary
Date: Tue, 18 Aug 2020 11:29:03 +0100 [thread overview]
Message-ID: <20200818102903.GL853475@embecosm.com> (raw)
In-Reply-To: <DM5PR12MB1644DE2B0B657A79E1920A749E5F0@DM5PR12MB1644.namprd12.prod.outlook.com>
* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [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 <AlokKumar.Sharma@amd.com>
> 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 <AlokKumar.Sharma@amd.com>
> +
> + * 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 <tdevries@suse.de>
>
> 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 <AlokKumar.Sharma@amd.com>
> +
> + * gdb.fortran/vla-type.exp: Skip commands not required for
> + the Flang compiled binaries after prologue fix.
> +
> 2020-08-16 Tom de Vries <tdevries@suse.de>
>
> 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 = <not allocated>, ivla2 = <not allocated> \\\)" \
> "print twov before allocated"
> gdb_test "print twov%ivla1" " = <not allocated>" \
> --
> 2.17.1
next prev parent reply other threads:[~2020-08-18 10:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 15:17 Sharma, Alok Kumar
2020-08-17 20:51 ` Tom Tromey
2020-08-19 13:05 ` Andrew Burgess
2020-08-18 10:29 ` Andrew Burgess [this message]
2020-08-18 12:53 ` Sharma, Alok Kumar
2020-08-19 13:09 ` Andrew Burgess
2020-08-19 15:25 ` Sharma, Alok Kumar
2020-08-18 19:21 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200818102903.GL853475@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=AlokKumar.Sharma@amd.com \
--cc=JiniSusan.George@amd.com \
--cc=Nitika.Achra@amd.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox