Message ID | 20180704163647.4494-1-andrew.burgess@embecosm.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 51419 invoked by alias); 4 Jul 2018 16:36:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51409 invoked by uid 89); 4 Jul 2018 16:36:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:a5d X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jul 2018 16:36:53 +0000 Received: by mail-wm0-f41.google.com with SMTP id p11-v6so6711049wmc.4 for <gdb-patches@sourceware.org>; Wed, 04 Jul 2018 09:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=BvlZuYhA19yX4xzsb3ox9SKY33YLlDJ9jtj6YCk6zZU=; b=A52Bod21LRNfPZ7SscVhfFvVpLE2GJovHiekIirLMQYUEz/15TI5yjUc4QvIo6vBWA Ef+gjeWaHXEfCRTMVY9Opj6gPkV6qHF5m7kwzR5GN9tA6c1KA3SSa/CwYqxml4fwZGiY Hp/PoAyyaeW0j2z2GBBkrEUSbhQin2qiO61wi1BxGwavKa9y/sWT7fvlZ2Spg/thJOZm T7ibZK8QZFlIvjC0tigqYFQRzrk/gQ7ctd8k4VudZbarQ7uJDHBwM3xmSSL/NKzmKCEU ri+QQCvPtSemHlcYhTh5uq4RxxHZBpVbi2G0EElUaN6v9UnqO1XFlXc7YAdV9KqQm+0r GPAg== Return-Path: <andrew.burgess@embecosm.com> Received: from localhost (host86-164-199-62.range86-164.btcentralplus.com. [86.164.199.62]) by smtp.gmail.com with ESMTPSA id q140-v6sm6328532wmb.35.2018.07.04.09.36.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jul 2018 09:36:50 -0700 (PDT) From: Andrew Burgess <andrew.burgess@embecosm.com> To: gdb-patches@sourceware.org Cc: Andrew Burgess <andrew.burgess@embecosm.com> Subject: [PATCH] gdb/testsuite: Ensure test links in malloc and free Date: Wed, 4 Jul 2018 17:36:47 +0100 Message-Id: <20180704163647.4494-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes |
Commit Message
Andrew Burgess
July 4, 2018, 4:36 p.m. UTC
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(+)
Comments
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
* 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
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 */ }