Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
@ 2013-03-24 12:02 Siva Chandra
  2013-04-15  9:22 ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Siva Chandra @ 2013-03-24 12:02 UTC (permalink / raw)
  To: gdb-patches

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

Hello,

The attached patch allows one to specify an option 'with_pthreads'
when using 'prepare_for_testing' in tests.  One could call
gdb_compile_pthreads directly for such a purpose, but I think using
'prepare_for_testing' is the suggested approach.  If my understanding
or approach is wrong here, then what is the best way to make testcases
to link with pthreads for c++ testcases?

2013-03-23  Siva Chandra Reddy  <sivachandra@google.com>

        Add option to link testcases with Pthreads library when
        using 'prepare_for_testing' in tests.

        testsuite/
        * lib/gdb.exp (build_executable_from_specs): Use
        gdb_compile_pthreads to compile if option "with_pthreads" is
        specified.

Thanks,
Siva Chandra

[-- Attachment #2: pthreads_option_patch.txt --]
[-- Type: text/plain, Size: 863 bytes --]

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ee9fdec..ab91cc5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3997,10 +3997,17 @@ proc build_executable_from_specs {testname executable options args} {
         lappend objects "${binfile}${i}.o"
 	incr i
     }
-    
-    if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
-        untested $testname
-        return -1
+
+    if { [lsearch -exact $options "with_pthreads"] >= 0 } {    
+        if  { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
+    } else {
+        if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
     }
 
     set info_options ""

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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-03-24 12:02 [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing' Siva Chandra
@ 2013-04-15  9:22 ` Tom Tromey
  2013-04-15 18:12   ` Siva Chandra
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2013-04-15  9:22 UTC (permalink / raw)
  To: Siva Chandra; +Cc: gdb-patches

>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> The attached patch allows one to specify an option 'with_pthreads'
Siva> when using 'prepare_for_testing' in tests.  One could call
Siva> gdb_compile_pthreads directly for such a purpose, but I think using
Siva> 'prepare_for_testing' is the suggested approach.  If my understanding
Siva> or approach is wrong here, then what is the best way to make testcases
Siva> to link with pthreads for c++ testcases?

You can use gdb_compile_pthreads and put "c++" in the options.

However, I like your approach.  Actually I wish most of the
gdb_compile_* procs would go away and be replaced by a variant of this
idea.

Siva>         * lib/gdb.exp (build_executable_from_specs): Use
Siva>         gdb_compile_pthreads to compile if option "with_pthreads" is
Siva>         specified.

The intro comment to build_executable_from_specs needs an update to note
that with_pthreads is handled locally.

Siva> +    if { [lsearch -exact $options "with_pthreads"] >= 0 } {    
Siva> +        if  { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } {

I wonder if you need to remove with_pthreads from the options here.

Tom


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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-04-15  9:22 ` Tom Tromey
@ 2013-04-15 18:12   ` Siva Chandra
  2013-04-15 18:51     ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Siva Chandra @ 2013-04-15 18:12 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

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

The attached patch addresses both of Tom's comments.

On Fri, Apr 12, 2013 at 1:56 PM, Tom Tromey <tromey@redhat.com> wrote:
> The intro comment to build_executable_from_specs needs an update to note
> that with_pthreads is handled locally.

Done.

> Siva> +    if { [lsearch -exact $options "with_pthreads"] >= 0 } {
> Siva> +        if  { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } {
>
> I wonder if you need to remove with_pthreads from the options here.

Done.

ChangeLog
2013-04-15  Siva Chandra Reddy  <sivachandra@google.com>

        Add option to link testcases with Pthreads library when
        using 'prepare_for_testing' in tests.

        testsuite/
        * lib/gdb.exp (build_executable_from_specs): Use
        gdb_compile_pthreads to compile if option "with_pthreads" is
        specified.

[-- Attachment #2: pthreads_option_patch.txt --]
[-- Type: text/plain, Size: 1603 bytes --]

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d05257d..a900cb7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3977,7 +3977,8 @@ proc test_prefix_command_help { command_list expected_initial_lines args } {
 # different options to be passed to different sub-compilations.
 # TESTNAME is the name of the test; this is passed to 'untested' if
 # something fails.
-# OPTIONS is passed to the final link, using gdb_compile.
+# OPTIONS is passed to the final link, using gdb_compile.  If OPTIONS
+# contains the option "with_pthreads", then gdb_compile_pthreads is used.
 # ARGS is a flat list of source specifications, of the form:
 #    { SOURCE1 OPTIONS1 [ SOURCE2 OPTIONS2 ]... }
 # Each SOURCE is compiled to an object file using its OPTIONS,
@@ -3999,10 +4000,19 @@ proc build_executable_from_specs {testname executable options args} {
         lappend objects "${binfile}${i}.o"
 	incr i
     }
-    
-    if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
-        untested $testname
-        return -1
+
+    set with_pthreads [lsearch -exact $options "with_pthreads"]
+    if { $with_pthreads >= 0 } {
+        set options [lreplace $options $with_pthreads $with_pthreads]
+        if  { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
+    } else {
+        if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
     }
 
     set info_options ""

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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-04-15 18:12   ` Siva Chandra
@ 2013-04-15 18:51     ` Pedro Alves
  2013-04-16  5:39       ` Siva Chandra
  0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2013-04-15 18:51 UTC (permalink / raw)
  To: Siva Chandra; +Cc: Tom Tromey, gdb-patches

On 04/15/2013 02:36 PM, Siva Chandra wrote:

> ChangeLog
> 2013-04-15  Siva Chandra Reddy  <sivachandra@google.com>
> 
>         Add option to link testcases with Pthreads library when
>         using 'prepare_for_testing' in tests.

Super nit, but do we need "with_" ?  We don't say "with_debug" or
"with_nowarnings" either.  I'd suggest just "pthread".  Singular, as
GNU uses -pthread / -lpthread.

Thanks,
-- 
Pedro Alves


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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-04-15 18:51     ` Pedro Alves
@ 2013-04-16  5:39       ` Siva Chandra
  2013-04-16  5:47         ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Siva Chandra @ 2013-04-16  5:39 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

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

On Mon, Apr 15, 2013 at 7:23 AM, Pedro Alves <palves@redhat.com> wrote:
> Super nit, but do we need "with_" ?  We don't say "with_debug" or
> "with_nowarnings" either.  I'd suggest just "pthread".  Singular, as
> GNU uses -pthread / -lpthread.

Done.  Please find the patch attached.

2013-04-15  Siva Chandra Reddy  <sivachandra@google.com>

        Add option to link testcases with Pthreads library when
        using 'prepare_for_testing' in tests.

        testsuite/
        * lib/gdb.exp (build_executable_from_specs): Use
        gdb_compile_pthreads to compile if option "pthreads" is
        specified.

[-- Attachment #2: pthreads_option_patch.txt --]
[-- Type: text/plain, Size: 1573 bytes --]

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3273bf4..06e1226 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3995,7 +3995,8 @@ proc test_prefix_command_help { command_list expected_initial_lines args } {
 # different options to be passed to different sub-compilations.
 # TESTNAME is the name of the test; this is passed to 'untested' if
 # something fails.
-# OPTIONS is passed to the final link, using gdb_compile.
+# OPTIONS is passed to the final link, using gdb_compile.  If OPTIONS
+# contains the option "pthreads", then gdb_compile_pthreads is used.
 # ARGS is a flat list of source specifications, of the form:
 #    { SOURCE1 OPTIONS1 [ SOURCE2 OPTIONS2 ]... }
 # Each SOURCE is compiled to an object file using its OPTIONS,
@@ -4017,10 +4018,19 @@ proc build_executable_from_specs {testname executable options args} {
         lappend objects "${binfile}${i}.o"
 	incr i
     }
-    
-    if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
-        untested $testname
-        return -1
+
+    set pthreads [lsearch -exact $options "pthreads"]
+    if { $pthreads >= 0 } {
+        set options [lreplace $options $pthreads $pthreads]
+        if  { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
+    } else {
+        if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
+            untested $testname
+            return -1
+        }
     }
 
     set info_options ""

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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-04-16  5:39       ` Siva Chandra
@ 2013-04-16  5:47         ` Tom Tromey
  2013-04-16  7:52           ` Siva Chandra
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2013-04-16  5:47 UTC (permalink / raw)
  To: Siva Chandra; +Cc: Pedro Alves, gdb-patches

>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> 2013-04-15  Siva Chandra Reddy  <sivachandra@google.com>
Siva>         Add option to link testcases with Pthreads library when
Siva>         using 'prepare_for_testing' in tests.

Siva>         testsuite/
Siva>         * lib/gdb.exp (build_executable_from_specs): Use
Siva>         gdb_compile_pthreads to compile if option "pthreads" is
Siva>         specified.

This is ok, thanks.

Tom


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

* Re: [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing'
  2013-04-16  5:47         ` Tom Tromey
@ 2013-04-16  7:52           ` Siva Chandra
  0 siblings, 0 replies; 7+ messages in thread
From: Siva Chandra @ 2013-04-16  7:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

On Mon, Apr 15, 2013 at 12:00 PM, Tom Tromey <tromey@redhat.com> wrote:
> Siva> 2013-04-15  Siva Chandra Reddy  <sivachandra@google.com>
> Siva>         Add option to link testcases with Pthreads library when
> Siva>         using 'prepare_for_testing' in tests.
>
> Siva>         testsuite/
> Siva>         * lib/gdb.exp (build_executable_from_specs): Use
> Siva>         gdb_compile_pthreads to compile if option "pthreads" is
> Siva>         specified.
>
> This is ok, thanks.

Committed the patch. Thanks for the review.


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

end of thread, other threads:[~2013-04-15 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-24 12:02 [RFC][testsuite] Add option to link testcases with pthreads when using 'prepare_for_testing' Siva Chandra
2013-04-15  9:22 ` Tom Tromey
2013-04-15 18:12   ` Siva Chandra
2013-04-15 18:51     ` Pedro Alves
2013-04-16  5:39       ` Siva Chandra
2013-04-16  5:47         ` Tom Tromey
2013-04-16  7:52           ` Siva Chandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox