Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: Roland McGrath <roland@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] add-symbol-file-from-memory command
Date: Mon, 02 Feb 2004 04:06:00 -0000	[thread overview]
Message-ID: <20040202040641.GA9495@nevyn.them.org> (raw)
In-Reply-To: <200402020338.i123cQks022042@magilla.sf.frob.com>

On Sun, Feb 01, 2004 at 07:38:26PM -0800, Roland McGrath wrote:
> This patch hasn't changed since the last time I posted it.  But I'm hoping
> that it will be approved this time.  This support (the underlying function,
> not the user command) is the last nontrivial piece required for backtraces
> from system calls to work right with vanilla Linux 2.6 kernels.  The only
> objections previously were not apropos, and noone said anything about the
> content of the code itself.  If there is valid cause not to put this in
> now, I hope I can see it stated clearly.
> 
> The last time around, some said bfd_elf_bfd_from_remote_memory function was
> "in flux" or "a work in progress".  That function is fine as it is in BFD
> and has sat there without change for a long time.  If anyone intends to
> change its calling convention, updating gdb to suit will be at most three
> minutes work.  Since the current BFD code was approved for commit as it is,
> I can't see how speculations about possible future changes there warrant
> holding up this gdb change now.
> 
> I've made fresh diffs here, after testing this code with today's mainline
> gdb.  It still works just fine.  

I can't approve this patch, but I have some comments anyway.

I can tell you one problem with this patch, based on my backport of it:
there's an annoying/incorrect message when a program is re-run, saying:
   "<in-memory>" has disappeared; keeping its symbols

This is merely an annoyance, the message is harmless but should be
fixed.

There also was a segfault when the objfile is released.  To reproduce,
I could just say "file\n" after loading one.  GDB will try to
xfree("<in-memory>").  I see that this is fixed in the patch below, so
if the bits were unchanged from your last post then I must have come up
with the wrong copy.

> @@ -1802,6 +1810,106 @@ add_shared_symbol_files_command (char *a
>  #endif
>  }
>  \f
> +/* Helper function passed to bfd_map_over_sections.  */
> +static void
> +build_addr_info (bfd *abfd, asection *sectp, void *info)
> +{
> +  struct section_addr_info *const sai = info;
> +  unsigned int i = 0;
> +
> +  if ((bfd_get_section_flags (abfd, sectp) & (SEC_ALLOC|SEC_LOAD)) == 0)
> +    return;
> +
> +  while (sai->other[i++].name != NULL)
> +    if (i == sai->num_sections)
> +      return;
> +
> +  sai->other[i].addr = bfd_get_section_vma (abfd, sectp);
> +  sai->other[i].name = (char *) bfd_get_section_name (abfd, sectp);
> +  sai->other[i].sectindex = sectp->index;
> +}

Mind doing this in some way that isn't gratuitously quadratic?  From
the BFD manual aout bfd_map_over_sections:

        This is the preferred method for iterating over sections; an
        alternative would be to use a loop:

|          section *p;
|          for (p = abfd->sections; p != NULL; p = p->next)
|             func (abfd, p, ...)

so the ->next chain is a documented interface.

> +  if (from_tty)
> +    {
> +      if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
> +	error ("add-symbol-file-from-memory not supported for this target");
> +    }
> +  else
> +    gdb_assert (bfd_get_flavour (templ) == bfd_target_elf_flavour);

Please remove the check and the !from_tty branch.  An error is fine in
either case, and internal errors are not appropriate for user input.
Further down you have different error behavior on !from_tty also.  Is
there a particular inspiration for this?

> +  reinit_frame_cache ();	/* ??? */

Yes, this is necessary if the current cached backtrace would pass
through the newly loaded object.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2004-02-02  4:06 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-02  3:38 Roland McGrath
2004-02-02  4:06 ` Daniel Jacobowitz [this message]
2004-02-02  4:47   ` Roland McGrath
2004-02-02 15:02     ` Daniel Jacobowitz
2004-02-02 23:31       ` Roland McGrath
2004-02-02 23:34         ` Daniel Jacobowitz
2004-02-02  6:19 ` Eli Zaretskii
2004-02-02  7:35   ` Roland McGrath
2004-02-02 17:29     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2004-04-08 22:38 Roland McGrath
2004-04-15 18:11 ` Jim Blandy
2004-04-15 18:49   ` Andrew Cagney
2004-04-15 21:42   ` Roland McGrath
2004-04-08 20:47 Roland McGrath
2004-04-08 22:13 ` Jim Blandy
2004-04-08 22:28   ` Roland McGrath
2004-04-08 22:32     ` Daniel Jacobowitz
2004-04-08 22:35   ` Andrew Cagney
2004-04-08 22:42     ` Roland McGrath
2004-04-15 18:52       ` Andrew Cagney
2004-02-12  0:34 Roland McGrath
2004-02-13 15:54 ` Andrew Cagney
2004-02-13 19:13   ` Roland McGrath
2003-10-03  4:27 Roland McGrath
2003-10-03 21:41 ` Jim Blandy
2003-10-03 21:45   ` Daniel Jacobowitz
2003-10-03 22:08   ` Roland McGrath
2003-10-03 22:19   ` Elena Zannoni
2003-10-03 23:00     ` Roland McGrath
2003-10-04 12:57       ` Elena Zannoni
2003-10-04 20:14         ` Roland McGrath
2003-10-07  1:42           ` Andrew Cagney
2003-10-03 22:34   ` Andrew Cagney
2003-10-03 23:02     ` Roland McGrath
2003-10-04 14:39       ` Andrew Cagney
2003-10-06 15:30   ` Jim Blandy
2003-10-06 15:43     ` Daniel Jacobowitz
2003-10-06 19:57       ` Roland McGrath
2003-10-07 23:32       ` Michael Snyder
2003-05-20  7:01 Roland McGrath

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=20040202040641.GA9495@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=roland@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