[RFC,v3] Yank out target_ops->to_sections
Ulrich Weigand
uweigand@de.ibm.com
Tue Jun 2 11:10:00 GMT 2009
Pedro Alves wrote:
> > I've been thinking for a while that the exec_ops target
> > should be pushed whenever we have any kind of file loaded (main
> > executable or dynamic shared module) that we can read memory
> > from. It implements the file_stratum after all, and target.h says:
> >
> > file_stratum, /* Executable files, etc */
> > ^^^
>
> I think I'm convinced this it is the best to do, design-wise.
> This way, we'll still be able to read memory from shared library
> sections if no main executable is loaded into GDB (e.g., gdb -c foo,
> without specifying an executable needs this).
>
> I've given it a try, and, it does look like a cleaner solution
> long term to me. Even PIE executables blur the distintion of
> what is specified as main executable vs what is reported by the
> dynamic loader a bit more. Another interesting fact, is that
> the "vmap" bits spread about in exec.c for xcoffsolib are quite
> similar in spirit to this "set of target sections we can read file
> read memory from". Find below an incremental patch that applies
> on top of the v2 one I posted (the changes aren't that
> many: push/unpush of exec_ops moved, plus that default of
> target_get_section_table you pointed out goes away, replaced by
> the exec_ops target returning the current set of target sections).
> At the bottom there's the new v3 combined patch.
>
> Please let me know what you think about this. Re-tested on x86_64-linux.
I think this makes sense. Your new combined patch looks good to me.
> Index: src/gdb/exec.c
> ===================================================================
> --- src.orig/gdb/exec.c 2009-05-30 17:24:30.000000000 +0100
> +++ src/gdb/exec.c 2009-05-30 17:24:47.000000000 +0100
> @@ -71,6 +71,15 @@ struct target_ops exec_ops;
> bfd *exec_bfd = NULL;
> long exec_bfd_mtime = 0;
>
> +/* GDB currently only supports a single symbol/address space for the
> + whole debug session. When that limitation is lifted, this global
> + goes away. */
> +static struct target_section_table current_target_sections_1;
> +
> +/* The set of target sections matching the sections mapped into the
> + current inferior's address space. */
> +struct target_section_table *current_target_sections = ¤t_target_sections_1;
This can be "static" now, right?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
More information about the Gdb-patches
mailing list