From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69982 invoked by alias); 22 Aug 2018 13:59:22 -0000 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 Received: (qmail 69959 invoked by uid 89); 22 Aug 2018 13:59:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 13:59:20 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w7MDxEYm006095 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Aug 2018 09:59:19 -0400 Received: by simark.ca (Postfix, from userid 112) id 519311EAB8; Wed, 22 Aug 2018 09:59:14 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 973761E76F; Wed, 22 Aug 2018 09:59:13 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 22 Aug 2018 13:59:00 -0000 From: Simon Marchi To: Xavier Roirand Cc: gdb-patches@sourceware.org, brobecker@adacore.com Subject: Re: [RFA 2/5] Darwin: Handle unrelocated dyld. In-Reply-To: <1534932677-9496-3-git-send-email-roirand@adacore.com> References: <1534932677-9496-1-git-send-email-roirand@adacore.com> <1534932677-9496-3-git-send-email-roirand@adacore.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00528.txt.bz2 On 2018-08-22 06:11, Xavier Roirand wrote: > @@ -558,6 +600,56 @@ darwin_solib_create_inferior_hook (int from_tty) > if (vmaddr != load_addr) > objfile_rebase (symfile_objfile, load_addr - vmaddr); > } > + > + /* Set solib notifier (to reload list of shared libraries). */ > + notifier = info->all_image.notifier; > + info->notifier_set = 1; > + > + if (info->all_image.count == 0) > + { > + CORE_ADDR start; > + > + /* Dyld hasn't yet relocated itself, so the notifier address may > be > + incorrect (as it has to be relocated). > + (Apparently dyld doesn't need to relocate itself on x86-64 > darwin, > + but don't assume that). > + Set an event breakpoint at the entry point. */ > + start = bfd_get_start_address (exec_bfd); > + if (start == 0) > + notifier = 0; > + else > + { > + gdb_bfd_ref_ptr dyld_bfd (darwin_get_dyld_bfd ()); > + if (dyld_bfd != NULL) > + { > + CORE_ADDR dyld_bfd_start_address; > + CORE_ADDR dyld_relocated_base_address; > + CORE_ADDR pc; > + > + dyld_bfd_start_address = bfd_get_start_address > (dyld_bfd.get()); > + > + /* We find the dynamic linker's base address by > examining > + the current pc (which should point at the entry point > + for the dynamic linker) and subtracting the offset of > + the entry point. */ > + > + pc = regcache_read_pc (get_current_regcache ()); > + dyld_relocated_base_address = pc - > dyld_bfd_start_address; > + > + /* We get the proper notifier relocated address by > + adding the dyld relocated base address to the current > + notifier offset value. */ > + > + notifier += dyld_relocated_base_address; > + info->notifier_set = 0; > + } > + } > + } > + > + /* Add the breakpoint which is hit by dyld when the list of solib is > + modified. */ > + if (notifier != 0) > + create_solib_event_breakpoint (target_gdbarch (), notifier); > } Also, if the process of finding the notifier address fails at any point, could we display a warning? Simon