Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Kumar N, Bhuvanendra via Gdb-patches" <gdb-patches@sourceware.org>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "George, Jini Susan" <JiniSusan.George@amd.com>,
	"Achra, Nitika" <Nitika.Achra@amd.com>,
	"Sharma, Alok Kumar" <AlokKumar.Sharma@amd.com>,
	"E, Nagajyothi" <Nagajyothi.E@amd.com>,
	"Tomar, Sourabh Singh" <SourabhSingh.Tomar@amd.com>
Subject: [PATCH] [gdb.base] Add additional next commands for clang-12 and above in foll-exec.exp
Date: Thu, 15 Apr 2021 19:37:13 +0000	[thread overview]
Message-ID: <DM5PR12MB1450FC4E5D49A1DA3040C2BF874D9@DM5PR12MB1450.namprd12.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6851 bytes --]

[AMD Official Use Only - Internal Distribution Only]

Hello All,

I request all of you to please review this patch. Below are the details.

Problem Description:
Following 8 test points started to fail after the clang patch(https://reviews.llvm.org/D91734).

FAIL: gdb.base/foll-exec.exp: step through execlp call
FAIL: gdb.base/foll-exec.exp: step after execlp call
FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
FAIL: gdb.base/foll-exec.exp: step through execl call
FAIL: gdb.base/foll-exec.exp: step after execl call
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

Resolution:


These comments in the clang patch(https://reviews.llvm.org/D91734) explain/address the issue :

". . .the test is trying to "next" over a function call; gcc attributes all parameter evaluation to the function name, while clang will attribute each parameter to its own location. And when the parameters span multiple source lines, the is_stmt heuristic kicks in, so we stop on each line with actual parameters.

This is not ideal IMO; I'd rather be more principled about (a) stop at every parameter, or (b) stop at no parameters. But without reworking how we do is_stmt, I think fiddling the test to do enough single-steps to actually get past the function call is okay."

After this clang patch, we can see additional .debug_line entries created while handling the function call and parameter evaluation as mentioned in the commit message. Hence to suit the new clang behavior, its suggested to modify the test case for clang-12 and above.

Thanks and Regards,
Bhuvan

Patch content inlined:

From b6c3646cdd40fae679131107a0b2be4ff5b9eae5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 00:18:07 +0530
Subject: [PATCH] [gdb.base] Additional next commands added for
clang-12 and above.

After this clang patch(https://reviews.llvm.org/D91734), 8 test points
started to FAIL in this test case. As mentioned in this PR,
"...this test is trying to "next" over a function call; gcc attributes
all parameter evaluation to the function name, while clang will attribute
each parameter to its own location. And when the parameters span across
multiple source lines, the is_stmt heuristic kicks in, so we stop on each
line with actual parameters...".
We can see additional .debug_line entries getting created after this clang
patch, hence the test case is modified accordingly to suit the new clang
behavior. This test case modification is required for clang-12 and above.

Line table: (before clang patch for the below code snippet) :
0x000000b0: 84 address += 8,  line += 2
            0x000000000020196a     42      3      1   0             0
0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000b2: 41 address += 3,  line += 5
            0x000000000020197e     47      3      1   0             0

Line table: (after clang patch for the below code snippet) :
0x000000b5: 84 address += 8,  line += 2
            0x0000000000201958     42     11      1   0             0
0x000000b6: 05 DW_LNS_set_column (4)
0x000000b8: 75 address += 7,  line += 1
            0x000000000020195f     43      4      1   0             0
0x000000b9: 05 DW_LNS_set_column (3)
0x000000bb: 73 address += 7,  line += -1
            0x0000000000201966     42      3      1   0             0
0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000bd: 4f address += 4,  line += 5
            0x000000000020197b     47      3      1   0             0

gdb.base/foll-exec.c test file snippet :
. . .
42   execlp (prog, /* tbreak-execlp */
43           prog,
44           "execlp arg1 from foll-exec",
45           (char *) 0);
46
47   printf ("foll-exec is about to execl(execd-prog)...\n");

Following 8 test points started to fail after the above clang patch.

FAIL: gdb.base/foll-exec.exp: step through execlp call
FAIL: gdb.base/foll-exec.exp: step after execlp call
FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
FAIL: gdb.base/foll-exec.exp: step through execl call
FAIL: gdb.base/foll-exec.exp: step after execl call
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

gdb/testsuite/ChangeLog:
        * gdb.base/foll-exec.exp: Additional next commands added for
        clang-12 and above.
---
gdb/testsuite/ChangeLog              |  5 +++++
gdb/testsuite/gdb.base/foll-exec.exp | 15 +++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 52b0752276..ad289c135d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16  Bhuvanendra Kumar  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
+
+        * gdb.base/foll-exec.exp: Additional next commands added for
+     clang-12 and above.
+
2021-02-12  Andrew Burgess  andrew.burgess@embecosm.com<mailto:andrew.burgess@embecosm.com>
      * gdb.fortran/allocated.exp: New file.
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 6d5e21f54d..8b1fa42db9 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -118,7 +118,14 @@ proc do_exec_tests {} {
    # We should stop in execd-program, at its first statement.
    #
    set execd_line [gdb_get_line_number "after-exec" $srcfile2]
-   send_gdb "next\n"
+   # Clang-12 and above will emit extra .debug_line entries when
+   # parameters span across multiple source lines, hence additional
+   # next commands were added.
+   if {[test_compiler_info {clang-1[2-9]-*}]} {
+       send_gdb "next 3\n"
+   } else {
+       send_gdb "next\n"
+   }
    gdb_expect {
      -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int  local_j = argc;.*$gdb_prompt $"\
                      {pass "step through execlp call"}
@@ -269,7 +276,11 @@ proc do_exec_tests {} {
    # the newly-exec'd program, not after the remaining step-count
    # reaches zero.
    #
-   send_gdb "next 2\n"
+   if {[test_compiler_info {clang-1[2-9]-*}]} {
+       send_gdb "next 3\n"
+   } else {
+       send_gdb "next 2\n"
+   }
    gdb_expect {
      -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int  local_j = argc;.*$gdb_prompt $"\
                      {pass "step through execl call"}
--
2.17.1





[-- Attachment #2: gdb.base-Additional-next-commands-added.patch --]
[-- Type: application/octet-stream, Size: 4834 bytes --]

From b6c3646cdd40fae679131107a0b2be4ff5b9eae5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Fri, 16 Apr 2021 00:18:07 +0530
Subject: [PATCH] [gdb.base] Additional next commands added for
 clang-12 and above.

After this clang patch(https://reviews.llvm.org/D91734), 8 test points
started to FAIL in this test case. As mentioned in this PR,
"...this test is trying to "next" over a function call; gcc attributes
all parameter evaluation to the function name, while clang will attribute
each parameter to its own location. And when the parameters span across
multiple source lines, the is_stmt heuristic kicks in, so we stop on each
line with actual parameters...".
We can see additional .debug_line entries getting created after this clang
patch, hence the test case is modified accordingly to suit the new clang
behavior. This test case modification is required for clang-12 and above.

Line table: (before clang patch for the below code snippet) :
0x000000b0: 84 address += 8,  line += 2
            0x000000000020196a     42      3      1   0             0
0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000b2: 41 address += 3,  line += 5
            0x000000000020197e     47      3      1   0             0

Line table: (after clang patch for the below code snippet) :
0x000000b5: 84 address += 8,  line += 2
            0x0000000000201958     42     11      1   0             0
0x000000b6: 05 DW_LNS_set_column (4)
0x000000b8: 75 address += 7,  line += 1
            0x000000000020195f     43      4      1   0             0
0x000000b9: 05 DW_LNS_set_column (3)
0x000000bb: 73 address += 7,  line += -1
            0x0000000000201966     42      3      1   0             0
0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000bd: 4f address += 4,  line += 5
            0x000000000020197b     47      3      1   0             0

gdb.base/foll-exec.c test file snippet :
. . .
 42   execlp (prog, /* tbreak-execlp */
 43           prog,
 44           "execlp arg1 from foll-exec",
 45           (char *) 0);
 46
 47   printf ("foll-exec is about to execl(execd-prog)...\n");

Following 8 test points started to fail after the above clang patch.

FAIL: gdb.base/foll-exec.exp: step through execlp call
FAIL: gdb.base/foll-exec.exp: step after execlp call
FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
FAIL: gdb.base/foll-exec.exp: step through execl call
FAIL: gdb.base/foll-exec.exp: step after execl call
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

gdb/testsuite/ChangeLog:
        * gdb.base/foll-exec.exp: Additional next commands added for
        clang-12 and above.
---
 gdb/testsuite/ChangeLog              |  5 +++++
 gdb/testsuite/gdb.base/foll-exec.exp | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 52b0752276..ad289c135d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16  Bhuvanendra Kumar  <Bhuvanendra.KumarN@amd.com>
+
+        * gdb.base/foll-exec.exp: Additional next commands added for
+	clang-12 and above.
+
 2021-02-12  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.fortran/allocated.exp: New file.
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 6d5e21f54d..8b1fa42db9 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -118,7 +118,14 @@ proc do_exec_tests {} {
    # We should stop in execd-program, at its first statement.
    #
    set execd_line [gdb_get_line_number "after-exec" $srcfile2]
-   send_gdb "next\n"
+   # Clang-12 and above will emit extra .debug_line entries when
+   # parameters span across multiple source lines, hence additional
+   # next commands were added.
+   if {[test_compiler_info {clang-1[2-9]-*}]} {
+       send_gdb "next 3\n"
+   } else {
+       send_gdb "next\n"
+   }
    gdb_expect {
      -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int  local_j = argc;.*$gdb_prompt $"\
                      {pass "step through execlp call"}
@@ -269,7 +276,11 @@ proc do_exec_tests {} {
    # the newly-exec'd program, not after the remaining step-count
    # reaches zero.
    #
-   send_gdb "next 2\n"
+   if {[test_compiler_info {clang-1[2-9]-*}]} {
+       send_gdb "next 3\n"
+   } else {
+       send_gdb "next 2\n"
+   }
    gdb_expect {
      -re ".*xecuting new program: .*${testfile2}.*${srcfile2}:${execd_line}.*int  local_j = argc;.*$gdb_prompt $"\
                      {pass "step through execl call"}
-- 
2.17.1


             reply	other threads:[~2021-04-15 19:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15 19:37 Kumar N, Bhuvanendra via Gdb-patches [this message]
2021-04-30  8:59 ` Kumar N, Bhuvanendra via Gdb-patches
2021-05-26  8:00   ` Kumar N, Bhuvanendra via Gdb-patches
2021-05-29  2:20 ` Simon Marchi via Gdb-patches
2021-06-01 11:10   ` Kumar N, Bhuvanendra via Gdb-patches
2021-06-01 13:50     ` Simon Marchi via Gdb-patches
2021-06-01 15:40       ` Kumar N, Bhuvanendra via Gdb-patches

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=DM5PR12MB1450FC4E5D49A1DA3040C2BF874D9@DM5PR12MB1450.namprd12.prod.outlook.com \
    --to=gdb-patches@sourceware.org \
    --cc=AlokKumar.Sharma@amd.com \
    --cc=Bhuvanendra.KumarN@amd.com \
    --cc=JiniSusan.George@amd.com \
    --cc=Nagajyothi.E@amd.com \
    --cc=Nitika.Achra@amd.com \
    --cc=SourabhSingh.Tomar@amd.com \
    /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