public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC 12/32] Add target_ops argument to to_thread_name
Date: Wed, 15 Jan 2014 16:45:00 -0000	[thread overview]
Message-ID: <87fvopry6x.fsf@fleche.redhat.com> (raw)
In-Reply-To: <52D53599.4040503@redhat.com> (Pedro Alves's message of "Tue, 14	Jan 2014 13:03:21 +0000")

Pedro> The patch is fine with me as is, but I'll note that I don't
Pedro> think there's any need for exec_set_find_memory_regions
Pedro> nowadays.  Seems to me that exec_ops.to_find_memory_regions could
Pedro> always be set to objfile_find_memory_regions unconditionally.

Good point.

Here is a patch I've added to my branch to fix this up.
It's cleaner and also more obviously correct in the multi-target case.

Tom

commit a6a3bf71f7c81b589ffd13ade0d29be010e794c8
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 15 09:40:13 2014 -0700

    remove exec_set_find_memory_regions
    
    exec_set_find_memory_regions is used to modify the exec target.
    However, it only has a single caller, and so it is much clearer to
    simply set the appropriate field directly.  It's also better for the
    coming multi-target world to avoid this kind of global state change
    anyway.
    
    2014-01-15  Tom Tromey  <tromey@redhat.com>
    
    	* gcore.h (objfile_find_memory_regions): Declare.
    	* gcore.c (objfile_find_memory_regions): No longer static.  Add
    	"self" argument.
    	(_initialize_gcore): Don't call exec_set_find_memory_regions.
    	* exec.c: Include gcore.h.
    	(exec_set_find_memory_regions): Remove.
    	(exec_find_memory_regions): Remove.
    	(exec_do_find_memory_regions): Remove.
    	(init_exec_ops): Update.
    	* defs.h (exec_set_find_memory_regions): Remove.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca5b145..d8765c9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 2014-01-15  Tom Tromey  <tromey@redhat.com>
 
+	* gcore.h (objfile_find_memory_regions): Declare.
+	* gcore.c (objfile_find_memory_regions): No longer static.  Add
+	"self" argument.
+	(_initialize_gcore): Don't call exec_set_find_memory_regions.
+	* exec.c: Include gcore.h.
+	(exec_set_find_memory_regions): Remove.
+	(exec_find_memory_regions): Remove.
+	(exec_do_find_memory_regions): Remove.
+	(init_exec_ops): Update.
+	* defs.h (exec_set_find_memory_regions): Remove.
+
+2014-01-15  Tom Tromey  <tromey@redhat.com>
+
 	* target-delegates.c: Rebuild.
 	* target.h (struct target_ops) <to_extra_thread_info,
 	to_thread_name, to_pid_to_exec_file, to_get_section_table,
diff --git a/gdb/defs.h b/gdb/defs.h
index 1469299..1361562 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -372,10 +372,6 @@ typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size,
 					 int read, int write, int exec,
 					 int modified, void *data);
 
-/* Take over the 'find_mapped_memory' vector from exec.c.  */
-extern void exec_set_find_memory_regions
-  (int (*func) (find_memory_region_ftype func, void *data));
-
 /* Possible lvalue types.  Like enum language, this should be in
    value.h, but needs to be here for the same reason.  */
 
diff --git a/gdb/exec.c b/gdb/exec.c
index 6777f35..d03fff4 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -34,6 +34,7 @@
 #include "gdbthread.h"
 #include "progspace.h"
 #include "gdb_bfd.h"
+#include "gcore.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -62,10 +63,6 @@ void _initialize_exec (void);
 
 struct target_ops exec_ops;
 
-/* Function used to implement to_find_memory_regions.  */
-
-static int (*exec_do_find_memory_regions) (find_memory_region_ftype, void *);
-
 /* True if the exec target is pushed on the stack.  */
 static int using_exec_ops;
 
@@ -820,21 +817,6 @@ exec_has_memory (struct target_ops *ops)
 	  != current_target_sections->sections_end);
 }
 
