public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp
@ 2021-10-12  8:19 Natarajan, Kavitha
  2021-10-25  5:01 ` Natarajan, Kavitha
  2021-10-25 18:23 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Natarajan, Kavitha @ 2021-10-12  8:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: George, Jini Susan, Parasuraman, Hariharan

[AMD Official Use Only]

Hi all,

I request you to please review the patch to fix the gdb.cp/Koenig.exp test failure with clang.

--

While running the test case gdb.cp/koenig.exp, there is an
unexpected failure:
[...]
p foo (p_union)
No symbol "p_union" in current context.
(gdb) FAIL: gdb.cp/koenig.exp: p foo (p_union)
[...]

In the testcase, "foo" is an unused variable of unnamed union type.
Clang does not emit symbol for unused unnamed union/struct variables
at any optimization level. Since the compiler itself is not emitting
the symbol for "foo", debug info is also not emitted when built with
debug option. Hence the failure. If clang option -femit-all-decls is
added to the compile line, the compiler would emit symbol for unused
unnamed union/struct variables (-g & -O0, optimized out at higher opt
levels) and thus the debug info. To fix the test failure,
-femit-all-decls is added.
[...]
p foo (p_union)
Cannot resolve function foo to any overloaded instance
(gdb) PASS: gdb.cp/koenig.exp: p foo (p_union)
[...]
---
gdb/testsuite/gdb.cp/koenig.exp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp
index 86350fa5ad4..35e67e826d2 100644
--- a/gdb/testsuite/gdb.cp/koenig.exp
+++ b/gdb/testsuite/gdb.cp/koenig.exp
@@ -15,8 +15,13 @@

standard_testfile .cc

+set additional_flags ""
+if {[test_compiler_info "clang*"]} {
+    set additional_flags "additional_flags=-femit-all-decls"
+}
+
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
-      {debug c++ additional_flags=-Wno-unused-comparison}] } {
+      [list debug c++ additional_flags=-Wno-unused-comparison ${additional_flags}]] } {
      return -1
}

--

Regards,
Kavitha

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

* RE: [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp
  2021-10-12  8:19 [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp Natarajan, Kavitha
@ 2021-10-25  5:01 ` Natarajan, Kavitha
  2021-10-25 18:23 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Natarajan, Kavitha @ 2021-10-25  5:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: George, Jini Susan, Parasuraman, Hariharan

[AMD Official Use Only]

Hi all,

A gentle reminder. Please review the simple fix in gdb test provided in the below patch.

Regards,
Kavitha

From: Natarajan, Kavitha
Sent: Tuesday, October 12, 2021 1:50 PM
To: gdb-patches@sourceware.org
Cc: George, Jini Susan <JiniSusan.George@amd.com>; Parasuraman, Hariharan <Hariharan.Parasuraman@amd.com>
Subject: [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp


[AMD Official Use Only]

Hi all,

I request you to please review the patch to fix the gdb.cp/Koenig.exp test failure with clang.

--

While running the test case gdb.cp/koenig.exp, there is an
unexpected failure:
[...]
p foo (p_union)
No symbol "p_union" in current context.
(gdb) FAIL: gdb.cp/koenig.exp: p foo (p_union)
[...]

In the testcase, "foo" is an unused variable of unnamed union type.
Clang does not emit symbol for unused unnamed union/struct variables
at any optimization level. Since the compiler itself is not emitting
the symbol for "foo", debug info is also not emitted when built with
debug option. Hence the failure. If clang option -femit-all-decls is
added to the compile line, the compiler would emit symbol for unused
unnamed union/struct variables (-g & -O0, optimized out at higher opt
levels) and thus the debug info. To fix the test failure,
-femit-all-decls is added.
[...]
p foo (p_union)
Cannot resolve function foo to any overloaded instance
(gdb) PASS: gdb.cp/koenig.exp: p foo (p_union)
[...]
---
gdb/testsuite/gdb.cp/koenig.exp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp
index 86350fa5ad4..35e67e826d2 100644
--- a/gdb/testsuite/gdb.cp/koenig.exp
+++ b/gdb/testsuite/gdb.cp/koenig.exp
@@ -15,8 +15,13 @@

standard_testfile .cc

+set additional_flags ""
+if {[test_compiler_info "clang*"]} {
+    set additional_flags "additional_flags=-femit-all-decls"
+}
+
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
-      {debug c++ additional_flags=-Wno-unused-comparison}] } {
+      [list debug c++ additional_flags=-Wno-unused-comparison ${additional_flags}]] } {
      return -1
}

--

Regards,
Kavitha

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

* Re: [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp
  2021-10-12  8:19 [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp Natarajan, Kavitha
  2021-10-25  5:01 ` Natarajan, Kavitha
@ 2021-10-25 18:23 ` Tom Tromey
  2021-10-26 11:25   ` Natarajan, Kavitha
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2021-10-25 18:23 UTC (permalink / raw)
  To: Natarajan, Kavitha via Gdb-patches
  Cc: Natarajan, Kavitha, George, Jini Susan, Parasuraman, Hariharan

>>>>> ">" == Natarajan, Kavitha via Gdb-patches <gdb-patches@sourceware.org> writes:

>> In the testcase, "foo" is an unused variable of unnamed union type.
>> Clang does not emit symbol for unused unnamed union/struct variables
>> at any optimization level.

Is it possible to change the test so that the variable is used?
I think that would be preferable, if it is possible.

thanks,
Tom

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

* RE: [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp
  2021-10-25 18:23 ` Tom Tromey
@ 2021-10-26 11:25   ` Natarajan, Kavitha
  0 siblings, 0 replies; 4+ messages in thread
From: Natarajan, Kavitha @ 2021-10-26 11:25 UTC (permalink / raw)
  To: Tom Tromey, Natarajan, Kavitha via Gdb-patches
  Cc: George, Jini Susan, Parasuraman, Hariharan

[AMD Official Use Only]

Hi Tom,

Thanks for the review. It is possible to initialize the variable and generate the debug info for the unnamed/anonymous union variable. I will create the new patch and send it for review.

Regards,
Kavitha

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Monday, October 25, 2021 11:54 PM
To: Natarajan, Kavitha via Gdb-patches <gdb-patches@sourceware.org>
Cc: Natarajan, Kavitha <Kavitha.Natarajan@amd.com>; George, Jini Susan <JiniSusan.George@amd.com>; Parasuraman, Hariharan <Hariharan.Parasuraman@amd.com>
Subject: Re: [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp

[CAUTION: External Email]

>>>>> ">" == Natarajan, Kavitha via Gdb-patches <gdb-patches@sourceware.org> writes:

>> In the testcase, "foo" is an unused variable of unnamed union type.
>> Clang does not emit symbol for unused unnamed union/struct variables 
>> at any optimization level.

Is it possible to change the test so that the variable is used?
I think that would be preferable, if it is possible.

thanks,
Tom

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

end of thread, other threads:[~2021-10-26 11:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  8:19 [PATCH] [gdb/testsuite] Add a clang option to gdb.cp/koenig.exp Natarajan, Kavitha
2021-10-25  5:01 ` Natarajan, Kavitha
2021-10-25 18:23 ` Tom Tromey
2021-10-26 11:25   ` Natarajan, Kavitha

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