Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patchv3 1/5] Mostly code cleanup: Constification
@ 2013-09-15 19:37 Jan Kratochvil
  2013-09-16 22:22 ` Doug Evans
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Kratochvil @ 2013-09-15 19:37 UTC (permalink / raw)
  To: gdb-patches

Hi,

this is mostly a code cleanup, just the main.c part is not exactly the same.


Jan


gdb/
2013-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Constification.
	* main.c (captured_main): Wrap symbol_file_add_main calls with
	TRY_CATCH.  Twice.
	* symfile.c (symbol_file_add_main_1): Make args parameter const.
	(symbol_file_add): Make name parameter const.
	(symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
	(symfile_bfd_open): Make name parameter const, rename it to cname.  Add
	variable name.  Change their usage accordingly.
	* symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
	const.
	(symbol_file_add_main): Make args parameter const.

--- a/gdb/main.c
+++ b/gdb/main.c
@@ -950,8 +950,15 @@ captured_main (void *data)
          catch_command_errors returns non-zero on success!  */
       if (catch_command_errors (exec_file_attach, execarg,
 				!batch_flag, RETURN_MASK_ALL))
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	{
+	  volatile struct gdb_exception e;
+
+	  TRY_CATCH (e, RETURN_MASK_ALL)
+	    {
+	      symbol_file_add_main (symarg, !batch_flag);
+	    }
+	  exception_print (gdb_stderr, e);
+	}
     }
   else
     {
@@ -959,8 +966,15 @@ captured_main (void *data)
 	catch_command_errors (exec_file_attach, execarg,
 			      !batch_flag, RETURN_MASK_ALL);
       if (symarg != NULL)
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	{
+	  volatile struct gdb_exception e;
+
+	  TRY_CATCH (e, RETURN_MASK_ALL)
+	    {
+	      symbol_file_add_main (symarg, !batch_flag);
+	    }
+	  exception_print (gdb_stderr, e);
+	}
     }
 
   if (corearg && pidarg)
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -87,7 +87,7 @@ int readnow_symbol_files;	/* Read full symbols immediately.  */
 
 static void load_command (char *, int);
 
-static void symbol_file_add_main_1 (char *args, int from_tty, int flags);
+static void symbol_file_add_main_1 (const char *args, int from_tty, int flags);
 
 static void add_symbol_file_command (char *, int);
 
@@ -1200,8 +1200,8 @@ symbol_file_add_from_bfd (bfd *abfd, int add_flags,
    loaded file.  See symbol_file_add_with_addrs's comments for details.  */
 
 struct objfile *
-symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
-		 int flags)
+symbol_file_add (const char *name, int add_flags,
+		 struct section_addr_info *addrs, int flags)
 {
   bfd *bfd = symfile_bfd_open (name);
   struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
@@ -1221,13 +1221,13 @@ symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
    command itself.  */
 
 void
-symbol_file_add_main (char *args, int from_tty)
+symbol_file_add_main (const char *args, int from_tty)
 {
   symbol_file_add_main_1 (args, from_tty, 0);
 }
 
 static void
-symbol_file_add_main_1 (char *args, int from_tty, int flags)
+symbol_file_add_main_1 (const char *args, int from_tty, int flags)
 {
   const int add_flags = (current_inferior ()->symfile_flags
 			 | SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0));
@@ -1652,31 +1652,31 @@ gdb_bfd_open_maybe_remote (const char *name)
    absolute).  In case of trouble, error() is called.  */
 
 bfd *
-symfile_bfd_open (char *name)
+symfile_bfd_open (const char *cname)
 {
   bfd *sym_bfd;
   int desc;
-  char *absolute_name;
+  char *name, *absolute_name;
   struct cleanup *back_to;
 
-  if (remote_filename_p (name))
+  if (remote_filename_p (cname))
     {
-      sym_bfd = remote_bfd_open (name, gnutarget);
+      sym_bfd = remote_bfd_open (cname, gnutarget);
       if (!sym_bfd)
-	error (_("`%s': can't open to read symbols: %s."), name,
+	error (_("`%s': can't open to read symbols: %s."), cname,
 	       bfd_errmsg (bfd_get_error ()));
 
       if (!bfd_check_format (sym_bfd, bfd_object))
 	{
 	  make_cleanup_bfd_unref (sym_bfd);
-	  error (_("`%s': can't read symbols: %s."), name,
+	  error (_("`%s': can't read symbols: %s."), cname,
 		 bfd_errmsg (bfd_get_error ()));
 	}
 
       return sym_bfd;
     }
 
