From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9051 invoked by alias); 16 Oct 2013 15:22:07 -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 9037 invoked by uid 89); 16 Oct 2013 15:22:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Oct 2013 15:22:06 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9GFLqVp000497 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Oct 2013 11:21:52 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9GFLpeV009663; Wed, 16 Oct 2013 11:21:51 -0400 Message-ID: <525EAF0E.3050801@redhat.com> Date: Wed, 16 Oct 2013 15:22:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: "Maciej W. Rozycki" CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Avoid producing broken non-native core files References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-10/txt/msg00488.txt.bz2 On 10/15/2013 03:20 PM, Maciej W. Rozycki wrote: > The cause of missing register information is elfcore_write_prstatus in BFD > that writes no data (and returns NULL) on non-native targets that have no > explicit support (bed->elf_backend_write_core_note is NULL), because > HAVE_PRSTATUS_T and HAVE_PRSTATUS32_T are both forcibly undefined for > non-native BFD configurations. And if cross debugging, and bed->elf_backend_write_core_note is NULL for the current target, but HAVE_PRSTATUS_T/HAVE_PRSTATUS32_T are defined (for the native target), then gcore will generate bogus notes. :-/ It probably will be a long time before bfd's core generation is host-independent everywhere, unfortunately. As future improvement, maybe we should try _only_ bed->elf_backend_write_core_note, and skip the HAVE_... bits, unless debugging with the native target. Anyway, > Given that such core files produced are useless anyway I propose that for > targets where elfcore_write_prstatus is indeed used and returns NULL an > error message was printed and core file preparation aborted. This is > implemented in linux_corefile_thread_callback where signal information is > also stored and currently overwrites any unsuccessful return status from > the register store worker function (linux_collect_thread_registers). The > test framework is updated accordingly to handle the alternative error > message produced in that case. > --- gdb-fsf-trunk-quilt.orig/gdb/linux-tdep.c 2013-10-14 22:44:49.868756722 +0100 > +++ gdb-fsf-trunk-quilt/gdb/linux-tdep.c 2013-10-14 22:46:21.887601484 +0100 > @@ -1211,7 +1211,9 @@ linux_corefile_thread_callback (struct t > args->stop_signal); > args->num_notes++; > > - if (siginfo_data != NULL) > + /* Don't return anything if we got no register information above, > + such a core file is useless. */ > + if (args->note_data != NULL && siginfo_data != NULL) ... I was surprised to find that it took me a bit to grok the flow of this change. I'd prefer the more explicit: args->note_data = args->collect (regcache, info->ptid, args->obfd, args->note_data, args->note_size, args->stop_signal); + if (args->note_data == NULL) + { + /* Don't return anything if we got no register information above, + such a core file is useless. */ + do_cleanups (old_chain); + return 1; + } args->num_notes++; if (siginfo_data != NULL) { args->note_data = elfcore_write_note (args->obfd, args->note_data, args->note_size, "CORE", NT_SIGINFO, siginfo_data, siginfo_size); args->num_notes++; } This is OK with that change. Thanks, -- Pedro Alves