From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69532 invoked by alias); 6 Mar 2020 17:13:23 -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 69524 invoked by uid 89); 6 Mar 2020 17:13:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 17:13:21 +0000 Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 624C01E581; Fri, 6 Mar 2020 12:13:20 -0500 (EST) Subject: Re: [PATCH] Don't try to get the TIB address without an inferior To: Hannes Domani , Gdb-patches References: <20200306165000.3073-1-ssbssa.ref@yahoo.de> <20200306165000.3073-1-ssbssa@yahoo.de> <01f93db0-846f-8a9b-0642-498be38e75ff@simark.ca> <1282895660.8715665.1583514403483@mail.yahoo.com> From: Simon Marchi Message-ID: <74b2a6ee-7411-0d5f-298d-c84f25603eca@simark.ca> Date: Fri, 06 Mar 2020 17:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1282895660.8715665.1583514403483@mail.yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2020-03/txt/msg00150.txt On 2020-03-06 12:06 p.m., Hannes Domani via gdb-patches wrote: > Am Freitag, 6. März 2020, 17:57:30 MEZ hat Simon Marchi Folgendes geschrieben: > >> On 2020-03-06 11:50 a.m., Hannes Domani via gdb-patches wrote: >> >>> The target_get_tib_address call always fails in this case, and there is an >>> error when changing the program with the file command: >>> >>> (gdb) file allocer64.exe >>> Reading symbols from allocer64.exe... >>> You can't do that when your target is `exec' >>> >>> Now it will skip this part, there is no need to rebase the executable without >>> an inferior anyways. >>> >>> gdb/ChangeLog: >>> >>> 2020-03-06  Hannes Domani  >>> >>>      * windows-tdep.c (windows_solib_create_inferior_hook): >>>      Check inferior_ptid. >>> --- >>>   gdb/windows-tdep.c | 3 ++- >>>   1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c >>> index 4e5d8303ca..a3bacc2211 100644 >>> --- a/gdb/windows-tdep.c >>> +++ b/gdb/windows-tdep.c >>> @@ -843,7 +843,8 @@ windows_solib_create_inferior_hook (int from_tty) >>>       } >>>     CORE_ADDR tlb; >>>     gdb_byte buf[8]; >>> -  if (target_get_tib_address (inferior_ptid, &tlb) >>> +  if (inferior_ptid != null_ptid >>> +      && target_get_tib_address (inferior_ptid, &tlb) >>>         && !target_read_memory (tlb + peb_offset, buf, ptr_bytes)) >>>       { >>>         CORE_ADDR peb = extract_unsigned_integer (buf, ptr_bytes, byte_order); >> >> >> It won't really make much of a difference in practice, but I think it would be >> appropriate to use "target_has_memory" for this condition. > > I just tried it, but exec_target::has_memory() returns true, although no > program is running: > > (gdb) l > 1153    bool > 1154    exec_target::has_memory () > 1155    { > 1156      /* We can provide memory if we have any file/target sections to read > 1157         from.  */ > 1158      return (current_target_sections->sections > 1159              != current_target_sections->sections_end); > 1160    } > 1161 > 1162    char * > (gdb) p current_program_space->target_sections > $4 = { >   sections = 0x11f70630, >   sections_end = 0x11f70710 > } > Oh, right, perhaps target_has_execution then?