From: Keith Seitz <keiths@redhat.com>
To: "gdb-patches@sourceware.org ml" <gdb-patches@sourceware.org>
Subject: [RFA 4/4] Constify parse_linesepc
Date: Mon, 30 Sep 2013 18:57:00 -0000 [thread overview]
Message-ID: <5249C987.50809@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
Hi,
This last patch const-ifies a fair bit of linespec.c around parse_linespec.
Tested as in all previous patches.
Keith
ChangeLog
2013-09-24 Keith Seitz <keiths@redhat.com>
* 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.
[-- Attachment #2: constify-parse_linespec.patch --]
[-- Type: text/x-patch, Size: 4843 bytes --]
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);
next reply other threads:[~2013-09-30 18:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 18:57 Keith Seitz [this message]
2013-10-01 4:15 ` Sergio Durigan Junior
2013-10-01 20:16 ` Tom Tromey
2013-10-02 4:38 ` Keith Seitz
2013-10-16 9:57 ` Regression for gdb.pascal/* [Re: [RFA 4/4] Constify parse_linesepc] Jan Kratochvil
2013-10-16 22:07 ` Sergio Durigan Junior
2013-10-16 23:40 ` Sergio Durigan Junior
2013-10-17 18:18 ` Keith Seitz
2013-10-17 20:52 ` Tom Tromey
2013-10-18 17:20 ` Jan Kratochvil
2013-10-18 19:09 ` [pascal patch] Use case_sensitive_off [Re: Regression for gdb.pascal/* [Re: [RFA 4/4] Constify parse_linesepc]] Jan Kratochvil
2013-10-18 19:34 ` Regression for gdb.pascal/* [Re: [RFA 4/4] Constify parse_linesepc] Jan Kratochvil
2013-10-20 13:17 ` Pierre Muller
2013-10-20 13:27 ` Jan Kratochvil
2013-10-29 16:39 ` Tom Tromey
2013-10-31 16:14 ` Pierre Muller
2013-11-13 20:43 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5249C987.50809@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox