This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] make first parameter of to_lookup_symbol const char *


On Monday 14 March 2011 10:13:43, Tristan Gingold wrote:

> is there any good reason why the NAME parameter is 'char *' instead of 'const char *' ?  I can't see any of them.

Old code.  Original K&R didn't know about const.  We have a lot of places
that could/should be const but aren't.  It's an ongoing slow cleanup.

> 
> This patch was tested only by recompiling gdb for powerpc-elf.
> 
> BTW, it looks like no target defines this operation...

Are you going to add a use of it?  Otherwise, I'd rather
just getting rid of it.

> 
> Tristan.
> 
> 2011-03-14  Tristan Gingold  <gingold@adacore.com>
> 
> 	* target.h (target_ops): Make NAME parameter of to_lookup_symbol
> 	const char*
> 	* target.c (debug_to_lookup_symbol): Constify NAME parameter.
> 	Adjust prototype.
> 	(update_current_target): Adjust.
> 
> diff --git a/gdb/target.c b/gdb/target.c
> index c155716..0e6d652 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -151,7 +151,7 @@ static void debug_to_load (char *, int);
>  
>  static void debug_to_unload (char *, int);
>  
> -static int debug_to_lookup_symbol (char *, CORE_ADDR *);
> +static int debug_to_lookup_symbol (const char *, CORE_ADDR *);
>  
>  static int debug_to_can_run (void);
>  
> @@ -781,7 +781,7 @@ update_current_target (void)
>  	    (void (*) (char *, int))
>  	    tcomplain);
>    de_fault (to_lookup_symbol,
> -	    (int (*) (char *, CORE_ADDR *))
> +	    (int (*) (const char *, CORE_ADDR *))
>  	    nosymbol);
>    de_fault (to_post_startup_inferior,
>  	    (void (*) (ptid_t))
> @@ -3679,7 +3679,7 @@ debug_to_unload (char *args, int from_tty)
>  }
>  
>  static int
> -debug_to_lookup_symbol (char *name, CORE_ADDR *addrp)
> +debug_to_lookup_symbol (const char *name, CORE_ADDR *addrp)
>  {
>    int retval;
>  
> diff --git a/gdb/target.h b/gdb/target.h
> index b8db4bc..2318b9d 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -478,7 +478,7 @@ struct target_ops
>      void (*to_kill) (struct target_ops *);
>      void (*to_load) (char *, int);
>      void (*to_unload) (char *, int);
> -    int (*to_lookup_symbol) (char *, CORE_ADDR *);
> +    int (*to_lookup_symbol) (const char *, CORE_ADDR *);
>      void (*to_create_inferior) (struct target_ops *, 
>  				char *, char *, char **, int);
>      void (*to_post_startup_inferior) (ptid_t);
> 
> 

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]