-  name = tilde_expand (name);	/* Returns 1st new malloc'd copy.  */
+  name = tilde_expand (cname);	/* Returns 1st new malloc'd copy.  */
 
   /* Look down path for it, allocate 2nd new malloc'd copy.  */
   desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -477,7 +477,7 @@ enum symfile_add_flags
 
 extern void new_symfile_objfile (struct objfile *, int);
 
-extern struct objfile *symbol_file_add (char *, int,
+extern struct objfile *symbol_file_add (const char *, int,
 					struct section_addr_info *, int);
 
 extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
@@ -528,7 +528,7 @@ extern void set_initial_language (void);
 
 extern void find_lowest_section (bfd *, asection *, void *);
 
-extern bfd *symfile_bfd_open (char *);
+extern bfd *symfile_bfd_open (const char *);
 
 extern bfd *gdb_bfd_open_maybe_remote (const char *);
 
@@ -572,7 +572,7 @@ extern CORE_ADDR overlay_unmapped_address (CORE_ADDR, struct obj_section *);
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Load symbols from a file.  */
-extern void symbol_file_add_main (char *args, int from_tty);
+extern void symbol_file_add_main (const char *args, int from_tty);
 
 /* Clear GDB symbol tables.  */
 extern void symbol_file_clear (int from_tty);


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-15 19:37 [patchv3 1/5] Mostly code cleanup: Constification Jan Kratochvil
@ 2013-09-16 22:22 ` Doug Evans
  2013-09-17  6:48   ` Jan Kratochvil
  2013-09-18 14:08   ` Jan Kratochvil
  0 siblings, 2 replies; 12+ messages in thread
From: Doug Evans @ 2013-09-16 22:22 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Jan Kratochvil writes:
 > Hi,
 > 
 > this is mostly a code cleanup, just the main.c part is not exactly the same.
 > 
 > 
 > Jan
 > 
 > 
 > gdb/
 > 2013-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 > 
 > 	Constification.
 > 	* main.c (captured_main): Wrap symbol_file_add_main calls with
 > 	TRY_CATCH.  Twice.
 > 	* symfile.c (symbol_file_add_main_1): Make args parameter const.
 > 	(symbol_file_add): Make name parameter const.
 > 	(symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
 > 	(symfile_bfd_open): Make name parameter const, rename it to cname.  Add
 > 	variable name.  Change their usage accordingly.
 > 	* symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
 > 	const.
 > 	(symbol_file_add_main): Make args parameter const.
 > 
 > --- a/gdb/main.c
 > +++ b/gdb/main.c
 > @@ -950,8 +950,15 @@ captured_main (void *data)
 >           catch_command_errors returns non-zero on success!  */
 >        if (catch_command_errors (exec_file_attach, execarg,
 >  				!batch_flag, RETURN_MASK_ALL))
 > -	catch_command_errors (symbol_file_add_main, symarg,
 > -			      !batch_flag, RETURN_MASK_ALL);
 > +	{
 > +	  volatile struct gdb_exception e;
 > +
 > +	  TRY_CATCH (e, RETURN_MASK_ALL)
 > +	    {
 > +	      symbol_file_add_main (symarg, !batch_flag);
 > +	    }
 > +	  exception_print (gdb_stderr, e);
 > +	}
 >      }
 >    else
 >      {
 > @@ -959,8 +966,15 @@ captured_main (void *data)
 >  	catch_command_errors (exec_file_attach, execarg,
 >  			      !batch_flag, RETURN_MASK_ALL);
 >        if (symarg != NULL)
 > -	catch_command_errors (symbol_file_add_main, symarg,
 > -			      !batch_flag, RETURN_MASK_ALL);
 > +	{
 > +	  volatile struct gdb_exception e;
 > +
 > +	  TRY_CATCH (e, RETURN_MASK_ALL)
 > +	    {
 > +	      symbol_file_add_main (symarg, !batch_flag);
 > +	    }
 > +	  exception_print (gdb_stderr, e);
 > +	}
 >      }
 >  
 >    if (corearg && pidarg)

There is catch_command_errors_const.
Would that work here?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-16 22:22 ` Doug Evans
@ 2013-09-17  6:48   ` Jan Kratochvil
  2013-09-17 18:39     ` Tom Tromey
  2013-09-18 14:08   ` Jan Kratochvil
  1 sibling, 1 reply; 12+ messages in thread
From: Jan Kratochvil @ 2013-09-17  6:48 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

On Tue, 17 Sep 2013 00:22:12 +0200, Doug Evans wrote:
> Jan Kratochvil writes:
>  > -	catch_command_errors (symbol_file_add_main, symarg,
>  > -			      !batch_flag, RETURN_MASK_ALL);
>  > +	{
>  > +	  volatile struct gdb_exception e;
>  > +
>  > +	  TRY_CATCH (e, RETURN_MASK_ALL)
>  > +	    {
>  > +	      symbol_file_add_main (symarg, !batch_flag);
>  > +	    }
>  > +	  exception_print (gdb_stderr, e);
>  > +	}
>  >      }
>  >  
>  >    if (corearg && pidarg)
> 
> There is catch_command_errors_const.
> Would that work here?

It would work here.  But I thought catch_command_errors* is deprecated in
favor of TRY_CATCH.  Maybe I could split this patch in two, but the end would
be the same.


Jan


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17  6:48   ` Jan Kratochvil
@ 2013-09-17 18:39     ` Tom Tromey
  2013-09-17 19:24       ` Doug Evans
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2013-09-17 18:39 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Doug Evans, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> But I thought catch_command_errors* is deprecated in favor of
Jan> TRY_CATCH.

It's certainly easier to use TRY_CATCH.
I wouldn't mind getting rid of the wrappers.

Tom


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17 18:39     ` Tom Tromey
@ 2013-09-17 19:24       ` Doug Evans
  2013-09-17 19:32         ` Tom Tromey
  0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2013-09-17 19:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Jan Kratochvil, gdb-patches

On Tue, Sep 17, 2013 at 11:05 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> But I thought catch_command_errors* is deprecated in favor of
> Jan> TRY_CATCH.
>
> It's certainly easier to use TRY_CATCH.
> I wouldn't mind getting rid of the wrappers.
>
> Tom

What's wrong with utility wrappers?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17 19:24       ` Doug Evans
@ 2013-09-17 19:32         ` Tom Tromey
  2013-09-17 19:37           ` Jan Kratochvil
  2013-09-18 13:45           ` Joel Brobecker
  0 siblings, 2 replies; 12+ messages in thread
From: Tom Tromey @ 2013-09-17 19:32 UTC (permalink / raw)
  To: Doug Evans; +Cc: Jan Kratochvil, gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> What's wrong with utility wrappers?

In the general case they require the introduction of a new function, a
new type, and marshalling and unmarshalling code.  This is verbose and
error prone.

I suppose catch_command_errors* aren't quite so bad.

Tom


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17 19:32         ` Tom Tromey
@ 2013-09-17 19:37           ` Jan Kratochvil
  2013-09-17 19:50             ` Doug Evans
  2013-09-18 13:45           ` Joel Brobecker
  1 sibling, 1 reply; 12+ messages in thread
From: Jan Kratochvil @ 2013-09-17 19:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Doug Evans, gdb-patches

On Tue, 17 Sep 2013 21:32:48 +0200, Tom Tromey wrote:
> >>>>> "Doug" == Doug Evans <dje@google.com> writes:
> 
> Doug> What's wrong with utility wrappers?
> 
> In the general case they require the introduction of a new function, a
> new type, and marshalling and unmarshalling code.  This is verbose and
> error prone.
> 
> I suppose catch_command_errors* aren't quite so bad.

* catch_command_errors* use non-public function print_any_exception() with
  unclear differences from the public function exception_print().

* The body of catch_command_errors* is several lines of code which is rather
  questionable whether it is worth wrapping in a function.

But I sure do not mind much either way, primarily it should be converted to
C++ try {} before the discussion makes sense to continue.


Jan


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17 19:37           ` Jan Kratochvil
@ 2013-09-17 19:50             ` Doug Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Doug Evans @ 2013-09-17 19:50 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On Tue, Sep 17, 2013 at 12:37 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Tue, 17 Sep 2013 21:32:48 +0200, Tom Tromey wrote:
>> >>>>> "Doug" == Doug Evans <dje@google.com> writes:
>>
>> Doug> What's wrong with utility wrappers?
>>
>> In the general case they require the introduction of a new function, a
>> new type, and marshalling and unmarshalling code.  This is verbose and
>> error prone.
>>
>> I suppose catch_command_errors* aren't quite so bad.

They're rather trivial, and abandoning them is isomorphic (IMO) to
asking people to instead duplicate their contents.  Sounds like the
definition of a good wrapper, or any utility function really.
[There is a discussion to be had about print_any_exception, but that's
just cleanup ...]

> * catch_command_errors* use non-public function print_any_exception() with
>   unclear differences from the public function exception_print().

Plus I saw a call to target_terminal_ours.  Not sure it's present on
all code paths.

> * The body of catch_command_errors* is several lines of code which is rather
>   questionable whether it is worth wrapping in a function.

A better measure is how many lines of code is there to use it versus not use it?
[Plus, all else being equal, wouldn't the larger the amount of code
that can be replaced with a subroutine call improve the worthiness of
creating a utility function?]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-17 19:32         ` Tom Tromey
  2013-09-17 19:37           ` Jan Kratochvil
@ 2013-09-18 13:45           ` Joel Brobecker
  1 sibling, 0 replies; 12+ messages in thread
From: Joel Brobecker @ 2013-09-18 13:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Doug Evans, Jan Kratochvil, gdb-patches

> In the general case they require the introduction of a new function, a
> new type, and marshalling and unmarshalling code.  This is verbose and
> error prone.

My feeling as well.

-- 
Joel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-16 22:22 ` Doug Evans
  2013-09-17  6:48   ` Jan Kratochvil
@ 2013-09-18 14:08   ` Jan Kratochvil
  2013-09-18 17:10     ` Doug Evans
  1 sibling, 1 reply; 12+ messages in thread
From: Jan Kratochvil @ 2013-09-18 14:08 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

On Tue, 17 Sep 2013 00:22:12 +0200, Doug Evans wrote:
> Jan Kratochvil writes:
[...]
>  > -	catch_command_errors (symbol_file_add_main, symarg,
>  > -			      !batch_flag, RETURN_MASK_ALL);
>  > +	{
>  > +	  volatile struct gdb_exception e;
>  > +
>  > +	  TRY_CATCH (e, RETURN_MASK_ALL)
>  > +	    {
>  > +	      symbol_file_add_main (symarg, !batch_flag);
>  > +	    }
>  > +	  exception_print (gdb_stderr, e);
>  > +	}
>  >      }
>  >  
>  >    if (corearg && pidarg)
> 
> There is catch_command_errors_const.
> Would that work here?

