From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3703 invoked by alias); 4 Oct 2012 03:41:07 -0000 Received: (qmail 3695 invoked by uid 22791); 4 Oct 2012 03:41:06 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,TW_RG,TW_XG X-Spam-Check-By: sourceware.org Received: from server-nat-6.cs.umd.edu (HELO bacon.cs.umd.edu) (128.8.127.149) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Oct 2012 03:41:02 +0000 Received: from [192.168.32.3] (pool-96-240-134-12.washdc.fios.verizon.net [96.240.134.12]) (Authenticated sender: khooyp) by bacon.cs.umd.edu (Postfix) with ESMTPSA id D37B9B406CF; Wed, 3 Oct 2012 23:40:59 -0400 (EDT) Subject: Re: [PATCH] Also install data-directory into the build directory as computed by relocate_gdb_directory Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Khoo Yit Phang In-Reply-To: <20121004013358.GJ3028@adacore.com> Date: Thu, 04 Oct 2012 03:41:00 -0000 Cc: Khoo Yit Phang , Doug Evans , Jan Kratochvil , GDB Patches Content-Transfer-Encoding: quoted-printable Message-Id: <7D8A7772-25C5-46D7-B359-0EB727DBABFC@cs.umd.edu> References: <2878953E-B698-43F3-989A-A551D96BAB62@cs.umd.edu> <20120924152641.GF4146@adacore.com> <9F52A338-A158-44DC-90C1-F46503859613@cs.umd.edu> <285502C6-1395-4049-9D55-031EDA3AD06D@cs.umd.edu> <20120924170348.GI4146@adacore.com> <20120927091737.GB2980@adacore.com> <20121004000840.GI3028@adacore.com> <20121004013358.GJ3028@adacore.com> To: Joel Brobecker X-CSD-MailScanner-ID: D37B9B406CF.A1C00 X-CSD-MailScanner: Found to be clean X-CSD-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-50, required 5, autolearn=not spam, ALL_TRUSTED -50.00) X-CSD-MailScanner-From: khooyp@cs.umd.edu X-CSD-MailScanner-Watermark: 1349926860.6792@3/ZI+RNUcYc4J6tsvyZksA 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-10/txt/msg00054.txt.bz2 Hi, On Oct 3, 2012, at 9:33 PM, Joel Brobecker wrote: >> Another wild idea is to rename the gdb in the build directory as xgdb >> (akin to xgcc). One could key off that to know gdb is being run from >> the build directory. >=20 > I think that this is opening the door for allowing GDB to execute > code without the user being aware of it. I'd rather avoid that. I've thought of one more option: we can compile two near copies of gdb: the= standard gdb to be installed, and xgdb for debugging (never installed). Th= e only difference for xgdb is that it has a different main() function that = inserts --data-directory into the command line before calling the real main= . The implementation can be something like: // xgdb.c int main (int argc, char *argv[]) { ... add --data-directory $BUILDDIR to argv if it doesn't exists ... return the_actual_main(argc, argv); } #define main the_actual_main #include "gdb.c" // end xgdb.c This doesn't have the issue of my previous idea of using exec, and does not= rely on any quirks of relocate_gdb_directory. It does hard code the build = directory into the binary, but that binary should never be installed and so= does not affect users. The cost would be compiling one more source file an= d linking it. Yit October 3, 2012