From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id CF9FF3858C60 for ; Wed, 3 Nov 2021 15:59:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF9FF3858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 94B0992CD1; Wed, 3 Nov 2021 15:59:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hks043RZDz4h9d; Wed, 3 Nov 2021 15:59:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id E38F820696; Wed, 3 Nov 2021 15:59:15 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: Process memory map To: Chris Packham , Howard Chu Cc: "gdb@sourceware.org" References: <11b6bfd2-dc8b-4f07-a6ee-74fceda32054@symas.com> From: John Baldwin Message-ID: <95ecace6-76fd-781c-381d-385692373b0e@FreeBSD.org> Date: Wed, 3 Nov 2021 08:59:14 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2021 15:59:18 -0000 On 11/3/21 12:20 AM, Chris Packham via Gdb wrote: > On Wed, Nov 3, 2021 at 1:33 PM Howard Chu wrote: >> >> Is the complete map of process address space saved in a core file? When debugging >> with a core file, is there a gdb command to mmap the files that were mapped at the >> time the core was taken, so that references to addresses in those regions will be >> valid? > > I recently had a similar need. I found `info proc all` (technically > `info proc mappings`) contained the mapping info I needed. For a > regular core file the shared libraries were automatically loaded (in > my case I needed to `set auto-load safe-path` and `set sysroot` for my > cross-build environment). The one slight problem I had was with a very > specific core file where the crash was in ld.so in that specific case > it wasn't automatically loaded and I had to muck around with `add > symbol-file` and manually working out some offsets to get it loaded > into the right place. > > I'd be interested in hearing tips from anyone else. Note that manually loading symbols is much easier in recent versions of GDB. You can find the base address that a given file is loaded at via 'info proc mappings' and then just use 'add-symbol-file -o /path/to/library' to load all of the symbols without having to calculate the address of individual sections. -- John Baldwin