From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28884 invoked by alias); 1 Jun 2012 12:48:31 -0000 Received: (qmail 28874 invoked by uid 22791); 1 Jun 2012 12:48:30 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jun 2012 12:48:17 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SaRH7-0003lM-1s from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 01 Jun 2012 05:48:17 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 1 Jun 2012 05:48:16 -0700 Received: from localhost.localdomain (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Fri, 1 Jun 2012 05:48:15 -0700 From: Yao Qi To: Subject: [testsuite] Really ensure printf/fprintf are available in dprintf.exp Date: Fri, 01 Jun 2012 12:48:00 -0000 Message-ID: <1338554885-3954-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-06/txt/msg00006.txt.bz2 I noticed some fails of gdb.base/dprintf.exp on tic6x-elf-gdb testing. FAIL: gdb.base/dprintf.exp: 1st dprintf, call FAIL: gdb.base/dprintf.exp: 2nd dprintf, call caused by unable to find symbol "printf" and "malloc", (gdb) continue Continuing. kickoff also to stderr No symbol "printf" in current context. If printf/fprintf only prints constant string, compiler will replace them to puts/fwrite respectively, and actual printf/fprintf is not linked into executable. This problem should affect other ELF gdb. This patch simply add extra parameter in printf/fprintf to make sure they are linked, instead of puts/fwrite. I'll apply it in two or three days if no comments. gdb/testsuite: 2012-06-01 Yao Qi * gdb.base/dprintf.c (main): Add extra parameter. (bar): New function. It is a dead function, but to ensure 'malloc' is linked explicitly. --- gdb/testsuite/gdb.base/dprintf.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/dprintf.c b/gdb/testsuite/gdb.base/dprintf.c index 283ff58..8140a3e 100644 --- a/gdb/testsuite/gdb.base/dprintf.c +++ b/gdb/testsuite/gdb.base/dprintf.c @@ -33,8 +33,8 @@ main (int argc, char *argv[]) int loc = 1234; /* Ensure these functions are available. */ - printf ("kickoff\n"); - fprintf (stderr, "also to stderr\n"); + printf ("kickoff %d\n", loc); + fprintf (stderr, "also to stderr %d\n", loc); foo (loc++); foo (loc++); @@ -42,3 +42,17 @@ main (int argc, char *argv[]) return g; } +#include +/* Make sure function 'malloc' is linked into program. One some bare-mental + port, if we don't use 'malloc', it will not be linked in program. 'malloc' + is needed, otherwise we'll see such error message + + evaluation of this expression requires the program to have a function + "malloc". */ +void +bar (void) +{ + void *p = malloc (16); + + free (p); +} -- 1.7.0.4