-/* Find mapped memory.  */
-
-extern void
-exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))
-{
-  exec_do_find_memory_regions = func;
-}
-
-static int
-exec_find_memory_regions (struct target_ops *self,
-			  find_memory_region_ftype func, void *data)
-{
-  return exec_do_find_memory_regions (func, data);
-}
-
 static char *exec_make_note_section (struct target_ops *self, bfd *, int *);
 
 /* Fill in the exec file target vector.  Very few entries need to be
@@ -859,7 +841,7 @@ Specify the filename of the executable file.";
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
-  exec_ops.to_find_memory_regions = exec_find_memory_regions;
+  exec_ops.to_find_memory_regions = objfile_find_memory_regions;
   exec_ops.to_magic = OPS_MAGIC;
 }
 
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 49f9b22..6228f22 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -471,8 +471,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
   return 0;
 }
 
-static int
-objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
+int
+objfile_find_memory_regions (struct target_ops *self,
+			     find_memory_region_ftype func, void *obfd)
 {
   /* Use objfile data to create memory sections.  */
   struct objfile *objfile;
@@ -607,5 +608,4 @@ Save a core file with the current state of the debugged process.\n\
 Argument is optional filename.  Default filename is 'core.<process_id>'."));
 
   add_com_alias ("gcore", "generate-core-file", class_files, 1);
-  exec_set_find_memory_regions (objfile_find_memory_regions);
 }
diff --git a/gdb/gcore.h b/gdb/gcore.h
index 0f67a1e..1240b49 100644
--- a/gdb/gcore.h
+++ b/gdb/gcore.h
@@ -23,5 +23,8 @@
 extern bfd *create_gcore_bfd (const char *filename);
 extern void write_gcore_file (bfd *obfd);
 extern bfd *load_corefile (char *filename, int from_tty);
