Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>, gdb-patches@sourceware.org
Subject: Re: RFC: implement 'info proc mappings' for core files
Date: Mon, 03 Dec 2012 09:29:00 -0000	[thread overview]
Message-ID: <20121203092943.GA21145@host2.jankratochvil.net> (raw)
In-Reply-To: <87zk2cm44y.fsf@fleche.redhat.com>

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 <ctype.h>
>  
> @@ -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


  parent reply	other threads:[~2012-12-03  9:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02 18:42 Tom Tromey
2012-11-03  3:45 ` Sergio Durigan Junior
     [not found] ` <m3vcdnjqn5.fsf__5583.70666481114$1351914377$gmane$org@redhat.com>
2012-11-05 14:11   ` Tom Tromey
     [not found]   ` <871ug8nnqw.fsf__31325.5512774505$1352124723$gmane$org@fleche.redhat.com>
2012-11-05 21:48     ` Tom Tromey
2012-11-20 20:05       ` Tom Tromey
2012-11-20 20:16         ` Eli Zaretskii
2012-12-03  9:29         ` Jan Kratochvil [this message]
2012-12-03 17:26           ` Tom Tromey
2012-12-14 15:17             ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121203092943.GA21145@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox