From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4112 invoked by alias); 31 Aug 2010 17:27:41 -0000 Received: (qmail 4101 invoked by uid 22791); 31 Aug 2010 17:27:40 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Aug 2010 17:27:35 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7VHRO8n002694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 31 Aug 2010 13:27:24 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7VHRMo0019927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 31 Aug 2010 13:27:23 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o7VHRLGr009539; Tue, 31 Aug 2010 19:27:21 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o7VHRLlJ009532; Tue, 31 Aug 2010 19:27:21 +0200 Date: Tue, 31 Aug 2010 17:27:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [patch] Code cleanup: Make function typedef for find memory region Message-ID: <20100831172720.GA27390@host1.dyn.jankratochvil.net> References: <20100830085953.GA25961@host1.dyn.jankratochvil.net> <201008301143.55582.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201008301143.55582.pedro@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 X-SW-Source: 2010-08/txt/msg00554.txt.bz2 On Mon, 30 Aug 2010 12:43:55 +0200, Pedro Alves wrote: > I suggest you don't use _t for this. Most of our function typedefs > use the *_ftype prefix, a few _func, and only a couple _fn or _t. [...] > find_memory_region_ftype Chose this one. Otherwise I find it obvious, I will check it in upon approval of: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804) http://sourceware.org/ml/gdb-patches/2010-08/msg00499.html Thanks, Jan gdb/ 2010-08-31 Jan Kratochvil Code cleanup. * defs.h (find_memory_region_ftype): New typedef. (exec_set_find_memory_regions): Use it. * exec.c (exec_set_find_memory_regions): Use find_memory_region_ftype. * fbsd-nat.c (fbsd_find_memory_regions): Likewise. * gcore.c (objfile_find_memory_regions): Likewise. * gnu-nat.c (gnu_find_memory_regions): Likewise. * linux-nat.c (linux_nat_find_memory_regions): Likewise. * procfs.c (iterate_over_mappings_cb_ftype): Remove. (iterate_over_mappings): Rename iterate_over_mappings_cb_ftype to find_memory_region_ftype. (insert_dbx_link_bpt_in_region): Likewise. (iterate_over_mappings): Likewise. Drop the comment part about the function prototype. (find_memory_regions_callback): Use find_memory_region_ftype. (proc_find_memory_regions): Likewise. (info_mappings_callback): Rename iterate_over_mappings_cb_ftype to find_memory_region_ftype. * target.c (dummy_find_memory_regions): Use find_memory_region_ftype. * target.h (struct target_ops) : Likewise. --- a/gdb/defs.h +++ b/gdb/defs.h @@ -634,12 +634,13 @@ extern void init_source_path (void); /* From exec.c */ +typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size, + int read, int write, int exec, + void *data); + /* Take over the 'find_mapped_memory' vector from exec.c. */ -extern void exec_set_find_memory_regions (int (*) (int (*) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *)); +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. */ --- a/gdb/exec.c +++ b/gdb/exec.c @@ -835,11 +835,7 @@ exec_has_memory (struct target_ops *ops) /* Find mapped memory. */ extern void -exec_set_find_memory_regions (int (*func) (int (*) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *)) +exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *)) { exec_ops.to_find_memory_regions = func; } --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -92,9 +92,7 @@ fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end, argument to FUNC. */ int -fbsd_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, - int, int, int, void *), - void *obfd) +fbsd_find_memory_regions (find_memory_region_ftype func, void *obfd) { pid_t pid = ptid_get_pid (inferior_ptid); char *mapfilename; --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -462,9 +462,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, } static int -objfile_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, - int, int, int, void *), - void *obfd) +objfile_find_memory_regions (find_memory_region_ftype func, void *obfd) { /* Use objfile data to create memory sections. */ struct objfile *objfile; --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2487,11 +2487,7 @@ gnu_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, /* Call FUNC on each memory region in the task. */ static int -gnu_find_memory_regions (int (*func) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *data) +gnu_find_memory_regions (find_memory_region_ftype func, void *data) { error_t err; task_t task; --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4104,9 +4104,7 @@ read_mapping (FILE *mapfile, regions in the inferior for a corefile. */ static int -linux_nat_find_memory_regions (int (*func) (CORE_ADDR, - unsigned long, - int, int, int, void *), void *obfd) +linux_nat_find_memory_regions (find_memory_region_ftype func, void *obfd) { int pid = PIDGET (inferior_ptid); char mapsfilename[MAXPATHLEN]; --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -438,17 +438,9 @@ static void free_syscalls (procinfo *pi); static int find_syscall (procinfo *pi, char *name); #endif /* DYNAMIC_SYSCALLS */ -/* A function type used as a callback back iterate_over_mappings. */ -typedef int (iterate_over_mappings_cb_ftype) - (CORE_ADDR vaddr, unsigned long size, int read, int write, int execute, - void *data); - static int iterate_over_mappings - (procinfo *pi, - iterate_over_mappings_cb_ftype *child_func, - void *data, - int (*func) (struct prmap *map, - iterate_over_mappings_cb_ftype *child_func, + (procinfo *pi, find_memory_region_ftype child_func, void *data, + int (*func) (struct prmap *map, find_memory_region_ftype child_func, void *data)); /* The head of the procinfo list: */ @@ -3784,7 +3776,7 @@ solib_mappings_callback (struct prmap *map, int (*func) (int, CORE_ADDR), static int insert_dbx_link_bpt_in_region (struct prmap *map, - iterate_over_mappings_cb_ftype *child_func, + find_memory_region_ftype child_func, void *data) { procinfo *pi = (procinfo *) data; @@ -5226,11 +5218,10 @@ procfs_use_watchpoints (struct target_ops *t) from the callback function, or zero. */ static int -iterate_over_mappings (procinfo *pi, - iterate_over_mappings_cb_ftype *child_func, +iterate_over_mappings (procinfo *pi, find_memory_region_ftype child_func, void *data, int (*func) (struct prmap *map, - iterate_over_mappings_cb_ftype *child_func, + find_memory_region_ftype child_func, void *data)) { char pathname[MAX_PROC_NAME_SIZE]; @@ -5282,23 +5273,12 @@ iterate_over_mappings (procinfo *pi, } /* Implements the to_find_memory_regions method. Calls an external - function for each memory region. The external function will have - the signature: - - int callback (CORE_ADDR vaddr, - unsigned long size, - int read, int write, int execute, - void *data); - + function for each memory region. Returns the integer value returned by the callback. */ static int find_memory_regions_callback (struct prmap *map, - int (*func) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *data) + find_memory_region_ftype func, void *data) { return (*func) ((CORE_ADDR) map->pr_vaddr, map->pr_size, @@ -5321,11 +5301,7 @@ find_memory_regions_callback (struct prmap *map, the callback. */ static int -proc_find_memory_regions (int (*func) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *data) +proc_find_memory_regions (find_memory_region_ftype func, void *data) { procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); @@ -5364,8 +5340,7 @@ mappingflags (long flags) mappings'. */ static int -info_mappings_callback (struct prmap *map, - iterate_over_mappings_cb_ftype *ignore, +info_mappings_callback (struct prmap *map, find_memory_region_ftype ignore, void *unused) { unsigned int pr_off; --- a/gdb/target.c +++ b/gdb/target.c @@ -3005,7 +3005,7 @@ dummy_pid_to_str (struct target_ops *ops, ptid_t ptid) /* Error-catcher for target_find_memory_regions. */ static int -dummy_find_memory_regions (int (*ignore1) (), void *ignore2) +dummy_find_memory_regions (find_memory_region_ftype ignore1, void *ignore2) { error (_("Command not implemented for this target.")); return 0; --- a/gdb/target.h +++ b/gdb/target.h @@ -504,11 +504,7 @@ struct target_ops int (*to_async_mask) (int); int (*to_supports_non_stop) (void); /* find_memory_regions support method for gcore */ - int (*to_find_memory_regions) (int (*) (CORE_ADDR, - unsigned long, - int, int, int, - void *), - void *); + int (*to_find_memory_regions) (find_memory_region_ftype func, void *data); /* make_corefile_notes support method for gcore */ char * (*to_make_corefile_notes) (bfd *, int *); /* get_bookmark support method for bookmarks */