public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c
@ 2021-06-03 14:57 Kumar N, Bhuvanendra
  2021-06-03 15:38 ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-03 14:57 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar, E,
	Nagajyothi, Tomar, Sourabh Singh

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

[AMD Official Use Only - Internal Distribution Only]

Hi Simon and all,

Could you please review this GDB patch. Patch is attached with this email and also inlined here. Thanks in advance

Problem Description:
Following 8 test points started to fail after the clang backend 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)

Sample 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");
. . .

Resolution:

We had discussed 2 ways of handling this issue earlier, i.e.


  1.  Adding few extra "next" command during these multi-line function call
  2.  combine these multi-line function call into single line in foll-exec.c


This PR has taken the latter approach and converted the multi-line function call into single line in foll-exec.c, thereby there is no change in .debug_line entries now and test case works as expected.

NOTE: earlier I had sent a test patch(sent on 2021-04-15) with first approach and it was suggested to follow the second approach, hence now I am sending this PR with the second approach

regards,
bhuvan

Patch content inlined:

From 77e09b9b9a19dfb35a748fd57d7a16eb52f1b6ee 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: Thu, 3 Jun 2021 17:50:28 +0530
Subject: [PATCH] [gdb.base] Convert multi-line function call into
single line.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After this clang backend 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...".

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");
. . .

Line table: (before clang backend patch for the above 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 backend patch for the above 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

Following 8 test points started to fail after the above clang backend 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)

As we can note, reason for these new test failures is due to additional
.debug_line entries getting created in case of clang compiler, hence to fix
this issue, test case required either additional "next" command during
these multi-line function call or combine these multi-line function call into
single line. This PR has taken the latter approach and converted the multi-line
function call into single line in foll-exec.c, thereby there is no change in
.debug_line entries now and test case works as expected.
---
gdb/testsuite/ChangeLog            |  5 +++++
gdb/testsuite/gdb.base/foll-exec.c | 11 ++---------
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7959f58c3c4..1873f9ddf05 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-03  Bhuvanendra Kumar N  Bhuvanendra.KumarN@amd.com<mailto:Bhuvanendra.KumarN@amd.com>
+
+          * gdb.base/foll-exec.c: convert the multi-line function call into
+          single line.
+
2021-06-02  Bernd Edlinger  bernd.edlinger@hotmail.de<mailto:bernd.edlinger@hotmail.de>
            * gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index fea62b06db4..f1b97aca4a4 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -39,18 +39,11 @@ int main (int argc, char ** argv)
   memcpy (prog + len - 9, "execd-prog", 10);
   prog[len + 1] = 0;
-  execlp (prog, /* tbreak-execlp */
-             prog,
-             "execlp arg1 from foll-exec",
-             (char *) 0);
+  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
   printf ("foll-exec is about to execl(execd-prog)...\n");
-  execl (prog,  /* tbreak-execl */
-           prog,
-           "execl arg1 from foll-exec",
-           "execl arg2 from foll-exec",
-           (char *) 0);
+  execl (prog, /* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
   {
     static char * argv[] = {
--
2.17.1


[-- Attachment #2: gdb.base-Convert-multi-line-function-call-into.patch --]
[-- Type: application/octet-stream, Size: 4726 bytes --]

From 77e09b9b9a19dfb35a748fd57d7a16eb52f1b6ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Thu, 3 Jun 2021 17:50:28 +0530
Subject: [PATCH] [gdb.base] Convert multi-line function call into
 single line.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After this clang backend 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...".

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");
. . .

Line table: (before clang backend patch for the above 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 backend patch for the above 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

Following 8 test points started to fail after the above clang backend 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)

As we can note, reason for these new test failures is due to additional
.debug_line entries getting created in case of clang compiler, hence to fix
this issue, test case required either additional “next” command during
these multi-line function call or combine these multi-line function call into
single line. This PR has taken the latter approach and converted the multi-line
function call into single line in foll-exec.c, thereby there is no change in
.debug_line entries now and test case works as expected.
---
 gdb/testsuite/ChangeLog            |  5 +++++
 gdb/testsuite/gdb.base/foll-exec.c | 11 ++---------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7959f58c3c4..1873f9ddf05 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-03  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
+
+	* gdb.base/foll-exec.c: convert the multi-line function call into
+	single line.
+
 2021-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
 	* gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index fea62b06db4..f1b97aca4a4 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -39,18 +39,11 @@ int main (int argc, char ** argv)
   memcpy (prog + len - 9, "execd-prog", 10);
   prog[len + 1] = 0;
 
-  execlp (prog, /* tbreak-execlp */
-	  prog,
-	  "execlp arg1 from foll-exec",
-	  (char *) 0);
+  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
 
   printf ("foll-exec is about to execl(execd-prog)...\n");
 
