From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31722 invoked by alias); 3 Dec 2012 09:29:59 -0000 Received: (qmail 31707 invoked by uid 22791); 3 Dec 2012 09:29:58 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Dec 2012 09:29:51 +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 qB39Tp3o028151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 3 Dec 2012 04:29:51 -0500 Received: from host2.jankratochvil.net (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB39TiDt017273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 3 Dec 2012 04:29:47 -0500 Date: Mon, 03 Dec 2012 09:29:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: Sergio Durigan Junior , gdb-patches@sourceware.org Subject: Re: RFC: implement 'info proc mappings' for core files Message-ID: <20121203092943.GA21145@host2.jankratochvil.net> References: <87y5ijoniv.fsf@fleche.redhat.com> <871ug8nnqw.fsf__31325.5512774505$1352124723$gmane$org@fleche.redhat.com> <877gpzloii.fsf@fleche.redhat.com> <87zk2cm44y.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zk2cm44y.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2012-12/txt/msg00016.txt.bz2 On Tue, 20 Nov 2012 21:05:33 +0100, Tom Tromey wrote: > diff --git a/gdb/corelow.c b/gdb/corelow.c > index 99611ba..1645858 100644 > --- a/gdb/corelow.c > +++ b/gdb/corelow.c > @@ -927,6 +927,17 @@ core_has_registers (struct target_ops *ops) > return (core_bfd != NULL); > } > > +/* Implement the to_info_proc method. */ > + > +static void > +core_info_proc (struct target_ops *ops, char *args, enum info_proc_what request) > +{ > + struct gdbarch *gdbarch = get_current_arch (); > + It was not much clear to me first: /* As this is core file target here we call core_info_proc from gdbarch, not info_proc. Despite we are target_info_proc implementation. */ > + if (gdbarch_core_info_proc_p (gdbarch)) > + gdbarch_core_info_proc (gdbarch, args, request); > +} > + > /* Fill in core_ops with its defined operations and properties. */ > > static void > @@ -953,6 +964,7 @@ init_core_ops (void) > core_ops.to_has_memory = core_has_memory; > core_ops.to_has_stack = core_has_stack; > core_ops.to_has_registers = core_has_registers; > + core_ops.to_info_proc = core_info_proc; > core_ops.to_magic = OPS_MAGIC; > > if (core_target) > --- a/gdb/gdbarch.sh > +++ b/gdb/gdbarch.sh > @@ -943,6 +943,9 @@ m:void:gen_return_address:struct agent_expr *ax, struct axs_value *value, CORE_A > # Implement the "info proc" command. > M:void:info_proc:char *args, enum info_proc_what what:args, what > > +# Implement the "info proc" command for core files. > +M:void:core_info_proc:char *args, enum info_proc_what what:args, what > + Here maybe a comment # There exists only target_info_proc but there are two gdbarch methods for it. > # Iterate over all objfiles in the order that makes the most sense > # for the architecture to make global symbol searches. > # [...] > --- a/gdb/linux-tdep.c > +++ b/gdb/linux-tdep.c > @@ -30,6 +30,8 @@ > #include "elf-bfd.h" /* for elfcore_write_* */ > #include "inferior.h" > #include "cli/cli-utils.h" > +#include "arch-utils.h" > +#include "gdb_obstack.h" > > #include > > @@ -533,11 +535,149 @@ linux_info_proc (struct gdbarch *gdbarch, char *args, > } > } > > +/* Implement "info proc mappings" for a corefile. */ > + > +static void > +linux_core_info_proc_mappings (struct gdbarch *gdbarch, char *args) > +{ > + asection *section; > + ULONGEST count, page_size; > + unsigned char *descdata, *filenames, *descend, *contents; > + size_t note_size; > + unsigned int addr_size_bits, addr_size; > + struct cleanup *cleanup; > + struct gdbarch *core_gdbarch = gdbarch_from_bfd (core_bfd); > + > + section = bfd_get_section_by_name (core_bfd, ".note.linuxcore.file"); > + if (section == NULL) > + { > + warning (_("unable to find mappings in core file")); > + return; > + } > + > + if (gdbarch_addr_bit (core_gdbarch) == 32 && sizeof (ULONGEST) < 8) > + error (_("cannot decode 64-bit core note in 32-bit gdb")); Here you probably meant gdbarch_addr_bit == 64. But there was a discussion with pending patch GDB cannot be compiled without "long long" anyway resulting in: [patch] Require long long for GDB [Re: [patch] Compilation regression on older gcc + 32-bit host] Message-ID: <20120531154019.GA16401@host2.jankratochvil.net> http://sourceware.org/ml/gdb-patches/2012-05/msg01094.html I should check in that patch but it had no more comments. So 'sizeof (ULONGEST) < 8' can never happen. > + > + addr_size_bits = gdbarch_addr_bit (core_gdbarch); > + addr_size = addr_size_bits / 8; > + note_size = bfd_get_section_size (section); > + > + if (note_size < 2 * addr_size) > + error (_("malformed core note - too short for header")); > + > + contents = xmalloc (note_size); > + cleanup = make_cleanup (xfree, contents); > + if (!bfd_get_section_contents (core_bfd, section, contents, 0, note_size)) > + error (_("could not get core note contents")); [...] > +typedef int (*linux_find_memory_region_ftype) (ULONGEST vaddr, ULONGEST size, *_ftype named typedefs in GDB are without the pointer. > + ULONGEST offset, ULONGEST inode, > + int read, int write, > + int exec, int modified, > + const char *filename, > + void *data); > + > /* List memory regions in the inferior for a corefile. */ > > static int > -linux_find_memory_regions (struct gdbarch *gdbarch, > - find_memory_region_ftype func, void *obfd) > +linux_find_memory_regions_full (struct gdbarch *gdbarch, > + linux_find_memory_region_ftype func, void *obfd) > { > char filename[100]; > gdb_byte *data; [...] > +/* A callback for linux_find_memory_regions_full that updates the > + mappings data for linux_make_mappings_corefile_notes. */ > + And here could be then static linux_find_memory_region_ftype linux_make_mappings_callback; To (also) see in editor all the instances of that *_ftype. > +static int > +linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size, > + ULONGEST offset, ULONGEST inode, > + int read, int write, int exec, int modified, > + const char *filename, void *data) > +{ [...] Thanks, Jan