public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/2] [gdb/testsuite] Remove superfluous pid in temp files
@ 2023-03-27  9:36 Tom de Vries
  2023-03-27  9:36 ` [pushed 2/2] [gdb/testsuite] Handle missing gdc in gdb.dlang/dlang-start.exp Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-03-27  9:36 UTC (permalink / raw)
  To: gdb-patches

While trying to use gdb_can_simple_compile with a d program, I ran into:
...
/data/vries/gdb/f37/build/gdb/testsuite/temp/105856/can_compile_d-105856.d: \
  error: module 'can_compile_d-105856' has non-identifier characters in \
  filename, use module declaration instead
...

The d compiler has a problem with the filename can_compile_d-105856.d, which
contains the pid.  The pid is added by gdb_simple_compile:
...
    set obj [standard_temp_file $name-[pid].$postfix]
...
but it's unnecessary because standard_temp_file already uses the pid.

Fix this by removing "[pid]" in all calls to standard_temp_file.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/dwarf.exp |  2 +-
 gdb/testsuite/lib/gdb.exp   | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 8b0cf77412d..434495df24a 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -294,7 +294,7 @@ proc shared_gdb_start_use { src options } {
     }
 
     if { $do_start } {
-	set exe [standard_temp_file func_addr[pid].x]
+	set exe [standard_temp_file func_addr.x]
 
 	gdb_compile $src $exe executable $options
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3cfe22b32cd..f8046ffe84d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4579,8 +4579,8 @@ gdb_caching_proc universal_compile_options {} {
     set me "universal_compile_options"
     set options {}
 
-    set src [standard_temp_file ccopts[pid].c]
-    set obj [standard_temp_file ccopts[pid].o]
+    set src [standard_temp_file ccopts.c]
+    set obj [standard_temp_file ccopts.o]
 
     gdb_produce_source $src {
 	int foo(void) { return 0; }
@@ -4635,8 +4635,8 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
 	    break
 	}
     }
-    set src [standard_temp_file $name-[pid].$ext]
-    set obj [standard_temp_file $name-[pid].$postfix]
+    set src [standard_temp_file $name.$ext]
+    set obj [standard_temp_file $name.$postfix]
     set compile_flags [concat $compile_flags {debug nowarnings quiet}]
 
     gdb_produce_source $src $code
@@ -7011,8 +7011,8 @@ gdb_caching_proc allow_float_test {} {
 
 	# Set up, compile, and execute a test program having VFP
 	# operations.
-	set src [standard_temp_file arm_vfp[pid].c]
-	set exe [standard_temp_file arm_vfp[pid].x]
+	set src [standard_temp_file arm_vfp.c]
+	set exe [standard_temp_file arm_vfp.x]
 
 	gdb_produce_source $src {
 	    int main() {

base-commit: 324998b47364528f407666512015370c12ab83a1
-- 
2.35.3


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

* [pushed 2/2] [gdb/testsuite] Handle missing gdc in gdb.dlang/dlang-start.exp
  2023-03-27  9:36 [pushed 1/2] [gdb/testsuite] Remove superfluous pid in temp files Tom de Vries
@ 2023-03-27  9:36 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2023-03-27  9:36 UTC (permalink / raw)
  To: gdb-patches

On openSUSE Leap 15.4, I get:
...
Running gdb.dlang/dlang-start.exp ...
gdb compile failed, default_target_compile: Can't find gdc.
UNTESTED: gdb.dlang/dlang-start.exp: failed to prepare
...

Fix this by:
- introducing a new proc can_compile, and
- requiring "can_compile d" in the test-case,
such that I have instead:
...
Running gdb.dlang/dlang-start.exp ...
UNSUPPORTED: gdb.dlang/dlang-start.exp: require failed: can_compile d
...

Tested on x86_64-linux, on openSUSE Leap 15.4 and Fedora 37.
---
 gdb/testsuite/gdb.dlang/dlang-start.exp |  1 +
 gdb/testsuite/lib/gdb.exp               | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gdb/testsuite/gdb.dlang/dlang-start.exp b/gdb/testsuite/gdb.dlang/dlang-start.exp
index fd4688b0635..921f67064d3 100644
--- a/gdb/testsuite/gdb.dlang/dlang-start.exp
+++ b/gdb/testsuite/gdb.dlang/dlang-start.exp
@@ -17,6 +17,7 @@
 
 load_lib d-support.exp
 require allow_d_tests
+require {can_compile d}
 
 # This testcase verifies the behavior of the `start' command, which
 # does not work when we use the gdb stub...
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f8046ffe84d..813b755215e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2461,6 +2461,18 @@ proc allow_d_tests {} {
     return 1
 }
 
+# Return a 1 if we can compile source files in LANG.
+
+gdb_caching_proc can_compile { lang } {
+
+    if { $lang == "d" } {
+	set src { void main() {} }
+	return [gdb_can_simple_compile can_compile_$lang $src executable {d}]
+    }
+
+    error "can_compile doesn't support lang: $lang"
+}
+
 # Return 1 to try Rust tests, 0 to skip them.
 proc allow_rust_tests {} {
     if { ![isnative] } {
@@ -4634,6 +4646,10 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
 	    set ext "cpp"
 	    break
 	}
+	if { "$flag" eq "d" } {
+	    set ext "d"
+	    break
+	}
     }
     set src [standard_temp_file $name.$ext]
     set obj [standard_temp_file $name.$postfix]
-- 
2.35.3


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

end of thread, other threads:[~2023-03-27  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27  9:36 [pushed 1/2] [gdb/testsuite] Remove superfluous pid in temp files Tom de Vries
2023-03-27  9:36 ` [pushed 2/2] [gdb/testsuite] Handle missing gdc in gdb.dlang/dlang-start.exp Tom de Vries

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