I did not know about catch_command_errors_const.

You are right the conversion of catch_command_errors* to TRY_CATCH - and later
to C++ try {} - is off-topic for this patch.


Thanks,
Jan


gdb/
2013-09-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Constification.
	* main.c (captured_main): Wrap symbol_file_add_main calls with
	TRY_CATCH.  Twice.
	* symfile.c (symbol_file_add_main_1): Make args parameter const.
	(symbol_file_add): Make name parameter const.
	(symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
	(symfile_bfd_open): Make name parameter const, rename it to cname.  Add
	variable name.  Change their usage accordingly.
	* symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
	const.
	(symbol_file_add_main): Make args parameter const.

--- a/gdb/main.c
+++ b/gdb/main.c
@@ -957,8 +957,8 @@ captured_main (void *data)
          catch_command_errors returns non-zero on success!  */
       if (catch_command_errors (exec_file_attach, execarg,
 				!batch_flag, RETURN_MASK_ALL))
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	catch_command_errors_const (symbol_file_add_main, symarg,
+				    !batch_flag, RETURN_MASK_ALL);
     }
   else
     {
@@ -966,8 +966,8 @@ captured_main (void *data)
 	catch_command_errors (exec_file_attach, execarg,
 			      !batch_flag, RETURN_MASK_ALL);
       if (symarg != NULL)
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	catch_command_errors_const (symbol_file_add_main, symarg,
+				    !batch_flag, RETURN_MASK_ALL);
     }
 
   if (corearg && pidarg)
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -87,7 +87,7 @@ int readnow_symbol_files;	/* Read full symbols immediately.  */
 
 static void load_command (char *, int);
 
