/* Objective-C language support routines for GDB, the GNU debugger.
- Copyright (C) 2002-2013 Free Software Foundation, Inc.
+ Copyright (C) 2002-2014 Free Software Foundation, Inc.
Contributed by Apple Computer, Inc.
Written by Michael Snyder.
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
+#include "varobj.h"
#include "c-lang.h"
#include "objc-lang.h"
#include "exceptions.h"
#include "value.h"
#include "symfile.h"
#include "objfiles.h"
-#include "gdb_string.h" /* for strchr */
#include "target.h" /* for target_has_execution */
#include "gdbcore.h"
#include "gdbcmd.h"
#include "block.h"
#include "infcall.h"
#include "valprint.h"
-#include "gdb_assert.h"
+#include "cli/cli-utils.h"
#include <ctype.h>
return 0;
}
- if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
+ if (lookup_minimal_symbol("objc_lookUpClass", 0, 0).minsym)
function = find_function_in_inferior("objc_lookUpClass", NULL);
- else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
+ else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0).minsym)
function = find_function_in_inferior("objc_lookup_class", NULL);
else
{
return 0;
}
- if (lookup_minimal_symbol("sel_getUid", 0, 0))
+ if (lookup_minimal_symbol("sel_getUid", 0, 0).minsym)
function = find_function_in_inferior("sel_getUid", NULL);
- else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
+ else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0).minsym)
function = find_function_in_inferior("sel_get_any_uid", NULL);
else
{
stringValue[2] = value_string(ptr, len, char_type);
stringValue[2] = value_coerce_array(stringValue[2]);
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
- if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
+ if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0).minsym)
{
function = find_function_in_inferior("_NSNewStringFromCString", NULL);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
- else if (lookup_minimal_symbol("istr", 0, 0))
+ else if (lookup_minimal_symbol("istr", 0, 0).minsym)
{
function = find_function_in_inferior("istr", NULL);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
- else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0))
+ else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0).minsym)
{
function
= find_function_in_inferior("+[NSString stringWithCString:]", NULL);
const struct language_defn objc_language_defn = {
"objective-c", /* Language name */
+ "Objective-C",
language_objc,
range_check_off,
case_sensitive_on,
default_get_string,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
+ &default_varobj_ops,
LANG_MAGIC
};
void
add_msglist(struct stoken *str, int addcolon)
{
- char *s, *p;
+ char *s;
+ const char *p;
int len, plen;
if (str == 0) /* Unnamed arg, or... */
}
int
-end_msglist(void)
+end_msglist (struct parser_state *ps)
{
int val = msglist_len;
struct selname *sel = selname_chain;
selname_chain = sel->next;
msglist_len = sel->msglist_len;
msglist_sel = sel->msglist_sel;
- selid = lookup_child_selector (parse_gdbarch, p);
+ selid = lookup_child_selector (parse_gdbarch (ps), p);
if (!selid)
error (_("Can't find selector \"%s\""), p);
- write_exp_elt_longcst (selid);
+ write_exp_elt_longcst (ps, selid);
xfree(p);
- write_exp_elt_longcst (val); /* Number of args */
+ write_exp_elt_longcst (ps, val); /* Number of args */
xfree(sel);
return val;
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- name = SYMBOL_NATURAL_NAME (msymbol);
+ name = MSYMBOL_NATURAL_NAME (msymbol);
if (name
&& (name[0] == '-' || name[0] == '+')
&& name[1] == '[') /* Got a method name. */
{
complaint (&symfile_complaints,
_("Bad method name '%s'"),
- SYMBOL_NATURAL_NAME (msymbol));
+ MSYMBOL_NATURAL_NAME (msymbol));
continue;
}
if (regexp == NULL || re_exec(++name) != 0)
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- name = SYMBOL_NATURAL_NAME (msymbol);
+ name = MSYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- name = SYMBOL_NATURAL_NAME (msymbol);
+ name = MSYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
ALL_MSYMBOLS (objfile, msymbol)
{
QUIT;
- name = SYMBOL_NATURAL_NAME (msymbol);
+ name = MSYMBOL_NATURAL_NAME (msymbol);
if (name &&
(name[0] == '-' || name[0] == '+') &&
name[1] == '[') /* Got a method name. */
s1 = method;
- while (isspace (*s1))
- s1++;
+ s1 = skip_spaces (s1);
if (*s1 == '\'')
{
found_quote = 1;
s1++;
}
- while (isspace (*s1))
- s1++;
+ s1 = skip_spaces (s1);
nselector = s1;
s2 = s1;
}
*s1++ = '\0';
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
if (found_quote)
{
if (*s2 == '\'')
s2++;
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
}
if (selector != NULL)
s1 = method;
- while (isspace (*s1))
- s1++;
+ s1 = skip_spaces (s1);
if (*s1 == '\'')
{
found_quote = 1;
s1++;
}
- while (isspace (*s1))
- s1++;
+ s1 = skip_spaces (s1);
if ((s1[0] == '+') || (s1[0] == '-'))
ntype = *s1++;
- while (isspace (*s1))
- s1++;
+ s1 = skip_spaces (s1);
if (*s1 != '[')
return NULL;
s1++;
s2 = s1;
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
if (*s2 == '(')
{
s2++;
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
ncategory = s2;
while (isalnum (*s2) || (*s2 == '_'))
s2++;
*s1++ = '\0';
s2++;
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
if (found_quote)
{
if (*s2 != '\'')
return NULL;
s2++;
- while (isspace (*s2))
- s2++;
+ s2 = skip_spaces (s2);
}
if (type != NULL)
/* Check the symbol name first as this can be done entirely without
sending any query to the target. */
- symname = SYMBOL_NATURAL_NAME (msymbol);
+ symname = MSYMBOL_NATURAL_NAME (msymbol);
if (symname == NULL)
continue;
const char *elem, *last = NULL;
int out;
+ /* If the vector is empty, there's nothing to do. This explicit
+ check is needed to avoid invoking qsort with NULL. */
+ if (VEC_empty (const_char_ptr, *strings))
+ return;
+
qsort (VEC_address (const_char_ptr, *strings),
VEC_length (const_char_ptr, *strings),
sizeof (const_char_ptr),
}
/*
- * 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
* 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;
SYMBOL_NATURAL_NAME (sym));
else
{
- struct minimal_symbol *msym = lookup_minimal_symbol (selector, 0, 0);
+ struct bound_minimal_symbol msym
+ = lookup_minimal_symbol (selector, 0, 0);
- if (msym != NULL)
+ if (msym.minsym != NULL)
VEC_safe_push (const_char_ptr, *symbol_names,
- SYMBOL_NATURAL_NAME (msym));
+ MSYMBOL_NATURAL_NAME (msym.minsym));
}
}
for (i = 0; i < nmethcalls; i++)
{
- struct minimal_symbol *func;
+ struct bound_minimal_symbol func;
/* Try both with and without underscore. */
- func = lookup_minimal_symbol (methcalls[i].name, NULL, NULL);
- if ((func == NULL) && (methcalls[i].name[0] == '_'))
+ func = lookup_bound_minimal_symbol (methcalls[i].name);
+ if ((func.minsym == NULL) && (methcalls[i].name[0] == '_'))
{
- func = lookup_minimal_symbol (methcalls[i].name + 1, NULL, NULL);
+ func = lookup_bound_minimal_symbol (methcalls[i].name + 1);
}
- if (func == NULL)
+ if (func.minsym == NULL)
{
methcalls[i].begin = 0;
methcalls[i].end = 0;
continue;
}
- methcalls[i].begin = SYMBOL_VALUE_ADDRESS (func);
- do {
- methcalls[i].end = SYMBOL_VALUE_ADDRESS (++func);
- } while (methcalls[i].begin == methcalls[i].end);
+ methcalls[i].begin = BMSYMBOL_VALUE_ADDRESS (func);
+ methcalls[i].end = minimal_symbol_upper_bound (func);
}
}