{
completion_tracker tmp_tracker;
const char *source_filename
- = PARSER_EXPLICIT (parser)->source_filename;
+ = PARSER_EXPLICIT (parser)->source_filename.get ();
symbol_name_match_type match_type
= PARSER_EXPLICIT (parser)->func_name_match_type;
}
}
- PARSER_EXPLICIT (parser)->function_name = name.release ();
+ PARSER_EXPLICIT (parser)->function_name = std::move (name);
}
else
{
{
PARSER_RESULT (parser)->function_symbols = std::move (symbols);
PARSER_RESULT (parser)->minimal_symbols = std::move (minimal_symbols);
- PARSER_EXPLICIT (parser)->function_name = name.release ();
+ PARSER_EXPLICIT (parser)->function_name = std::move (name);
}
else
{
PARSER_RESULT (parser)->labels.label_symbols = std::move (labels);
PARSER_RESULT (parser)->labels.function_symbols
= std::move (symbols);
- PARSER_EXPLICIT (parser)->label_name = name.release ();
+ PARSER_EXPLICIT (parser)->label_name = std::move (name);
}
else if (token.type == LSTOKEN_STRING
&& *LS_TOKEN_STOKEN (token).ptr == '$')
{
/* The user-specified variable was not valid. Do not
throw an error here. parse_linespec will do it for us. */
- PARSER_EXPLICIT (parser)->function_name = name.release ();
+ PARSER_EXPLICIT (parser)->function_name = std::move (name);
return;
}
}
an error here. parse_linespec will do it for us. */
/* Save a copy of the name we were trying to lookup. */
- PARSER_EXPLICIT (parser)->function_name = name.release ();
+ PARSER_EXPLICIT (parser)->function_name = std::move (name);
return;
}
}
= std::move (labels);
PARSER_RESULT (parser)->labels.function_symbols
= std::move (symbols);
- PARSER_EXPLICIT (parser)->label_name = name.release ();
+ PARSER_EXPLICIT (parser)->label_name = std::move (name);
}
else
{
/* We don't know what it was, but it isn't a label. */
undefined_label_error
- (PARSER_EXPLICIT (parser)->function_name, name.get ());
+ (PARSER_EXPLICIT (parser)->function_name.get (),
+ name.get ());
}
}
/* No function was specified, so add the symbol name. */
gdb_assert (ls->labels.function_symbols.size () == 1);
block_symbol s = ls->labels.function_symbols.front ();
- explicit_loc->function_name = xstrdup (s.symbol->natural_name ());
+ explicit_loc->function_name
+ = make_unique_xstrdup (s.symbol->natural_name ());
}
}
{
if (ls->explicit_loc.source_filename)
throw_error (NOT_FOUND_ERROR, _("No line %d in file \"%s\"."),
- val.line, ls->explicit_loc.source_filename);
+ val.line, ls->explicit_loc.source_filename.get ());
else
throw_error (NOT_FOUND_ERROR, _("No line %d in the current file."),
val.line);
form so that displaying SOURCE_FILENAME can follow the current
FILENAME_DISPLAY_STRING setting. But as it is used only rarely
it has been kept for code simplicity only in absolute form. */
- ls->explicit_loc.source_filename = xstrdup (filename);
+ ls->explicit_loc.source_filename = make_unique_xstrdup (filename);
}
}
else
{
source_file_not_found_error (source_filename);
}
- result->explicit_loc.source_filename = xstrdup (source_filename);
+ result->explicit_loc.source_filename
+ = make_unique_xstrdup (source_filename);
}
else
{
if (symbols.empty () && minimal_symbols.empty ())
symbol_not_found_error (function_name,
- result->explicit_loc.source_filename);
+ result->explicit_loc.source_filename.get ());
- result->explicit_loc.function_name = xstrdup (function_name);
+ result->explicit_loc.function_name
+ = make_unique_xstrdup (function_name);
result->function_symbols = std::move (symbols);
result->minimal_symbols = std::move (minimal_symbols);
}
&symbols, label_name);
if (labels.empty ())
- undefined_label_error (result->explicit_loc.function_name,
+ undefined_label_error (result->explicit_loc.function_name.get (),
label_name);
- result->explicit_loc.label_name = xstrdup (label_name);
+ result->explicit_loc.label_name = make_unique_xstrdup (label_name);
result->labels.label_symbols = labels;
result->labels.function_symbols = std::move (symbols);
}
const explicit_location_spec *explicit_spec)
{
convert_explicit_location_spec_to_linespec (self, result,
- explicit_spec->source_filename,
- explicit_spec->function_name,
+ explicit_spec->source_filename.get (),
+ explicit_spec->function_name.get (),
explicit_spec->func_name_match_type,
- explicit_spec->label_name,
+ explicit_spec->label_name.get (),
explicit_spec->line_offset);
return convert_linespec_to_sals (self, result);
}
if (file_exception.reason >= 0)
{
/* Symtabs were found for the file. Record the filename. */
- PARSER_EXPLICIT (parser)->source_filename = user_filename.release ();
+ PARSER_EXPLICIT (parser)->source_filename = std::move (user_filename);
/* Get the next token. */
token = linespec_lexer_consume_token (parser);
throw_exception (std::move (file_exception));
/* Otherwise, the symbol is not found. */
- symbol_not_found_error (PARSER_EXPLICIT (parser)->function_name,
- PARSER_EXPLICIT (parser)->source_filename);
+ symbol_not_found_error
+ (PARSER_EXPLICIT (parser)->function_name.get (),
+ PARSER_EXPLICIT (parser)->source_filename.get ());
}
convert_to_sals:
{
parser.complete_what = linespec_complete_what::NOTHING;
- const char *func_name = PARSER_EXPLICIT (&parser)->function_name;
+ const char *func_name = PARSER_EXPLICIT (&parser)->function_name.get ();
std::vector<block_symbol> function_symbols;
std::vector<bound_minimal_symbol> minimal_symbols;
const char *word = parser.completion_word;
- complete_linespec_component (&parser, tracker,
- parser.completion_word,
- linespec_complete_what::FUNCTION,
- PARSER_EXPLICIT (&parser)->source_filename);
+ complete_linespec_component
+ (&parser, tracker,
+ parser.completion_word,
+ linespec_complete_what::FUNCTION,
+ PARSER_EXPLICIT (&parser)->source_filename.get ());
parser.complete_what = linespec_complete_what::NOTHING;
tracker.advance_custom_word_point_by (parser.completion_word - orig);
- complete_linespec_component (&parser, tracker,
- parser.completion_word,
- parser.complete_what,
- PARSER_EXPLICIT (&parser)->source_filename);
+ complete_linespec_component
+ (&parser, tracker,
+ parser.completion_word,
+ parser.complete_what,
+ PARSER_EXPLICIT (&parser)->source_filename.get ());
/* If we're past the "filename:function:label:offset" linespec, and
didn't find any match, then assume the user might want to create
memcpy (saved_arg, arg, new_argptr - arg);
saved_arg[new_argptr - arg] = '\0';
- ls->explicit_loc.function_name = xstrdup (saved_arg);
+ ls->explicit_loc.function_name = make_unique_xstrdup (saved_arg);
ls->function_symbols = std::move (symbols);
ls->minimal_symbols = std::move (minimal_symbols);
values = convert_linespec_to_sals (self, ls);
if (ls->explicit_loc.source_filename)
{
holder = string_printf ("%s:%s",
- ls->explicit_loc.source_filename,
+ ls->explicit_loc.source_filename.get (),
saved_arg);
str = holder.c_str ();
}
return std::string ("*") + addr_string;
}
-explicit_location_spec::explicit_location_spec ()
- : location_spec (EXPLICIT_LOCATION_SPEC)
+explicit_location_spec::explicit_location_spec (const char *function_name)
+ : location_spec (EXPLICIT_LOCATION_SPEC),
+ function_name (maybe_xstrdup (function_name))
{
}
-explicit_location_spec::~explicit_location_spec ()
-{
- xfree (source_filename);
- xfree (function_name);
- xfree (label_name);
-}
-
explicit_location_spec::explicit_location_spec
(const explicit_location_spec &other)
: location_spec (other),
- source_filename (maybe_xstrdup (other.source_filename)),
- function_name (maybe_xstrdup (other.function_name)),
+ source_filename (maybe_xstrdup (other.source_filename.get ())),
+ function_name (maybe_xstrdup (other.function_name.get ())),
func_name_match_type (other.func_name_match_type),
- label_name (maybe_xstrdup (other.label_name)),
+ label_name (maybe_xstrdup (other.label_name.get ())),
line_offset (other.line_offset)
{
}
{
if (!as_linespec)
buf.puts ("-source ");
- buf.puts (explicit_loc->source_filename);
+ buf.puts (explicit_loc->source_filename.get ());
need_space = true;
}
buf.puts ("-qualified ");
if (!as_linespec)
buf.puts ("-function ");
- buf.puts (explicit_loc->function_name);
+ buf.puts (explicit_loc->function_name.get ());
need_space = true;
}
buf.putc (space);
if (!as_linespec)
buf.puts ("-label ");
- buf.puts (explicit_loc->label_name);
+ buf.puts (explicit_loc->label_name.get ());
need_space = true;
}
{
set_oarg (explicit_location_spec_lex_one (argp, language,
completion_info));
- locspec->source_filename = oarg.release ();
+ locspec->source_filename = std::move (oarg);
}
else if (strncmp (opt.get (), "-function", len) == 0)
{
set_oarg (explicit_location_spec_lex_one_function (argp, language,
completion_info));
- locspec->function_name = oarg.release ();
+ locspec->function_name = std::move (oarg);
}
else if (strncmp (opt.get (), "-qualified", len) == 0)
{
{
set_oarg (explicit_location_spec_lex_one (argp, language,
completion_info));
- locspec->label_name = oarg.release ();
+ locspec->label_name = std::move (oarg);
}
/* Only emit an "invalid argument" error for options
that look like option strings. */
struct explicit_location_spec : public location_spec
{
- explicit_location_spec ();
+ explicit explicit_location_spec (const char *function_name);
- ~explicit_location_spec ();
+ explicit_location_spec ()
+ : explicit_location_spec (nullptr)
+ {
+ }
location_spec_up clone () const override;
canonicalized/valid. */
std::string to_linespec () const;
- /* The source filename. Malloc'd. */
- char *source_filename = nullptr;
+ /* The source filename. */
+ gdb::unique_xmalloc_ptr<char> source_filename;
- /* The function name. Malloc'd. */
- char *function_name = nullptr;
+ /* The function name. */
+ gdb::unique_xmalloc_ptr<char> function_name;
/* Whether the function name is fully-qualified or not. */
symbol_name_match_type func_name_match_type
= symbol_name_match_type::WILD;
- /* The name of a label. Malloc'd. */
- char *label_name = nullptr;
+ /* The name of a label. */
+ gdb::unique_xmalloc_ptr<char> label_name;
/* A line offset relative to the start of the symbol
identified by the above fields or the current symtab
static inline location_spec_up
new_explicit_location_spec_function (const char *function_name)
{
- explicit_location_spec *spec
- = new explicit_location_spec ();
- spec->function_name
- = (function_name != nullptr ? xstrdup (function_name) : nullptr);
+ explicit_location_spec *spec = new explicit_location_spec (function_name);
return location_spec_up (spec);
}