-static void symbol_file_add_main_1 (char *args, int from_tty, int flags);
+static void symbol_file_add_main_1 (const char *args, int from_tty, int flags);
 
 static void add_symbol_file_command (char *, int);
 
@@ -1200,8 +1200,8 @@ symbol_file_add_from_bfd (bfd *abfd, int add_flags,
    loaded file.  See symbol_file_add_with_addrs's comments for details.  */
 
 struct objfile *
-symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
-		 int flags)
+symbol_file_add (const char *name, int add_flags,
+		 struct section_addr_info *addrs, int flags)
 {
   bfd *bfd = symfile_bfd_open (name);
   struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
@@ -1221,13 +1221,13 @@ symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
    command itself.  */
 
 void
-symbol_file_add_main (char *args, int from_tty)
+symbol_file_add_main (const char *args, int from_tty)
 {
   symbol_file_add_main_1 (args, from_tty, 0);
 }
 
 static void
-symbol_file_add_main_1 (char *args, int from_tty, int flags)
+symbol_file_add_main_1 (const char *args, int from_tty, int flags)
 {
   const int add_flags = (current_inferior ()->symfile_flags
 			 | SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0));
@@ -1652,31 +1652,31 @@ gdb_bfd_open_maybe_remote (const char *name)
    absolute).  In case of trouble, error() is called.  */
 
 bfd *
