Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 50948 invoked from network); 3 Aug 2010 02:24:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Aug 2010 02:24:48 -0000 Received: (qmail 80629 invoked by uid 500); 3 Aug 2010 02:24:47 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 80545 invoked by uid 500); 3 Aug 2010 02:24:46 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 80536 invoked by uid 99); 3 Aug 2010 02:24:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 02:24:46 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of xu.regis@gmail.com designates 74.125.83.177 as permitted sender) Received: from [74.125.83.177] (HELO mail-pv0-f177.google.com) (74.125.83.177) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 02:24:39 +0000 Received: by pvf33 with SMTP id 33so1727833pvf.36 for ; Mon, 02 Aug 2010 19:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=pIeO42FuWXdYxZqCWxLagJhIfHW1R1CIEI3+goQHbZw=; b=UQ6QXMsMQTobdHCYCUsfaHCCyXAe/Gpn5vwc4bHA+zB6m0CqLbsDEZI17qvooQ/3/1 7+dI9au8c+ccru/SzsfXaXdzv2VqN8TKSJ2xEl7rmGADt0+d1Ieclcnc53nTxmfIkNfP 2EMmb8KzlNEUcTy5669ISKd2dAGenixrnhnOg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=s7TC17iGl4DUKQ/J4YBzlMLX40nVN3kFcPAd55r3Q2OruOA35uLgg+fLCKiQDe2Maf YUv7XUEgfQCQb7VQTLTdjCoZAYiOs9uKOA29ZGwqIiYDjNg452T+DD+8h0NtpflcQ9S4 Yr5p30rEMcMZMqxiqg4zhUiad+h/eg8A1U5CA= Received: by 10.114.88.17 with SMTP id l17mr8324349wab.218.1280802258699; Mon, 02 Aug 2010 19:24:18 -0700 (PDT) Received: from [9.123.233.16] ([220.248.0.145]) by mx.google.com with ESMTPS id d39sm12591237wam.16.2010.08.02.19.24.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 02 Aug 2010 19:24:16 -0700 (PDT) Message-ID: <4C577DC9.7060001@gmail.com> Date: Tue, 03 Aug 2010 10:24:09 +0800 From: Regis User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: Problem met when building jdktools alone References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2010-08-02 23:44, Daniel Gong wrote: > Hi all, > > As you know that I'm developing the jdb command line tool. I met a weird > problem when building jdktools alone. > > Briefly, the problem is like this: after I build the jdktools module against > hdk, each jdk tool command line tool turns out to be segmentation fault when > running with a simple command such as "java", but succeeds when running with > a full path such as "$HDK/jdk/bin/java". > > According to the component-wise instruction, I get the jdktools code and > common resources code from svn, the directory structure is like this: > > myproject > | > |--------- jdktools > | | > | |---------- build.xml > | | > | |---------- LICENSE > | | > | |---------- make > | | > | |---------- modules > | | > | |---------- NOTICE > | > |--------- common resources > | | > | |---------- build.xml > | | > | |---------- depends > | | > | |---------- make > > And hdk is in another directory. HDK is also the java runtime that ant use. > > I have kept using the full path of jdk tool command to test whether my jdb > works and tried to find a solution but still do not have one... > > Does any one know what happened? Thanks. > > Best wishes > Daniel Gong > getExeDir in samsa.c uses realpath to find executable file path, which can't handle case of executable file is in $PATH. Reading symbol link "/proc/self/exe" can resolve it on linux, you can try following patch. I'm not sure if it works on other platforms (AIX, z/OS). Index: jdktools/modules/samsa/src/main/native/samsa/samsa.c ===================================================================== --- jdktools/modules/samsa/src/main/native/samsa/samsa.c +++ jdktools/modules/samsa/src/main/native/samsa/samsa.c @@ -471,13 +471,14 @@ char *getExeDir(const char* argv0) { // FIXME - handle this right - it could be that 512 isn't enough #else + int length; char buffer[PATH_MAX + 1]; - char *rc = realpath(argv0, buffer); - if (!rc) { - return NULL; + length = readlink("/proc/self/exe", buffer, sizeof(buffer)); + if (length == -1) { + return NULL; } - buffer[PATH_MAX] = '\0'; + buffer[length] = '\0'; #endif last = strrchr(buffer, PATH_SEPARATOR_CHAR); -- Best Regards, Regis.