From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 20 02:00:24 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D527816A417 for ; Fri, 20 Jul 2007 02:00:24 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.226]) by mx1.freebsd.org (Postfix) with ESMTP id 8FAB613C467 for ; Fri, 20 Jul 2007 02:00:24 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: by wx-out-0506.google.com with SMTP id i29so605983wxd for ; Thu, 19 Jul 2007 19:00:23 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uRJg4mIudyr4uXJcP3qeUseU+YMr1j6iZ0V3ap1Nlq2g1yVoND66EULE3GRJQrqAUOBOqe0cfGro3t+4cuPk9MsJ3hwTivViASfdOBBk/qaQu+8nErBNFf5z9fTd7gM534ZFJrppi+Kt0PRgY0cNn61lUX+HJRKkDs7K3qGsuiI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=q4ZWUyuUFXGpM2v3Kqzyd9UDtRCt0ZHaupsbZRcVkRn5YFpV124OeA9wEXSEBvHHP8vYj/IWnGUfYDwPFembVK8lAdQCJhzslTGOKLNmjMJz4xr09uRgBrP/onID7YjeU4Cypkf5YGl8NuKo1owjnxvcHC5GwhuGtetrRs7BG6M= Received: by 10.70.17.1 with SMTP id 1mr5382102wxq.1184896823855; Thu, 19 Jul 2007 19:00:23 -0700 (PDT) Received: by 10.70.38.11 with HTTP; Thu, 19 Jul 2007 19:00:23 -0700 (PDT) Message-ID: <78c6bd860707191900g375f98ado8315603feac50247@mail.gmail.com> Date: Thu, 19 Jul 2007 22:00:23 -0400 From: "Michael B Allen" To: freebsd-hackers In-Reply-To: <78c6bd860707191725r14b8bfe3sf15c1f0e30cf82ca@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <78c6bd860707191725r14b8bfe3sf15c1f0e30cf82ca@mail.gmail.com> Subject: Re: Path to executable of current process? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2007 02:00:24 -0000 On 7/19/07, Michael B Allen wrote: > Hello, > > I'm looking for an example that uses kvm_getargv but from just > googling around I can't seem to find an example. Can someone give me a > pointer? > > Actually what I'm *really* trying to do is port some code that invokes > GDB to do a backtrace and I need to give GDB the path to the > executable of the current process (e.g. on linux this is > /proc//exe) and the pid of the process to trace (easy - getpid). > The first argument is trickey since FreeBSD frequently does not have a > /proc filesystem. So it seems kvm_getargv should have this path no? Well I figured out how to get kvm_getargv working. Unfortunately it seems only root can call kvm_open so the faulting process can't backtrace unless it so happens to be running as root (which it's not). Is there any way to get argv[0] for the current process without being root? Mike