-symfile_bfd_open (char *name)
+symfile_bfd_open (const char *cname)
 {
   bfd *sym_bfd;
   int desc;
-  char *absolute_name;
+  char *name, *absolute_name;
   struct cleanup *back_to;
 
-  if (remote_filename_p (name))
+  if (remote_filename_p (cname))
     {
-      sym_bfd = remote_bfd_open (name, gnutarget);
+      sym_bfd = remote_bfd_open (cname, gnutarget);
       if (!sym_bfd)
-	error (_("`%s': can't open to read symbols: %s."), name,
+	error (_("`%s': can't open to read symbols: %s."), cname,
 	       bfd_errmsg (bfd_get_error ()));
 
       if (!bfd_check_format (sym_bfd, bfd_object))
 	{
 	  make_cleanup_bfd_unref (sym_bfd);
-	  error (_("`%s': can't read symbols: %s."), name,
+	  error (_("`%s': can't read symbols: %s."), cname,
 		 bfd_errmsg (bfd_get_error ()));
 	}
 
       return sym_bfd;
     }
 
-  name = tilde_expand (name);	/* Returns 1st new malloc'd copy.  */
+  name = tilde_expand (cname);	/* Returns 1st new malloc'd copy.  */
 
   /* Look down path for it, allocate 2nd new malloc'd copy.  */
   desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -477,7 +477,7 @@ enum symfile_add_flags
 
 extern void new_symfile_objfile (struct objfile *, int);
 
-extern struct objfile *symbol_file_add (char *, int,
+extern struct objfile *symbol_file_add (const char *, int,
 					struct section_addr_info *, int);
 
 extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
@@ -528,7 +528,7 @@ extern void set_initial_language (void);
 
 extern void find_lowest_section (bfd *, asection *, void *);
 
-extern bfd *symfile_bfd_open (char *);
+extern bfd *symfile_bfd_open (const char *);
 
 extern bfd *gdb_bfd_open_maybe_remote (const char *);
 
@@ -572,7 +572,7 @@ extern CORE_ADDR overlay_unmapped_address (CORE_ADDR, struct obj_section *);
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Load symbols from a file.  */
-extern void symbol_file_add_main (char *args, int from_tty);
+extern void symbol_file_add_main (const char *args, int from_tty);
 
 /* Clear GDB symbol tables.  */
 extern void symbol_file_clear (int from_tty);


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-18 14:08   ` Jan Kratochvil
@ 2013-09-18 17:10     ` Doug Evans
  2013-09-19 12:45       ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 12+ messages in thread
From: Doug Evans @ 2013-09-18 17:10 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On Wed, Sep 18, 2013 at 7:08 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> gdb/
> 2013-09-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>         Constification.
>         * main.c (captured_main): Wrap symbol_file_add_main calls with
>         TRY_CATCH.  Twice.
>         * symfile.c (symbol_file_add_main_1): Make args parameter const.
>         (symbol_file_add): Make name parameter const.
>         (symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
>         (symfile_bfd_open): Make name parameter const, rename it to cname.  Add
>         variable name.  Change their usage accordingly.
>         * symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
>         const.
>         (symbol_file_add_main): Make args parameter const.

LGTM (modulo updating ChangeLog entry for captured_main).
thanks


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [commit] [patchv3 1/5] Mostly code cleanup: Constification
  2013-09-18 17:10     ` Doug Evans
@ 2013-09-19 12:45       ` Jan Kratochvil
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Kratochvil @ 2013-09-19 12:45 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

On Wed, 18 Sep 2013 19:10:34 +0200, Doug Evans wrote:
> LGTM (modulo updating ChangeLog entry for captured_main).

Checked in.


Thanks,
Jan


https://sourceware.org/ml/gdb-cvs/2013-09/msg00118.html

--- src/gdb/ChangeLog	2013/09/18 17:47:56	1.16013
+++ src/gdb/ChangeLog	2013/09/19 12:44:45	1.16014
@@ -1,3 +1,17 @@
+2013-09-19  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Constification.
+	* main.c (captured_main): Replace catch_command_errors by
+	catch_command_errors_const.  Twice.
+	* symfile.c (symbol_file_add_main_1): Make args parameter const.
+	(symbol_file_add): Make name parameter const.
+	(symbol_file_add_main, symbol_file_add_main_1): Make args parameter const.
+	(symfile_bfd_open): Make name parameter const, rename it to cname.  Add
+	variable name.  Change their usage accordingly.
+	* symfile.h (symbol_file_add, symfile_bfd_open): Make first parameter
+	const.
+	(symbol_file_add_main): Make args parameter const.
+
 2013-09-18  Raunaq Bathija  <raunaq12@in.ibm.com>
 	    Ulrich Weigand  <uweigand@de.ibm.com>
 
--- src/gdb/main.c	2013/09/18 11:41:38	1.131
+++ src/gdb/main.c	2013/09/19 12:44:46	1.132
@@ -957,8 +957,8 @@
          catch_command_errors returns non-zero on success!  */
       if (catch_command_errors (exec_file_attach, execarg,
 				!batch_flag, RETURN_MASK_ALL))
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	catch_command_errors_const (symbol_file_add_main, symarg,
+				    !batch_flag, RETURN_MASK_ALL);
     }
   else
     {
@@ -966,8 +966,8 @@
 	catch_command_errors (exec_file_attach, execarg,
 			      !batch_flag, RETURN_MASK_ALL);
       if (symarg != NULL)
-	catch_command_errors (symbol_file_add_main, symarg,
-			      !batch_flag, RETURN_MASK_ALL);
+	catch_command_errors_const (symbol_file_add_main, symarg,
+				    !batch_flag, RETURN_MASK_ALL);
     }
 
   if (corearg && pidarg)
--- src/gdb/symfile.c	2013/09/13 14:21:03	1.389
+++ src/gdb/symfile.c	2013/09/19 12:44:46	1.390
@@ -87,7 +87,7 @@
 
 static void load_command (char *, int);
 
-static void symbol_file_add_main_1 (char *args, int from_tty, int flags);
+static void symbol_file_add_main_1 (const char *args, int from_tty, int flags);
 
 static void add_symbol_file_command (char *, int);
 
@@ -1200,8 +1200,8 @@
    loaded file.  See symbol_file_add_with_addrs's comments for details.  */
 
 struct objfile *
-symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
-		 int flags)
+symbol_file_add (const char *name, int add_flags,
+		 struct section_addr_info *addrs, int flags)
 {
   bfd *bfd = symfile_bfd_open (name);
   struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
@@ -1221,13 +1221,13 @@
    command itself.  */
 
 void
-symbol_file_add_main (char *args, int from_tty)
+symbol_file_add_main (const char *args, int from_tty)
 {
   symbol_file_add_main_1 (args, from_tty, 0);
 }
 
 static void
-symbol_file_add_main_1 (char *args, int from_tty, int flags)
+symbol_file_add_main_1 (const char *args, int from_tty, int flags)
 {
   const int add_flags = (current_inferior ()->symfile_flags
 			 | SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0));
@@ -1652,31 +1652,31 @@
    absolute).  In case of trouble, error() is called.  */
 
 bfd *
-symfile_bfd_open (char *name)
+symfile_bfd_open (const char *cname)
 {
   bfd *sym_bfd;
   int desc;
-  char *absolute_name;
+  char *name, *absolute_name;
   struct cleanup *back_to;
 
-  if (remote_filename_p (name))
+  if (remote_filename_p (cname))
     {
-      sym_bfd = remote_bfd_open (name, gnutarget);
+      sym_bfd = remote_bfd_open (cname, gnutarget);
       if (!sym_bfd)
-	error (_("`%s': can't open to read symbols: %s."), name,
+	error (_("`%s': can't open to read symbols: %s."), cname,
 	       bfd_errmsg (bfd_get_error ()));
 
       if (!bfd_check_format (sym_bfd, bfd_object))
 	{
 	  make_cleanup_bfd_unref (sym_bfd);
-	  error (_("`%s': can't read symbols: %s."), name,
+	  error (_("`%s': can't read symbols: %s."), cname,
 		 bfd_errmsg (bfd_get_error ()));
 	}
 
       return sym_bfd;
     }
 
-  name = tilde_expand (name);	/* Returns 1st new malloc'd copy.  */
+  name = tilde_expand (cname);	/* Returns 1st new malloc'd copy.  */
 
   /* Look down path for it, allocate 2nd new malloc'd copy.  */
   desc = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, name,
--- src/gdb/symfile.h	2013/08/07 20:06:37	1.129
+++ src/gdb/symfile.h	2013/09/19 12:44:46	1.130
@@ -477,7 +477,7 @@
 
 extern void new_symfile_objfile (struct objfile *, int);
 
-extern struct objfile *symbol_file_add (char *, int,
+extern struct objfile *symbol_file_add (const char *, int,
 					struct section_addr_info *, int);
 
 extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
@@ -528,7 +528,7 @@
 
 extern void find_lowest_section (bfd *, asection *, void *);
 
-extern bfd *symfile_bfd_open (char *);
+extern bfd *symfile_bfd_open (const char *);
 
 extern bfd *gdb_bfd_open_maybe_remote (const char *);
 
@@ -572,7 +572,7 @@
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Load symbols from a file.  */
-extern void symbol_file_add_main (char *args, int from_tty);
+extern void symbol_file_add_main (const char *args, int from_tty);
 
 /* Clear GDB symbol tables.  */
 extern void symbol_file_clear (int from_tty);


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-09-19 12:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-15 19:37 [patchv3 1/5] Mostly code cleanup: Constification Jan Kratochvil
2013-09-16 22:22 ` Doug Evans
2013-09-17  6:48   ` Jan Kratochvil
2013-09-17 18:39     ` Tom Tromey
2013-09-17 19:24       ` Doug Evans
2013-09-17 19:32         ` Tom Tromey
2013-09-17 19:37           ` Jan Kratochvil
2013-09-17 19:50             ` Doug Evans
2013-09-18 13:45           ` Joel Brobecker
2013-09-18 14:08   ` Jan Kratochvil
2013-09-18 17:10     ` Doug Evans
2013-09-19 12:45       ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox