diff options
author | Pedro Alves <pedro@palves.net> | 2020-09-13 21:28:09 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2020-09-13 21:28:09 +0100 |
commit | af26601c2f657535af68cc3cec2af969838877da (patch) | |
tree | 75525b0ea7980285f489337668f0780a3b4e44e0 /gdb/testsuite | |
parent | 2f4b83cd51953fdf9626dc7a198b35505d1f5472 (diff) | |
download | gdb-af26601c2f657535af68cc3cec2af969838877da.zip gdb-af26601c2f657535af68cc3cec2af969838877da.tar.gz gdb-af26601c2f657535af68cc3cec2af969838877da.tar.bz2 |
Fix gdb.base/share-env-with-gdbserver.exp with Clang
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 397c616..5c37401 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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 instead of spawning GDB with remote_spawn. * lib/mi-support.exp (default_mi_gdb_start): Adjust to use diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c index 740bfdc..17e9575 100644 --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c @@ -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); |