Fix gdb.base/share-env-with-gdbserver.exp with Clang
authorPedro Alves <pedro@palves.net>
Sun, 13 Sep 2020 20:28:09 +0000 (21:28 +0100)
committerPedro Alves <pedro@palves.net>
Sun, 13 Sep 2020 20:28:09 +0000 (21:28 +0100)
The testcase has GDB call my_getenv in the inferior, and that fails
with Clang, because Clang optimizes out my_getenv completely, since it
isn't called anywhere (in the program).

This commit fixes it.

gdb/testsuite/ChangeLog:

* gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
instead of getenv.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/share-env-with-gdbserver.c

index 397c6161324c0a9123eeffa12e5b5772287c2487..5c37401dd2ff90faee2f065d5317a4be06490594 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-13  Pedro Alves  <pedro@palves.net>
+
+       * gdb.base/share-env-with-gdbserver.c (main): Call my_getenv
+       instead of getenv.
+
 2020-09-13  Pedro Alves  <pedro@palves.net>
 
        * gdb.base/dbx.exp (dbx_gdb_start): Adjust to use gdb_spawn
index 740bfdcc43cee99f66c5f8ed032c666df194c73d..17e95756a0ae7aef07531936692363d4f6e8bf8d 100644 (file)
@@ -31,7 +31,9 @@ main (int argc, char *argv[])
 {
   /* Call malloc to ensure it is linked in.  */
   char *tmp = malloc (1);
-  const char *myvar = getenv ("GDB_TEST_VAR");
+  /* Similarly call my_getenv instead of getenv directly to make sure
+     the former isn't optimized out.  my_getenv is called by GDB.  */
+  const char *myvar = my_getenv ("GDB_TEST_VAR");
 
   if (myvar != NULL)
     printf ("It worked!  myvar = '%s'\n", myvar);
This page took 0.033889 seconds and 4 git commands to generate.