+extern int objfile_find_memory_regions (struct target_ops *self,
+					find_memory_region_ftype func,
+					void *obfd);
 
 #endif /* GCORE_H */

  reply	other threads:[~2014-01-15 16:45 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 19:12 [RFC 00/32] clean up target delegation Tom Tromey
2014-01-13 19:12 ` [RFC 01/32] add "this" pointers to more target APIs Tom Tromey
2014-01-14 12:10   ` Pedro Alves
2014-01-14 20:25     ` Tom Tromey
2014-01-13 19:12 ` [RFC 03/32] introduce async_callback_ftype Tom Tromey
2014-01-14 10:35   ` Pedro Alves
2014-01-14 10:50     ` Joel Brobecker
2014-01-14 15:06       ` Tom Tromey
2014-01-14 17:19         ` Joel Brobecker
2014-01-14 17:27           ` Tom Tromey
2014-01-14 18:30           ` Pedro Alves
2014-01-14 19:45             ` Tom Tromey
2014-01-15 15:25               ` Tom Tromey
2014-01-13 19:12 ` [RFC 02/32] introduce and use find_target_at Tom Tromey
2014-01-14 11:48   ` [PATCH] Fix "is a record target open" checks Pedro Alves
2014-01-14 15:30     ` Tom Tromey
2014-01-14 18:27       ` Pedro Alves
2014-01-15 16:22     ` Tom Tromey
2014-01-13 19:13 ` [RFC 11/32] Add target_ops argument to to_insert_vfork_catchpoint Tom Tromey
2014-01-14 12:52   ` Pedro Alves
2014-01-13 19:13 ` [RFC 09/32] Add target_ops argument to to_close Tom Tromey
2014-01-14 12:48   ` Pedro Alves
2014-01-13 19:13 ` [RFC 12/32] Add target_ops argument to to_thread_name Tom Tromey
2014-01-14 13:03   ` Pedro Alves
2014-01-15 16:45     ` Tom Tromey [this message]
2014-01-16 17:50       ` Pedro Alves
2014-01-13 19:13 ` [RFC 24/32] convert to_disable_tracepoint Tom Tromey
2014-01-14 18:49   ` Pedro Alves
2014-01-13 19:13 ` [RFC 27/32] convert to_insert_mask_watchpoint Tom Tromey
2014-01-14 19:15   ` Pedro Alves
2014-01-14 19:23     ` Tom Tromey
2014-01-13 19:13 ` [RFC 19/32] convert to_detach Tom Tromey
2014-01-14 13:32   ` Pedro Alves
2014-01-13 19:13 ` [RFC 10/32] Add target_ops argument to to_terminal_init Tom Tromey
2014-01-14 12:51   ` Pedro Alves
2014-01-13 19:13 ` [RFC 31/32] change delegation for to_read_description Tom Tromey
2014-01-14 20:07   ` Pedro Alves
2014-01-14 20:22     ` Tom Tromey
2014-01-13 19:13 ` [RFC 26/32] convert to_static_tracepoint_markers_by_strid Tom Tromey
2014-01-14 18:57   ` Pedro Alves
2014-01-13 19:13 ` [RFC 32/32] minor cleanups to update_current_target Tom Tromey
2014-01-14 20:10   ` Pedro Alves
2014-01-13 19:13 ` [RFC 04/32] add make-target-delegates Tom Tromey
2014-01-14 10:52   ` Pedro Alves
2014-01-14 14:46     ` Tom Tromey
2014-01-13 19:13 ` [RFC 08/32] remove extended_remote_create_inferior_1 Tom Tromey
2014-01-14 12:41   ` Pedro Alves
2014-01-16 19:20     ` Tom Tromey
2014-01-13 19:13 ` [RFC 25/32] convert to_upload_trace_state_variables Tom Tromey
2014-01-14 19:38   ` Pedro Alves
2014-01-13 19:23 ` [RFC 17/32] Add target_ops argument to to_static_tracepoint_markers_by_strid Tom Tromey
2014-01-14 13:25   ` Pedro Alves
2014-01-13 19:23 ` [RFC 20/32] convert to_remove_watchpoint Tom Tromey
2014-01-14 18:39   ` Pedro Alves
2014-01-14 18:55     ` Tom Tromey
2014-01-14 19:07       ` Tom Tromey
2014-01-14 20:38       ` Pedro Alves
2014-01-14 21:47         ` Tom Tromey
2014-01-13 19:23 ` [RFC 13/32] Add target_ops argument to to_get_ada_task_ptid Tom Tromey
2014-01-14 13:21   ` Pedro Alves
2014-01-13 19:23 ` [RFC 07/32] introduce remote_load Tom Tromey
2014-01-14 12:39   ` Pedro Alves
2014-01-13 19:24 ` [RFC 06/32] convert to_supports_btrace Tom Tromey
2014-01-14 12:37   ` Pedro Alves
2014-01-15 16:55     ` Tom Tromey
2014-01-13 19:24 ` [RFC 30/32] convert to_search_memory Tom Tromey
2014-01-14 19:45   ` Pedro Alves
2014-01-14 20:20     ` Tom Tromey
2014-01-13 19:24 ` [RFC 16/32] Add target_ops argument to to_upload_trace_state_variables Tom Tromey
2014-01-14 13:24   ` Pedro Alves
2014-01-13 19:37 ` [RFC 21/32] convert to_load Tom Tromey
2014-01-14 18:41   ` Pedro Alves
2014-01-13 19:38 ` [RFC 28/32] convert to_get_section_table Tom Tromey
2014-01-14 19:23   ` Pedro Alves
2014-01-14 19:29     ` Tom Tromey
2014-01-14 19:30       ` Pedro Alves
2014-01-15 16:43         ` Tom Tromey
2014-01-16 17:51           ` Pedro Alves
2014-01-13 19:38 ` [RFC 23/32] convert to_thread_architecture Tom Tromey
2014-01-14 18:46   ` Pedro Alves
2014-01-13 19:38 ` [RFC 18/32] Add target_ops argument to to_save_record Tom Tromey
2014-01-14 13:26   ` Pedro Alves
2014-01-13 19:38 ` [RFC 05/32] add target method delegation Tom Tromey
2014-01-14 12:32   ` Pedro Alves
2014-01-20 22:00     ` Tom Tromey
2014-01-13 19:38 ` [RFC 22/32] convert to_extra_thread_info Tom Tromey
2014-01-14 18:43   ` Pedro Alves
2014-01-13 19:40 ` [RFC 29/32] convert to_insn_history Tom Tromey
2014-01-14 19:29   ` Pedro Alves
2014-01-13 19:57 ` [RFC 15/32] Add target_ops argument to to_disable_tracepoint Tom Tromey
2014-01-14 13:23   ` Pedro Alves
2014-01-13 19:57 ` [RFC 14/32] Add target_ops argument to to_fileio_pwrite Tom Tromey
2014-01-14 13:22   ` Pedro Alves
2014-01-14 20:31 ` go32 fix Pedro Alves
2014-01-14 21:58   ` Tom Tromey
2014-01-15 12:55 ` [RFC 00/32] clean up target delegation Pedro Alves
2014-01-15 16:11   ` Tom Tromey
2014-01-15 20:05     ` Tom Tromey
2014-01-16 17:33       ` Pedro Alves
2014-01-16 19:09 ` 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=87fvopry6x.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).