Patchwork [v2,6/8] Make print-file-var.exp test attribute visibility hidden, dlopen, and main symbol

login
register
mail settings
Submitter Andrew Burgess
Date Sept. 23, 2019, 2:51 p.m.
Message ID <20190923145153.GI4962@embecosm.com>
Download mbox | patch
Permalink /patch/34636/
State New
Headers show

Comments

Andrew Burgess - Sept. 23, 2019, 2:51 p.m.
* Tom Tromey <tromey@adacore.com> [2019-09-20 13:20:15 -0600]:

> From: Pedro Alves <palves@redhat.com>
> 
> Make gdb.base/print-file-var.exp test all combinations of:
> 
>   - attribute hidden in the this_version_id symbols or not
>   - dlopen or not
>   - this_version_id symbol in main file or not
>   - C++
> 
> gdb/testsuite/ChangeLog
> 2019-08-27  Pedro Alves  <palves@redhat.com>
> 	    Andrew Burgess  <andrew.burgess@embecosm.com>
> 
> 	* gdb.base/print-file-var-lib1.c: Include <stdio.h> and
> 	"print-file-var.h".
> 	(this_version_id) Use ATTRIBUTE_VISIBILITY.
> 	(get_version_1): Print this_version_id and its address.
> 	Add extern "C" wrappers around interface functions.
> 	* gdb.base/print-file-var-lib2.c: Include <stdio.h> and
> 	"print-file-var.h".
> 	(this_version_id) Use ATTRIBUTE_VISIBILITY.
> 	(get_version_2): Print this_version_id and its address.
> 	Add extern "C" wrappers around interface functions.
> 	* gdb.base/print-file-var-main.c: Include <dlfcn.h>, <assert.h>,
> 	<stddef.h> and "print-file-var.h".
> 	Add extern "C" wrappers around interface functions.
> 	[VERSION_ID_MAIN] (this_version_id): Define.
> 	(main): Define v0.  Use dlopen if SHLIB_NAME is defined.
> 	* gdb.base/print-file-var.h: Add some #defines to simplify setting
> 	up extern "C" blocks.
> 	* gdb.base/print-file-var.exp (test): New, factored out from top
> 	level.
> 	(top level): Test all combinations of attribute hidden or not,
> 	dlopen or not, and this_version_id symbol in main file or not.
> 	Compile tests as both C++ and C, make test names unique.

The C++ build of this test should be optional, the following patch
applied on top of this one fixes this issue.

Thanks,
Andrew

---
Tom Tromey - Oct. 1, 2019, 2:11 p.m.
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> The C++ build of this test should be optional, the following patch
Andrew> applied on top of this one fixes this issue.

Thanks.  I've applied this.

Tom

Patch

diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp
index 1a065cf568b..9669f99202c 100644
--- a/gdb/testsuite/gdb.base/print-file-var.exp
+++ b/gdb/testsuite/gdb.base/print-file-var.exp
@@ -24,6 +24,16 @@  proc test {hidden dlopen version_id_main lang} {
 
     set suffix "-hidden$hidden-dlopen$dlopen-version_id_main$version_id_main"
 
+    # Normally we place different builds (C/C++) of a test into
+    # subdirectories within the test build directory, however, using
+    # gdb_load_shlib doesn't work well with this approach, so instead
+    # add a language specific suffix to the binary and library names.
+    if { $lang == "c" } {
+	set suffix "${suffix}_c"
+    } else {
+	set suffix "${suffix}_cpp"
+    }
+
     set executable $main$suffix
 
     set lib1 "print-file-var-lib1"
@@ -127,7 +137,14 @@  proc test {hidden dlopen version_id_main lang} {
     compare "'print-file-var-lib2.c'::this_version_id" "v2"
 }
 
-foreach_with_prefix lang { c c++ } {
+# Only test C++ if we are able.  Always use C.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+    set lang_list {c}
+} else {
+    set lang_list {c c++}
+}
+
+foreach_with_prefix lang $lang_list {
     foreach_with_prefix hidden {0 1} {
 	foreach_with_prefix dlopen {0 1} {
 	    foreach_with_prefix version_id_main {0 1} {