This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] [patchv3 1/5] Mostly code cleanup: Constification
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 19 Sep 2013 14:45:19 +0200
- Subject: [commit] [patchv3 1/5] Mostly code cleanup: Constification
- Authentication-results: sourceware.org; auth=none
- References: <20130915193742 dot GA20411 at host2 dot jankratochvil dot net> <21047 dot 33940 dot 998451 dot 19883 at ruffy dot mtv dot corp dot google dot com> <20130918140806 dot GA9628 at host2 dot jankratochvil dot net> <CADPb22Q-SEEpDjK6i4KMZ1JTp2+A5bS+e1YZJ1QFNo1Unp8gkA at mail dot gmail dot com>
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);