From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16321 invoked by alias); 1 Oct 2013 04:15:16 -0000 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 Received: (qmail 16280 invoked by uid 89); 1 Oct 2013 04:15:13 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2013 04:15:13 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r914FBXH018450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Oct 2013 00:15:11 -0400 Received: from psique (ovpn-113-41.phx2.redhat.com [10.3.113.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r914F7M2001898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 1 Oct 2013 00:15:09 -0400 From: Sergio Durigan Junior To: Keith Seitz Cc: "gdb-patches\@sourceware.org ml" Subject: Re: [RFA 4/4] Constify parse_linesepc References: <5249C987.50809@redhat.com> X-URL: http://www.redhat.com Date: Tue, 01 Oct 2013 04:15:00 -0000 In-Reply-To: <5249C987.50809@redhat.com> (Keith Seitz's message of "Mon, 30 Sep 2013 11:57:11 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00008.txt.bz2 On Monday, September 30 2013, Keith Seitz wrote: > Hi, > > This last patch const-ifies a fair bit of linespec.c around parse_linespec. Looks good too, but I can't approve it. Thanks again! > Tested as in all previous patches. > > Keith > > ChangeLog > 2013-09-24 Keith Seitz > > * linespec.c (struct ls_parser): Make 'saved_arg' const. > (parse_linespec): Make 'argptr' const. > Remove temporary cast of 'argptr' to const char **. > (decode_line_full): Pass const pointer to parse_linespec. > (decode_line_1): Likewise. > (decode_objc): Make local variable 'new_argptr' const. > (find_function_symbols): Remove temporary cast to char * > to find_imps. > * objc-lang.c (find_imps): Make argument 'method' const. > Return const. > * objc-lang.h (find_imps): Likewise. > diff --git a/gdb/linespec.c b/gdb/linespec.c > index 96f1d07..9468f26 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -278,7 +278,7 @@ struct ls_parser > struct > { > /* Save head of input stream. */ > - char *saved_arg; > + const char *saved_arg; > > /* Head of the input stream. */ > const char **stream; > @@ -320,7 +320,7 @@ static CORE_ADDR linespec_expression_to_pc (const char **exp_ptr); > > static struct symtabs_and_lines decode_objc (struct linespec_state *self, > linespec_p ls, > - char **argptr); > + const char **argptr); > > static VEC (symtab_ptr) *symtabs_from_filename (const char *); > > @@ -2144,7 +2144,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls) > /* Parse the linespec in ARGPTR. */ > > static struct symtabs_and_lines > -parse_linespec (linespec_parser *parser, char **argptr) > +parse_linespec (linespec_parser *parser, const char **argptr) > { > linespec_token token; > struct symtabs_and_lines values; > @@ -2175,7 +2175,7 @@ parse_linespec (linespec_parser *parser, char **argptr) > parser->keyword_ok = 0; > > parser->lexer.saved_arg = *argptr; > - parser->lexer.stream = (const char **) argptr; > + parser->lexer.stream = argptr; > file_exception.reason = 0; > > /* Initialize the default symtab and line offset. */ > @@ -2426,6 +2426,7 @@ decode_line_full (char **argptr, int flags, > VEC (const_char_ptr) *filters = NULL; > linespec_parser parser; > struct linespec_state *state; > + const char *copy, *orig; > > gdb_assert (canonical != NULL); > /* The filter only makes sense for 'all'. */ > @@ -2441,7 +2442,9 @@ decode_line_full (char **argptr, int flags, > cleanups = make_cleanup (linespec_parser_delete, &parser); > save_current_program_space (); > > - result = parse_linespec (&parser, argptr); > + orig = copy = *argptr; > + result = parse_linespec (&parser, ©); > + *argptr += copy - orig; > state = PARSER_STATE (&parser); > > gdb_assert (result.nelts == 1 || canonical->pre_expanded); > @@ -2496,13 +2499,16 @@ decode_line_1 (char **argptr, int flags, > struct symtabs_and_lines result; > linespec_parser parser; > struct cleanup *cleanups; > + const char *copy, *orig; > > linespec_parser_new (&parser, flags, current_language, default_symtab, > default_line, NULL); > cleanups = make_cleanup (linespec_parser_delete, &parser); > save_current_program_space (); > > - result = parse_linespec (&parser, argptr); > + orig = copy = *argptr; > + result = parse_linespec (&parser, ©); > + *argptr += copy - orig; > > do_cleanups (cleanups); > return result; > @@ -2602,12 +2608,12 @@ linespec_expression_to_pc (const char **exp_ptr) > the existing C++ code to let the user choose one. */ > > static struct symtabs_and_lines > -decode_objc (struct linespec_state *self, linespec_p ls, char **argptr) > +decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr) > { > struct collect_info info; > VEC (const_char_ptr) *symbol_names = NULL; > struct symtabs_and_lines values; > - char *new_argptr; > + const char *new_argptr; > struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr), > &symbol_names); > > @@ -3053,7 +3059,7 @@ find_function_symbols (struct linespec_state *state, > info.file_symtabs = file_symtabs; > > /* Try NAME as an Objective-C selector. */ > - find_imps ((char *) name, &symbol_names); > + find_imps (name, &symbol_names); > if (!VEC_empty (const_char_ptr, symbol_names)) > add_all_symbol_names_from_pspace (&info, NULL, symbol_names); > else > diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c > index cf99a0f..bcce435 100644 > --- a/gdb/objc-lang.c > +++ b/gdb/objc-lang.c > @@ -1072,7 +1072,7 @@ uniquify_strings (VEC (const_char_ptr) **strings) > } > > /* > - * Function: find_imps (char *selector, struct symbol **sym_arr) > + * Function: find_imps (const char *selector, struct symbol **sym_arr) > * > * Input: a string representing a selector > * a pointer to an array of symbol pointers > @@ -1101,8 +1101,8 @@ uniquify_strings (VEC (const_char_ptr) **strings) > * be the index of the first non-debuggable one). > */ > > -char * > -find_imps (char *method, VEC (const_char_ptr) **symbol_names) > +const char * > +find_imps (const char *method, VEC (const_char_ptr) **symbol_names) > { > char type = '\0'; > char *class = NULL; > diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h > index 23fac1b..2409363 100644 > --- a/gdb/objc-lang.h > +++ b/gdb/objc-lang.h > @@ -36,7 +36,8 @@ extern char *objc_demangle (const char *mangled, int options); > > extern int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc); > > -extern char *find_imps (char *method, VEC (const_char_ptr) **symbol_names); > +extern const char * > + find_imps (const char *method, VEC (const_char_ptr) **symbol_names); > > extern struct value *value_nsstring (struct gdbarch *gdbarch, > char *ptr, int len); -- Sergio