-  execl (prog,	/* tbreak-execl */
-	 prog,
-	 "execl arg1 from foll-exec",
-	 "execl arg2 from foll-exec",
-	 (char *) 0);
+  execl (prog,	/* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
 
   {
     static char * argv[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c
  2021-06-03 14:57 [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c Kumar N, Bhuvanendra
@ 2021-06-03 15:38 ` Simon Marchi
  2021-06-07  6:31   ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2021-06-03 15:38 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra, gdb-patches
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar, E,
	Nagajyothi, Tomar, Sourabh Singh

> diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
> 
> index fea62b06db4..f1b97aca4a4 100644
> 
> --- a/gdb/testsuite/gdb.base/foll-exec.c
> 
> +++ b/gdb/testsuite/gdb.base/foll-exec.c
> 
> @@ -39,18 +39,11 @@ int main (int argc, char ** argv)
> 
>    memcpy (prog + len - 9, "execd-prog", 10);
> 
>    prog[len + 1] = 0;
> 
> -  execlp (prog, /* tbreak-execlp */
> 
> -             prog,
> 
> -             "execlp arg1 from foll-exec",
> 
> -             (char *) 0);
> 
> +  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
> 
>    printf ("foll-exec is about to execl(execd-prog)...\n");
> 
> -  execl (prog,  /* tbreak-execl */
> 
> -           prog,
> 
> -           "execl arg1 from foll-exec",
> 
> -           "execl arg2 from foll-exec",
> 
> -           (char *) 0);
> 
> +  execl (prog, /* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
> 
>    {
> 
>      static char * argv[] = {

Since these lines exceed the normal line length limit of 80 columns,
please add a comment above to say why the call is all on one line.
Otherwise, someone may be tempted to "fix it" and put it back on
multiple lines (such a comment may be useful in the other test too).

Thanks,

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c
  2021-06-03 15:38 ` Simon Marchi
@ 2021-06-07  6:31   ` Kumar N, Bhuvanendra
  2021-06-07 15:07     ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-07  6:31 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar, E,
	Nagajyothi, Tomar, Sourabh Singh

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

[AMD Official Use Only - Internal Distribution Only]

Hi Simon,

> Since these lines exceed the normal line length limit of 80 columns, please add a comment above to say why the call is all on one line.

I have added the required comment in the source file, could you please review/approve the updated patch. 
I have attached the updated patch and also inlined here

regards,
bhuvan

Patch inlined:

From 8f77e54fad98f17f3f34d07a0275de521aeed74f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Thu, 3 Jun 2021 17:50:28 +0530
Subject: [PATCH] [gdb.base] Convert multi-line function call into
 single line.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After this clang backend 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...".

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");
. . .

Line table: (before clang backend patch for the above 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 backend patch for the above 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

Following 8 test points started to fail after the above clang backend 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)

As we can note, reason for these new test failures is due to additional
.debug_line entries getting created in case of clang compiler, hence to fix
this issue, test case required either additional “next” command during
these multi-line function call or combine these multi-line function call into
single line. This PR has taken the latter approach and converted the multi-line
function call into single line in foll-exec.c, thereby there is no change in
.debug_line entries now and test case works as expected.
---
 gdb/testsuite/ChangeLog            |  5 +++++
 gdb/testsuite/gdb.base/foll-exec.c | 19 ++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7959f58c3c4..1873f9ddf05 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-03  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
+
+	* gdb.base/foll-exec.c: convert the multi-line function call into
+	single line.
+
 2021-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
 	* gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index fea62b06db4..77a29860ebc 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -39,18 +39,19 @@ int main (int argc, char ** argv)
   memcpy (prog + len - 9, "execd-prog", 10);
   prog[len + 1] = 0;
 
-  execlp (prog, /* tbreak-execlp */
-	  prog,
-	  "execlp arg1 from foll-exec",
-	  (char *) 0);
+  /* In the following function call, maximum line length exceed the limit 80.
+     This is intentional and required for clang compiler such that complete
+     function call should be in a single line, please do not make it
+     multi-line */
+  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
 
   printf ("foll-exec is about to execl(execd-prog)...\n");
 
