From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14102 invoked by alias); 17 Oct 2012 18:11:22 -0000 Received: (qmail 14094 invoked by uid 22791); 17 Oct 2012 18:11:20 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKTIP,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ 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; Wed, 17 Oct 2012 18:11:01 +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.14.4/8.14.4) with ESMTP id q9HIB1KB023349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Oct 2012 14:11:01 -0400 Received: from barimba (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 q9HIAxaB005786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 17 Oct 2012 14:11:00 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: constify symtab_to_fullname Date: Wed, 17 Oct 2012 18:11:00 -0000 Message-ID: <87fw5d2clo.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-10/txt/msg00292.txt.bz2 Andrew's recent patch made me realize that symtab_to_fullname could be constify'd. Let me know what you think. Tested by rebuilding. Tom 2012-10-17 Tom Tromey * tracepoint.c (print_one_static_tracepoint_marker): Constify. * symtab.c (iterate_over_some_symtabs): Constify. * source.h (symtab_to_fullname): Return 'const char *'. * source.c (symtab_to_fullname): Return 'const char *'. * python/py-symtab.c (stpy_fullname): Constify. * cli/cli-cmds.c (edit_command): Constify. * breakpoint.c (print_breakpoint_location) (update_static_tracepoint): Constify. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8eeeacf..bebad75 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5689,7 +5689,7 @@ print_breakpoint_location (struct breakpoint *b, if (ui_out_is_mi_like_p (uiout)) { struct symtab_and_line sal = find_pc_line (loc->address, 0); - char *fullname = symtab_to_fullname (sal.symtab); + const char *fullname = symtab_to_fullname (sal.symtab); if (fullname) ui_out_field_string (uiout, "fullname", fullname); @@ -13822,7 +13822,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) if (ui_out_is_mi_like_p (uiout)) { - char *fullname = symtab_to_fullname (sal2.symtab); + const char *fullname = symtab_to_fullname (sal2.symtab); if (fullname) ui_out_field_string (uiout, "fullname", fullname); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index dcf5369..b65262e 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -762,7 +762,8 @@ edit_command (char *arg, int from_tty) struct symbol *sym; char *arg1; char *editor; - char *p, *fn; + char *p; + const char *fn; /* Pull in the current default source line if necessary. */ if (arg == 0) diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 21a172c..c023ad5 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -126,7 +126,7 @@ stpy_get_objfile (PyObject *self, void *closure) static PyObject * stpy_fullname (PyObject *self, PyObject *args) { - char *fullname; + const char *fullname; struct symtab *symtab = NULL; STPY_REQUIRE_VALID (self, symtab); diff --git a/gdb/source.c b/gdb/source.c index 31e104f..bd11c63 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1081,7 +1081,7 @@ open_source_file (struct symtab *s) If this function fails to find the file that this symtab represents, NULL will be returned and s->fullname will be set to NULL. */ -char * +const char * symtab_to_fullname (struct symtab *s) { int r; diff --git a/gdb/source.h b/gdb/source.h index bf9a688..a8918a9 100644 --- a/gdb/source.h +++ b/gdb/source.h @@ -48,7 +48,7 @@ extern int find_and_open_source (const char *filename, negative number for error. */ extern int open_source_file (struct symtab *s); -extern char* symtab_to_fullname (struct symtab *s); +extern const char *symtab_to_fullname (struct symtab *s); /* Create and initialize the table S->line_charpos that records the positions of the lines in the source file, which is assumed to be diff --git a/gdb/symtab.c b/gdb/symtab.c index cbfe4d0..7e16222 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -242,7 +242,7 @@ iterate_over_some_symtabs (const char *name, if (real_path != NULL) { - char *fullname = symtab_to_fullname (s); + const char *fullname = symtab_to_fullname (s); if (fullname != NULL) { diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index cce8d00..6e55d57 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -4838,7 +4838,7 @@ print_one_static_tracepoint_marker (int count, if (ui_out_is_mi_like_p (uiout)) { - char *fullname = symtab_to_fullname (sal.symtab); + const char *fullname = symtab_to_fullname (sal.symtab); if (fullname) ui_out_field_string (uiout, "fullname", fullname);