From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11484 invoked by alias); 29 Oct 2018 05:05:21 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 11433 invoked by uid 89); 29 Oct 2018 05:05:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=BAYES_05,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ddd, entirely, DDD, luo X-HELO: NAM01-BY2-obe.outbound.protection.outlook.com Received: from mail-by2nam01on0049.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) (104.47.34.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 29 Oct 2018 05:05:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IM6EctxT90Xbhm2ApBQO59w9cjEYs6xkaq5vraz51Pw=; b=DgJHoTftwO6lSoV8b1g8xEQAbJSL9uCpknO8vh6SGVJdUfzLcpHO5vhgtQByAxQrzEd7y4seqsgBsivzQn20S0LHkQ35dgkU2N5zS38x14Gs9p0Nol7J3WDdMFYQO3d+HGSSltPFlMEY7a0GcxVm3K6duRdJI/H9v90EXUwhD88= Received: from DM5PR12MB1417.namprd12.prod.outlook.com (10.168.238.144) by DM5PR12MB2424.namprd12.prod.outlook.com (52.132.141.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.18; Mon, 29 Oct 2018 05:05:11 +0000 Received: from DM5PR12MB1417.namprd12.prod.outlook.com ([fe80::28e2:65d9:6893:2729]) by DM5PR12MB1417.namprd12.prod.outlook.com ([fe80::28e2:65d9:6893:2729%4]) with mapi id 15.20.1273.027; Mon, 29 Oct 2018 05:05:11 +0000 From: "Luo, Ginger" To: Simon Marchi CC: "gdb@sourceware.org" Subject: RE: getenv always return NULL in GDB/DDD Date: Mon, 29 Oct 2018 05:05:00 -0000 Message-ID: References: <4db04642c19ebdf220c6022d2ff5f5b8@polymtl.ca> In-Reply-To: <4db04642c19ebdf220c6022d2ff5f5b8@polymtl.ca> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Ginger.Luo@amd.com; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2018-10/txt/msg00058.txt.bz2 Simon, Thanks, It's awesomely working. -----Original Message----- From: Simon Marchi =20 Sent: Friday, October 26, 2018 10:21 PM To: Luo, Ginger Cc: gdb@sourceware.org Subject: Re: getenv always return NULL in GDB/DDD On 2018-10-26 05:35, Luo, Ginger wrote: > Hello, GDB experts >=20 >=20 > I try to call getenv in my C code, this can return correct env string=20 > in terminal, while it returns NULL in GDB/DDD. >=20 >=20 > #include >=20 > #include >=20 > #include >=20 > void main() { > char * a =3D getenv("ANCHOR"); // ANCHOR exists in the terminal > if (strlen(a)>0) > printf("%s\n", a); > } >=20 >=20 > The GDB/DDD is started from the same terminal. Even I "show=20 > environment", this env exists. >=20 > Anyone any idea? >=20 > OS/Tools version info: RHEL Linux hostname1 2.6.32-754.3.5.el6.x86_64 > #1 SMP Thu Aug 9 11:56:22 EDT 2018 x86_64 GNU/Linux >=20 > GNU gdb (GDB) 7.12 >=20 > gcc (GCC) 6.3.0 > SHELL is tcsh, DDD/GDB is using default settings. >=20 > Let me know if you need any further info. I don't see off-hand why this would happen. One thing to try would be "set= startup-with-shell off". If, for some reason, your shell (through which t= he debugged program is ran) messes up with the environment, this would bypa= ss it entirely. Otherwise, as usual, I would recommend trying the latest version of GDB.=20 I don't have anything specific in mind that changed recently, but it's go= od to try. Simon