-  execl (prog,	/* tbreak-execl */
-	 prog,
-	 "execl arg1 from foll-exec",
-	 "execl arg2 from foll-exec",
-	 (char *) 0);
+  /* In the following function call, maximum line length exceed the limit 80.
+     This is intentional and required for clang compiler such that complete
+     function call should be in a single line, please do not make it
+     multi-line */
+  execl (prog,	/* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
 
   {
     static char * argv[] = {
-- 
2.17.1

-----Original Message-----
From: Simon Marchi <simon.marchi@polymtl.ca> 
Sent: Thursday, June 3, 2021 9:09 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>; 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: Re: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c

[CAUTION: External Email]

> diff --git a/gdb/testsuite/gdb.base/foll-exec.c 
> b/gdb/testsuite/gdb.base/foll-exec.c
>
> index fea62b06db4..f1b97aca4a4 100644
>
> --- a/gdb/testsuite/gdb.base/foll-exec.c
>
> +++ b/gdb/testsuite/gdb.base/foll-exec.c
>
> @@ -39,18 +39,11 @@ int main (int argc, char ** argv)
>
>    memcpy (prog + len - 9, "execd-prog", 10);
>
>    prog[len + 1] = 0;
>
> -  execlp (prog, /* tbreak-execlp */
>
> -             prog,
>
> -             "execlp arg1 from foll-exec",
>
> -             (char *) 0);
>
> +  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from 
> + foll-exec", (char *) 0);
>
>    printf ("foll-exec is about to execl(execd-prog)...\n");
>
> -  execl (prog,  /* tbreak-execl */
>
> -           prog,
>
> -           "execl arg1 from foll-exec",
>
> -           "execl arg2 from foll-exec",
>
> -           (char *) 0);
>
> +  execl (prog, /* tbreak-execl */ prog, "execl arg1 from foll-exec", 
> + "execl arg2 from foll-exec", (char *) 0);
>
>    {
>
>      static char * argv[] = {

Since these lines exceed the normal line length limit of 80 columns, please add a comment above to say why the call is all on one line.
Otherwise, someone may be tempted to "fix it" and put it back on multiple lines (such a comment may be useful in the other test too).

Thanks,

Simon

[-- Attachment #2: gdb.base-Convert-multi-line-function-call-into.patch --]
[-- Type: application/octet-stream, Size: 5117 bytes --]

From 8f77e54fad98f17f3f34d07a0275de521aeed74f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
Date: Thu, 3 Jun 2021 17:50:28 +0530
Subject: [PATCH] [gdb.base] Convert multi-line function call into
 single line.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

After this clang backend 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...".

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");
. . .

Line table: (before clang backend patch for the above 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 backend patch for the above 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

Following 8 test points started to fail after the above clang backend 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)

As we can note, reason for these new test failures is due to additional
.debug_line entries getting created in case of clang compiler, hence to fix
this issue, test case required either additional “next” command during
these multi-line function call or combine these multi-line function call into
single line. This PR has taken the latter approach and converted the multi-line
function call into single line in foll-exec.c, thereby there is no change in
.debug_line entries now and test case works as expected.
---
 gdb/testsuite/ChangeLog            |  5 +++++
 gdb/testsuite/gdb.base/foll-exec.c | 19 ++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7959f58c3c4..1873f9ddf05 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-03  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
+
+	* gdb.base/foll-exec.c: convert the multi-line function call into
+	single line.
+
 2021-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
 	* gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index fea62b06db4..77a29860ebc 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -39,18 +39,19 @@ int main (int argc, char ** argv)
   memcpy (prog + len - 9, "execd-prog", 10);
   prog[len + 1] = 0;
 
-  execlp (prog, /* tbreak-execlp */
-	  prog,
-	  "execlp arg1 from foll-exec",
-	  (char *) 0);
+  /* In the following function call, maximum line length exceed the limit 80.
+     This is intentional and required for clang compiler such that complete
+     function call should be in a single line, please do not make it
+     multi-line */
+  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
 
   printf ("foll-exec is about to execl(execd-prog)...\n");
 
-  execl (prog,	/* tbreak-execl */
-	 prog,
-	 "execl arg1 from foll-exec",
-	 "execl arg2 from foll-exec",
-	 (char *) 0);
+  /* In the following function call, maximum line length exceed the limit 80.
+     This is intentional and required for clang compiler such that complete
+     function call should be in a single line, please do not make it
+     multi-line */
+  execl (prog,	/* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
 
   {
     static char * argv[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c
  2021-06-07  6:31   ` Kumar N, Bhuvanendra
@ 2021-06-07 15:07     ` Simon Marchi
  2021-06-07 15:19       ` Kumar N, Bhuvanendra
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2021-06-07 15:07 UTC (permalink / raw)
  To: Kumar N, Bhuvanendra, gdb-patches
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar, E,
	Nagajyothi, Tomar, Sourabh Singh

On 2021-06-07 2:31 a.m., Kumar N, Bhuvanendra wrote:
> [AMD Official Use Only - Internal Distribution Only]
> 
> Hi Simon,
> 
>> Since these lines exceed the normal line length limit of 80 columns, please add a comment above to say why the call is all on one line.
> 
> I have added the required comment in the source file, could you please review/approve the updated patch. 
> I have attached the updated patch and also inlined here
> 
> regards,
> bhuvan
> 
> Patch inlined:
> 
> From 8f77e54fad98f17f3f34d07a0275de521aeed74f Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= <Bhuvanendra.KumarN@amd.com>
> Date: Thu, 3 Jun 2021 17:50:28 +0530
> Subject: [PATCH] [gdb.base] Convert multi-line function call into
>  single line.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> After this clang backend 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...".
> 
> 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");
> . . .
> 
> Line table: (before clang backend patch for the above 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 backend patch for the above 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
> 
> Following 8 test points started to fail after the above clang backend 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)
> 
> As we can note, reason for these new test failures is due to additional
> .debug_line entries getting created in case of clang compiler, hence to fix
> this issue, test case required either additional “next” command during
> these multi-line function call or combine these multi-line function call into
> single line. This PR has taken the latter approach and converted the multi-line
> function call into single line in foll-exec.c, thereby there is no change in
> .debug_line entries now and test case works as expected.
> ---
>  gdb/testsuite/ChangeLog            |  5 +++++
>  gdb/testsuite/gdb.base/foll-exec.c | 19 ++++++++++---------
>  2 files changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 7959f58c3c4..1873f9ddf05 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-06-03  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
> +
> +	* gdb.base/foll-exec.c: convert the multi-line function call into
> +	single line.
> +
>  2021-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>  
>  	* gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
> diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
> index fea62b06db4..77a29860ebc 100644
> --- a/gdb/testsuite/gdb.base/foll-exec.c
> +++ b/gdb/testsuite/gdb.base/foll-exec.c
> @@ -39,18 +39,19 @@ int main (int argc, char ** argv)
>    memcpy (prog + len - 9, "execd-prog", 10);
>    prog[len + 1] = 0;
>  
> -  execlp (prog, /* tbreak-execlp */
> -	  prog,
> -	  "execlp arg1 from foll-exec",
> -	  (char *) 0);
> +  /* In the following function call, maximum line length exceed the limit 80.
> +     This is intentional and required for clang compiler such that complete
> +     function call should be in a single line, please do not make it
> +     multi-line */
> +  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from foll-exec", (char *) 0);
>  
>    printf ("foll-exec is about to execl(execd-prog)...\n");
>  
> -  execl (prog,	/* tbreak-execl */
> -	 prog,
> -	 "execl arg1 from foll-exec",
> -	 "execl arg2 from foll-exec",
> -	 (char *) 0);
> +  /* In the following function call, maximum line length exceed the limit 80.
> +     This is intentional and required for clang compiler such that complete
> +     function call should be in a single line, please do not make it
> +     multi-line */
> +  execl (prog,	/* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
>  
>    {
>      static char * argv[] = {
> 

This is ok, please just make sure to finish the sentence in the comment
appropriately, with a period and two spaces before the */.

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c
  2021-06-07 15:07     ` Simon Marchi
@ 2021-06-07 15:19       ` Kumar N, Bhuvanendra
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar N, Bhuvanendra @ 2021-06-07 15:19 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches
  Cc: George, Jini Susan, Achra, Nitika, Sharma, Alok Kumar, E,
	Nagajyothi, Tomar, Sourabh Singh

[AMD Official Use Only - Internal Distribution Only]

Hi,

> please just make sure to finish the sentence in the comment appropriately, with a period and two spaces before the */.

Sure, will make these changes before pushing the changes, Thanks Simon for your review comments.

regards,
bhuvan

-----Original Message-----
From: Simon Marchi <simon.marchi@polymtl.ca> 
Sent: Monday, June 7, 2021 8:37 PM
To: Kumar N, Bhuvanendra <Bhuvanendra.KumarN@amd.com>; 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: Re: [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c

[CAUTION: External Email]

On 2021-06-07 2:31 a.m., Kumar N, Bhuvanendra wrote:
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi Simon,
>
>> Since these lines exceed the normal line length limit of 80 columns, please add a comment above to say why the call is all on one line.
>
> I have added the required comment in the source file, could you please review/approve the updated patch.
> I have attached the updated patch and also inlined here
>
> regards,
> bhuvan
>
> Patch inlined:
>
> From 8f77e54fad98f17f3f34d07a0275de521aeed74f Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=E2=80=9Cbhkumarn=E2=80=9D?= 
> <Bhuvanendra.KumarN@amd.com>
> Date: Thu, 3 Jun 2021 17:50:28 +0530
> Subject: [PATCH] [gdb.base] Convert multi-line function call into  
> single line.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> After this clang backend 
> patch(https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%
> 2Freviews.llvm.org%2FD91734&amp;data=04%7C01%7CBhuvanendra.KumarN%40am
> d.com%7C448d6971a0fb40f9a9c408d929c5f931%7C3dd8961fe4884e608e11a82d994
> e183d%7C0%7C0%7C637586752539681728%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
> wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=FfdJKw05LGNtRgJMPTTNsKXKIC86roCe6zHSwoQr%2FUA%3D&amp;reserved=0), 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...".
>
> 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");
> . . .
>
> Line table: (before clang backend patch for the above 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 backend patch for the above 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
>
> Following 8 test points started to fail after the above clang backend 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)
>
> As we can note, reason for these new test failures is due to 
> additional .debug_line entries getting created in case of clang 
> compiler, hence to fix this issue, test case required either 
> additional “next” command during these multi-line function call or 
> combine these multi-line function call into single line. This PR has 
> taken the latter approach and converted the multi-line function call 
> into single line in foll-exec.c, thereby there is no change in .debug_line entries now and test case works as expected.
> ---
>  gdb/testsuite/ChangeLog            |  5 +++++
>  gdb/testsuite/gdb.base/foll-exec.c | 19 ++++++++++---------
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> 7959f58c3c4..1873f9ddf05 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-06-03  Bhuvanendra Kumar N  <Bhuvanendra.KumarN@amd.com>
> +
> +     * gdb.base/foll-exec.c: convert the multi-line function call into
> +     single line.
> +
>  2021-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
>
>       * gdb.dwarf2/per-bfd-sharing.exp: Fix temp-dir leakage.
> diff --git a/gdb/testsuite/gdb.base/foll-exec.c 
> b/gdb/testsuite/gdb.base/foll-exec.c
> index fea62b06db4..77a29860ebc 100644
> --- a/gdb/testsuite/gdb.base/foll-exec.c
> +++ b/gdb/testsuite/gdb.base/foll-exec.c
> @@ -39,18 +39,19 @@ int main (int argc, char ** argv)
>    memcpy (prog + len - 9, "execd-prog", 10);
>    prog[len + 1] = 0;
>
> -  execlp (prog, /* tbreak-execlp */
> -       prog,
> -       "execlp arg1 from foll-exec",
> -       (char *) 0);
> +  /* In the following function call, maximum line length exceed the limit 80.
> +     This is intentional and required for clang compiler such that complete
> +     function call should be in a single line, please do not make it
> +     multi-line */
> +  execlp (prog, /* tbreak-execlp */ prog, "execlp arg1 from 
> + foll-exec", (char *) 0);
>
>    printf ("foll-exec is about to execl(execd-prog)...\n");
>
> -  execl (prog,       /* tbreak-execl */
> -      prog,
> -      "execl arg1 from foll-exec",
> -      "execl arg2 from foll-exec",
> -      (char *) 0);
> +  /* In the following function call, maximum line length exceed the limit 80.
> +     This is intentional and required for clang compiler such that complete
> +     function call should be in a single line, please do not make it
> +     multi-line */
> +  execl (prog,       /* tbreak-execl */ prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0);
>
>    {
>      static char * argv[] = {
>

This is ok, please just make sure to finish the sentence in the comment appropriately, with a period and two spaces before the */.

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-07 15:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 14:57 [PATCH] [gdb.base] Convert multi-line function call into in foll-exec.c Kumar N, Bhuvanendra
2021-06-03 15:38 ` Simon Marchi
2021-06-07  6:31   ` Kumar N, Bhuvanendra
2021-06-07 15:07     ` Simon Marchi
2021-06-07 15:19       ` Kumar N, Bhuvanendra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).