From owner-svn-src-head@freebsd.org Fri Nov 27 20:12:18 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40ECAA3AF50; Fri, 27 Nov 2015 20:12:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1A5061F24; Fri, 27 Nov 2015 20:12:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 916D4B923; Fri, 27 Nov 2015 15:12:15 -0500 (EST) From: John Baldwin To: src-committers@freebsd.org Cc: svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r291406 - in head: . gnu/usr.bin/gdb/kgdb lib/libkvm rescue/rescue share/mk sys/sparc64/include Date: Fri, 27 Nov 2015 11:04:23 -0800 Message-ID: <2898094.TQmcuznC5g@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201511271858.tARIwQOt030605@repo.freebsd.org> References: <201511271858.tARIwQOt030605@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 27 Nov 2015 15:12:15 -0500 (EST) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Nov 2015 20:12:18 -0000 On Friday, November 27, 2015 06:58:26 PM John Baldwin wrote: > Author: jhb > Date: Fri Nov 27 18:58:26 2015 > New Revision: 291406 > URL: https://svnweb.freebsd.org/changeset/base/291406 > > Log: > Add support to libkvm for reading vmcores from other architectures. > - Add a kvaddr_type to represent kernel virtual addresses instead of > unsigned long. > - Add a struct kvm_nlist which is a stripped down version of struct nlist > that uses kvaddr_t for n_value. > - Add a kvm_native() routine that returns true if an open kvm descriptor > is for a native kernel and memory image. > - Add a kvm_open2() function similar to kvm_openfiles(). It drops the > unused 'swapfile' argument and adds a new function pointer argument for > a symbol resolving function. Native kernels still use _fdnlist() from > libc to resolve symbols if a resolver function is not supplied, but cross > kernels require a resolver. > - Add a kvm_nlist2() function similar to kvm_nlist() except that it uses > struct kvm_nlist instead of struct nlist. > - Add a kvm_read2() function similar to kvm_read() except that it uses > kvaddr_t instead of unsigned long for the kernel virtual address. > - Add a new kvm_arch switch of routines needed by a vmcore backend. > Each backend is responsible for implementing kvm_read2() for a given > vmcore format. > - Use libelf to read headers from ELF kernels and cores (except for > powerpc cores). > - Add internal helper routines for the common page offset hash table used > by the minidump backends. > - Port all of the existing kvm backends to implement a kvm_arch switch and > to be cross-friendly by using private constants instead of ones that > vary by platform (e.g. PAGE_SIZE). Static assertions are present when > a given backend is compiled natively to ensure the private constants > match the real ones. > - Enable all of the existing vmcore backends on all platforms. This means > that libkvm on any platform should be able to perform KVA translation > and read data from a vmcore of any platform. > > Tested on: amd64, i386, sparc64 (marius) > Differential Revision: https://reviews.freebsd.org/D3341 emaste@ reviewed some pieces of this but not all I believe. I have not fully tested the in-tree cross-kgdb support though I believe it should build in the new world order without requiring one to build a cross libkvm. That is, you should just need to build the cross-debugger now using the stock libkvm. The kgdb patches in devel/gdb in ports already support this new interface, though it is only enabled at compile time if compiled on a world with the new libkvm. Currently the amd64 and i386 backends in kgdb in ports support cross-vmcore debugging, so you should be able to debug an amd64 or i386 vmcore on any platform where devel/gdb runs. As more platforms are added to devel/gdb they should all support cross-debugging (so, for example, once arm is added to devel/gdb and the kgdb bits in devel/gdb, one would be able to debug an arm vmcore on an amd64 host). Another fun trick would be to add some build glue to make libkvm buildable on other OS's (e.g. on OS X) so that gdb (or lldb) could be built on OS X and use the portable libkvm to debug a kernel vmcore from a non-FreeBSD host. -- John Baldwin