From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17483 invoked by alias); 15 Jan 2014 16:45:32 -0000 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 Received: (qmail 17472 invoked by uid 89); 15 Jan 2014 16:45:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Jan 2014 16:45:30 +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 s0FGjSH3013534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Jan 2014 11:45:28 -0500 Received: from barimba (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0FGjQrJ032583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 15 Jan 2014 11:45:26 -0500 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [RFC 12/32] Add target_ops argument to to_thread_name References: <1389640367-5571-1-git-send-email-tromey@redhat.com> <1389640367-5571-13-git-send-email-tromey@redhat.com> <52D53599.4040503@redhat.com> Date: Wed, 15 Jan 2014 16:45:00 -0000 In-Reply-To: <52D53599.4040503@redhat.com> (Pedro Alves's message of "Tue, 14 Jan 2014 13:03:21 +0000") Message-ID: <87fvopry6x.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2014-01/txt/msg00520.txt.bz2 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 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 * 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 + * 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 + * target-delegates.c: Rebuild. * target.h (struct target_ops) #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.'.")); 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 */