From patchwork Thu Jan 21 09:28:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 10496 Received: (qmail 23332 invoked by alias); 21 Jan 2016 09:29:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23300 invoked by uid 89); 21 Jan 2016 09:29:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 spammy=note_size, note_data, *note_data, sect_name X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 21 Jan 2016 09:29:01 +0000 Received: by mail-pa0-f54.google.com with SMTP id ho8so20357221pac.2; Thu, 21 Jan 2016 01:29:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=+8obQE3icSQbFs8tdOHDXuENEzEryWJn7oFj4Ro6atc=; b=DN+ICe2ZkpPYYvwfGfSONf2NRaxZZU8izQuVIUMN/eY6W24DbIAxYjd53W5ri8NtYi Tj5G3jBakm8cDNW++Gj+P3F2MUehiw+jL9KgDDUPZ/Opz9AXSPXVITlSv0l3hy9/yMYF KV0G0mFwKWWYVe5oY9FcRNReK/NkubByMAG3TplExyd6XZ+GhQdlSap/B5/ROf31rHGZ TnCtDOSa8kb5xDZg1M9MX/phrq/wjJ0qySOmFSQU/l06WCqgvU3XYWgG/CabfErzN4U+ mtnS7bg0WeWMRlHuokeeDxGio+zSyDuDjAIIWorA0xvkAs6zXaS4QA7/jaFbZek9PqT6 qpyA== X-Gm-Message-State: ALoCoQmQAaVmeSoDFSG5cyr98vkcfxzmLkF1HhdKLmsRu8G/JO1XWLYHEp7Wmdrb38SkArlKj+QAD+JHDHcA98MKksMyrA024w== X-Received: by 10.66.184.15 with SMTP id eq15mr58742296pac.42.1453368539684; Thu, 21 Jan 2016 01:28:59 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-163-67.gqzg1.fli.bigpond.net.au. [58.160.163.67]) by smtp.gmail.com with ESMTPSA id n27sm1067915pfb.53.2016.01.21.01.28.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 01:28:59 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 68F6EEA0186; Thu, 21 Jan 2016 19:58:55 +1030 (ACDT) Date: Thu, 21 Jan 2016 19:58:55 +1030 From: Alan Modra To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Use elfcore_write_linux_prstatus in gdb Message-ID: <20160121092855.GJ17028@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) The gdb side. Nothing fancy here, and no support for targets that need gdbarch_elfcore_write_linux_prstatus, mips n32, sparc64 if writing any of pr_{u,s,cu,cs}time, and probably x86-64 x32. diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 4ac6b90..981f8db 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -704,6 +704,9 @@ M:char *:make_corefile_notes:bfd *obfd, int *note_size:obfd, note_size # default. F:char *:elfcore_write_linux_prpsinfo:bfd *obfd, char *note_data, int *note_size, const struct elf_internal_linux_prpsinfo *info:obfd, note_data, note_size, info +# prstatus, as for prpsinfo +F:char *:elfcore_write_linux_prstatus:bfd *obfd, char *note_data, int *note_size, const struct elf_internal_linux_prstatus *info:obfd, note_data, note_size, info + # Find core file memory regions M:int:find_memory_regions:find_memory_region_ftype func, void *data:func, data @@ -1248,6 +1251,7 @@ struct stap_parse_info; struct parser_state; struct ravenscar_arch_ops; struct elf_internal_linux_prpsinfo; +struct elf_internal_linux_prstatus; struct mem_range; struct syscalls_info; struct thread_info; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 29f5f3c..03a273e 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1564,9 +1564,31 @@ linux_collect_regset_section_cb (const char *sect_name, int size, /* PRSTATUS still needs to be treated specially. */ if (strcmp (sect_name, ".reg") == 0) - data->note_data = (char *) elfcore_write_prstatus - (data->obfd, data->note_data, data->note_size, data->lwp, - gdb_signal_to_host (data->stop_signal), buf); + { + struct elf_internal_linux_prstatus prstatus; + + memset (&prstatus, 0, sizeof (prstatus)); + prstatus.pr_reg = buf; + prstatus.pr_reg_size = size; + prstatus.pr_pid = data->lwp; + prstatus.pr_cursig = gdb_signal_to_host (data->stop_signal); + if (gdbarch_elfcore_write_linux_prstatus_p (data->gdbarch)) + data->note_data = gdbarch_elfcore_write_linux_prstatus (data->gdbarch, + data->obfd, + data->note_data, + data->note_size, + &prstatus); + else if (gdbarch_ptr_bit (data->gdbarch) == 64) + data->note_data = elfcore_write_linux_prstatus64 (data->obfd, + data->note_data, + data->note_size, + &prstatus); + else + data->note_data = elfcore_write_linux_prstatus32 (data->obfd, + data->note_data, + data->note_size, + &prstatus); + } else data->note_data = (char *) elfcore_write_register_note (data->obfd, data->note_data, data->note_size,