gdb/testsuite: Ensure test links in malloc and free
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 10 Apr 2018 19:18:53 +0000 (20:18 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 6 Jul 2018 13:31:37 +0000 (14:31 +0100)
The test associated with the source file
gdb.base/share-env-with-gdbserver.c relies on calling malloc and free
within the inferior from GDB.  However, as the test source itself
makes no use of these functions, there's no requirement that they be
linked into the test executable.

This commit adds a dummy call to malloc and free to ensure they are
linked into the test executable.

gdb/testsuite/ChangeLog:

* gdb.base/share-env-with-gdbserver.c (main): Add call to
malloc/free.

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

index a9e1618410f981a7300e62e5877aabe2b7f4ca11..d908b8537d702c3e4ef6b28f0683d78eb99caf48 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-06  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.base/share-env-with-gdbserver.c (main): Add call to
+       malloc/free.
+
 2018-07-04  Tom de Vries  <tdevries@suse.de>
 
        * gdb.dwarf2/dw2-error.exp: Update expected error message.
index 2b821cd854d431fa0e196a4084d64bb60c2bc4be..213dde3d6e8fd7eaa288355af3f3ed21c69c7826 100644 (file)
@@ -29,6 +29,8 @@ my_getenv (const char *name)
 int
 main (int argc, char *argv[])
 {
+  /* Call malloc to ensure it is linked in.  */
+  char *tmp = malloc (1);
   const char *myvar = getenv ("GDB_TEST_VAR");
 
   if (myvar != NULL)
@@ -36,5 +38,6 @@ main (int argc, char *argv[])
   else
     printf ("It failed.");
 
+  free (tmp);
   return 0;    /* break-here */
 }
This page took 0.033288 seconds and 4 git commands to generate.