addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
special_name = NULL;
- //cp_find_method_field (sym.symbol, 1);
func_name = maybe_canonicalize_special_function
(SYMBOL_LINKAGE_NAME (sym.symbol), NULL,
SYMBOL_TYPE (sym.symbol), &special_name, &ignore);
#include <signal.h>
#include "gdb_setjmp.h"
#include "safe-ctype.h"
-#include "linespec.h" /* for find_toplevel_char_r */
/* Functions related to demangled name parsing. */
char *
cp_strip_template_parameters (const char *linkage_or_phys_name)
{
- /* This is by far the best way to do this, but there is one really big
- problem... The code below resets the the top-level node to below the
- (first) DEMANGLE_COMPONENT_TEMPLATE node in the tree.
-
- Normally that works, however, there is a special case (of course!)
- where this fails: conversion operators. Those *require* the template
- parameter to deduce the name of the operator. As a result, the code
- below will not work on conversion operators at all (and maybe others). */
-#if 0
- struct demangle_component *ret_comp;
- struct demangle_parse_info *info;
- void *storage = NULL;
- char *ret, *str = NULL, *demangled_name = NULL;
-
- info = cp_mangled_name_to_comp (linkage_or_phys_name, DMGL_ANSI,
- &storage, &demangled_name);
-
- if (info == NULL)
- {
- info = cp_demangled_name_to_comp (linkage_or_phys_name, NULL);
- if (info == NULL)
- {
- char *p;
-
- /* Special case: cp_demangled_name_to_comp doesn't like
- template specializations, templatename<>. Adjust for that
- here until libiberty is fixed. */
- str = xstrdup (linkage_or_phys_name);
- p = strstr (str, "<>");
- if (p == NULL)
- return NULL;
-
- *p = '\0';
- info = cp_demangled_name_to_comp (str, NULL);
- if (info == NULL)
- {
- xfree (str);
- return NULL;
- }
- }
- }
-
- ret_comp = info->tree;
- ret = NULL;
- if (ret_comp != NULL)
- {
- int done = 0;
-
- while (!done)
- {
- switch (ret_comp->type)
- {
- case DEMANGLE_COMPONENT_QUAL_NAME:
- case DEMANGLE_COMPONENT_LOCAL_NAME:
- ret_comp = d_right (ret_comp);
- break;
- case DEMANGLE_COMPONENT_TYPED_NAME:
- case DEMANGLE_COMPONENT_CONST:
- case DEMANGLE_COMPONENT_RESTRICT:
- case DEMANGLE_COMPONENT_VOLATILE:
- case DEMANGLE_COMPONENT_CONST_THIS:
- case DEMANGLE_COMPONENT_RESTRICT_THIS:
- case DEMANGLE_COMPONENT_VOLATILE_THIS:
- case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
- ret_comp = d_left (ret_comp);
- break;
- case DEMANGLE_COMPONENT_TEMPLATE:
- ret_comp = d_left (ret_comp);
- if (ret_comp->type == DEMANGLE_COMPONENT_QUAL_NAME
- && d_right (ret_comp)->type == DEMANGLE_COMPONENT_CONVERSION)
- {
- /* Remove the template parameter, replacing this
- node with a NAME node. */
- /* !!keiths: Can't be done without modifications to
- libiberty *or* reimplementing the entire libiberty
- printer (d_print_comp_inner). */
- /* !!keiths: Is there any other option??? */
- }
- /* fall through */
- default:
- done = 1;
- break;
- }
- }
- }
-
- ret = cp_comp_to_string (ret_comp, 10);
- cp_demangled_name_parse_free (info);
- xfree (storage);
- xfree (demangled_name);
- xfree (str);
- return ret;
-#else
+ /* We do not turn the linkage name into demangle components since we cannot
+ walk the tree in any usable way when dealing with conversion operators.
+ Instead we use a heuristic approach that works for all cases. */
char *stripped = NULL;
const char *name;
name = linkage_or_phys_name;
/* Only attempt to strip this if it looks like a template. */
- if (strchr (name, '<') != NULL
- && strchr (name, '>') != NULL)
+ if (strchr (name, '<') != NULL && strchr (name, '>') != NULL)
{
const char *p;
size_t len = strlen (name) - 1;
}
xfree (demangled_name);
- //printf ("stripped = \"%s\"\n", stripped);
return stripped;
-#endif
}
/* DEMANGLED_NAME is the name of a function, including parameters and
/* Attach template arguments to function. */
if (! VEC_empty (symbolp, template_args))
{
- const char *linkage_name;
-
gdb_assert (templ_func != NULL);
templ_func->template_arguments
/* Determine whether the template's return and argument types were
specified using template parameters. */
- linkage_name = dw2_linkage_name (die, cu);
+ const char *linkage_name = dw2_linkage_name (die, cu);
templ_func->linkage_name = linkage_name;
if (linkage_name != NULL)
{
accessibility = dwarf2_default_access_attribute (die, cu);
switch (accessibility)
{
+#if 1
case DW_ACCESS_public:
fp->is_public = 1;
break;
+#endif
case DW_ACCESS_private:
fp->is_private = 1;
break;
VEC_safe_push (typep, *superclasses, TYPE_BASECLASS (t, ibase));
}
-/* Find an instance of the character C in the string S that is outside
- of all parenthesis pairs, single-quoted strings, and double-quoted
- strings. Also, ignore the char within a template name, like a ','
- within foo<int, int>. */
-
-const char *
-find_toplevel_char (const char *s, char c)
-{
- int quoted = 0; /* zero if we're not in quotes;
- '"' if we're in a double-quoted string;
- '\'' if we're in a single-quoted string. */
- int depth = 0; /* Number of unclosed parens we've seen. */
- const char *scan;
-
- for (scan = s; *scan; scan++)
- {
- if (quoted)
- {
- if (*scan == quoted)
- quoted = 0;
- else if (*scan == '\\' && *(scan + 1))
- scan++;
- }
- else if (*scan == c && ! quoted && depth == 0)
- return scan;
- else if (*scan == '"' || *scan == '\'')
- quoted = *scan;
- else if (*scan == '(' || *scan == '<')
- depth++;
- else if ((*scan == ')' || *scan == '>') && depth > 0)
- depth--;
- }
-
- return 0;
-}
-
-/* See description in linespec.h. */
-
-const char *
-find_toplevel_char_r (const char *s, size_t len, char c)
-{
- int quoted = 0;
- int depth = 0;
- const char *scan;
-
- for (scan = s + len; scan >= s; --scan)
- {
- if (quoted)
- {
- if (*scan == quoted)
- quoted = 0;
- }
- else if (*scan == ')' || *scan == '>')
- ++depth;
- else if ((*scan == '(' || *scan == '<') && depth > 0)
- --depth;
-
- if (*scan == c && !quoted && depth == 0)
- return scan;
- else if ((*scan == '"' || *scan == '\'')
- && scan > s && *(scan - 1) != '\\')
- quoted = *scan;
- }
-
- return NULL;
-}
-
-/* See linespec.h. */
-
-const char *
-find_toplevel_string (const char *haystack, const char *needle)
-{
- const char *s = haystack;
-
- do
- {
- s = find_toplevel_char (s, *needle);
-
- if (s != NULL)
- {
- /* Found first char in HAYSTACK; check rest of string. */
- if (startswith (s, needle))
- return s;
-
- /* Didn't find it; loop over HAYSTACK, looking for the next
- instance of the first character of NEEDLE. */
- ++s;
- }
- }
- while (s != NULL && *s != '\0');
-
- /* NEEDLE was not found in HAYSTACK. */
- return NULL;
-}
-
/* Convert CANONICAL to its string representation using
symtab_to_fullname for SYMTAB. The caller must xfree the result. */
extern int is_ada_operator (const char *string);
-/* Find an instance of the character C in the string S that is outside
- of all parenthesis pairs, single-quoted strings, and double-quoted
- strings. Also, ignore the char within a template name, like a ','
- within foo<int, int>. */
-
-extern const char *find_toplevel_char (const char *s, char c);
-
-/* Like find_toplevel_char but searches S backwards, starting LEN characters
- into S. */
-
-extern const char *find_toplevel_char_r (const char *s, size_t len, char c);
-
-/* The string equivalent of find_toplevel_char. Returns a pointer
- to the location of NEEDLE in HAYSTACK, ignoring any occurrences
- inside "()" and "<>". Returns NULL if NEEDLE was not found. */
-
-const char *find_toplevel_string (const char *haystack,
- const char *needle);
-
/* Find the end of the (first) linespec pointed to by *STRINGP.
STRINGP will be advanced to this point. */
return p;
}
+/* See description in utils.h. */
+
+const char *
+find_toplevel_char (const char *s, char c)
+{
+ int quoted = 0; /* zero if we're not in quotes;
+ '"' if we're in a double-quoted string;
+ '\'' if we're in a single-quoted string. */
+ int depth = 0; /* Number of unclosed parens we've seen. */
+ const char *scan;
+
+ for (scan = s; *scan; scan++)
+ {
+ if (quoted)
+ {
+ if (*scan == quoted)
+ quoted = 0;
+ else if (*scan == '\\' && *(scan + 1))
+ scan++;
+ }
+ else if (*scan == c && ! quoted && depth == 0)
+ return scan;
+ else if (*scan == '"' || *scan == '\'')
+ quoted = *scan;
+ else if (*scan == '(' || *scan == '<')
+ depth++;
+ else if ((*scan == ')' || *scan == '>') && depth > 0)
+ depth--;
+ }
+
+ return 0;
+}
+
+/* See description in utils.h. */
+
+const char *
+find_toplevel_char_r (const char *s, size_t len, char c)
+{
+ int quoted = 0;
+ int depth = 0;
+ const char *scan;
+
+ for (scan = s + len; scan >= s; --scan)
+ {
+ if (quoted)
+ {
+ if (*scan == quoted)
+ quoted = 0;
+ }
+ else if (*scan == ')' || *scan == '>')
+ ++depth;
+ else if ((*scan == '(' || *scan == '<') && depth > 0)
+ --depth;
+
+ if (*scan == c && !quoted && depth == 0)
+ return scan;
+ else if ((*scan == '"' || *scan == '\'')
+ && scan > s && *(scan - 1) != '\\')
+ quoted = *scan;
+ }
+
+ return NULL;
+}
+
+/* See description in utils.h. */
+
+const char *
+find_toplevel_string (const char *haystack, const char *needle)
+{
+ const char *s = haystack;
+
+ do
+ {
+ s = find_toplevel_char (s, *needle);
+
+ if (s != NULL)
+ {
+ /* Found first char in HAYSTACK; check rest of string. */
+ if (startswith (s, needle))
+ return s;
+
+ /* Didn't find it; loop over HAYSTACK, looking for the next
+ instance of the first character of NEEDLE. */
+ ++s;
+ }
+ }
+ while (s != NULL && *s != '\0');
+
+ /* NEEDLE was not found in HAYSTACK. */
+ return NULL;
+}
+
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_utils;
extern char *make_hex_string (const gdb_byte *data, size_t length);
+/* Find an instance of the character C in the string S that is outside
+ of all parenthesis pairs, single-quoted strings, and double-quoted
+ strings. Also, ignore the char within a template name, like a ','
+ within foo<int, int>. */
+
+extern const char *find_toplevel_char (const char *s, char c);
+
+/* Like find_toplevel_char but searches S backwards, starting LEN characters
+ into S. */
+
+extern const char *find_toplevel_char_r (const char *s, size_t len, char c);
+
+/* The string equivalent of find_toplevel_char. Returns a pointer
+ to the location of NEEDLE in HAYSTACK, ignoring any occurrences
+ inside "()" and "<>". Returns NULL if NEEDLE was not found. */
+
+const char *find_toplevel_string (const char *haystack, const char *needle);
+
#endif /* UTILS_H */