public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: Ensure test links in malloc and free
@ 2018-07-04 16:36 Andrew Burgess
  2018-07-06  2:12 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2018-07-04 16:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

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                           | 5 +++++
 gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
index 2b821cd854..213dde3d6e 100644
--- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
@@ -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 */
 }
-- 
2.14.4

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

* Re: [PATCH] gdb/testsuite: Ensure test links in malloc and free
  2018-07-04 16:36 [PATCH] gdb/testsuite: Ensure test links in malloc and free Andrew Burgess
@ 2018-07-06  2:12 ` Simon Marchi
  2018-07-06 13:20   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-07-06  2:12 UTC (permalink / raw)
  To: Andrew Burgess, gdb-patches

On 2018-07-04 12:36 PM, Andrew Burgess wrote:
> 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                           | 5 +++++
>  gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> index 2b821cd854..213dde3d6e 100644
> --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> @@ -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 */
>  }
> 

Hi Andrew,

That LGTM, though I'd be curious to know in which configuration you found
this was required.

Simon

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

* Re: [PATCH] gdb/testsuite: Ensure test links in malloc and free
  2018-07-06  2:12 ` Simon Marchi
@ 2018-07-06 13:20   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2018-07-06 13:20 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

* Simon Marchi <simark@simark.ca> [2018-07-05 22:12:14 -0400]:

> On 2018-07-04 12:36 PM, Andrew Burgess wrote:
> > 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                           | 5 +++++
> >  gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 3 +++
> >  2 files changed, 8 insertions(+)
> > 
> > diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> > index 2b821cd854..213dde3d6e 100644
> > --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> > +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
> > @@ -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 */
> >  }
> > 
> 
> Hi Andrew,
> 
> That LGTM, though I'd be curious to know in which configuration you found
> this was required.

I was testing RiscV using newlib running on the built in GDB
simulator.

Without this fix the test is 18 PASS / 13 FAIL, with this fix 21 PASS
/ 9 FAIL / 1 UNTESTED.  Still some work to do, but I'm trying to clear
out some of the small fixes I have lying around.

Thanks,
Andrew

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

end of thread, other threads:[~2018-07-06 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 16:36 [PATCH] gdb/testsuite: Ensure test links in malloc and free Andrew Burgess
2018-07-06  2:12 ` Simon Marchi
2018-07-06 13:20   ` Andrew Burgess

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