aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Fedor <fedor@gnu.org>2002-12-03 03:52:37 +0000
committerAdam Fedor <fedor@gnu.org>2002-12-03 03:52:37 +0000
commit36e53c6341449469a2e4a48e4692349ddb0e45e6 (patch)
tree7e2d47c5567b60d86e4d2fb837f1a868468ff1f0
parent504d5c7e6af52a59551dfa0b4a008f730eec5203 (diff)
downloadgdb-36e53c6341449469a2e4a48e4692349ddb0e45e6.zip
gdb-36e53c6341449469a2e4a48e4692349ddb0e45e6.tar.gz
gdb-36e53c6341449469a2e4a48e4692349ddb0e45e6.tar.bz2
* gdb/objc-lang.c (objc_printstr): Add width arg to match
printstr prototype. (compare_selectors): Add 'const' to arg types. (compare_classes): Likewise. (find_imps): Cast msym pointer to avoid compiler warning. (print_object_command): Validate the address before passing it to the print routine. (find_objc_msgcall_submethod): Change function argument to return an int. * objc-lang.h: Add 'extern' to all function declaration. (value_nsstring): Add declaration.
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/objc-lang.c35
-rw-r--r--gdb/objc-lang.h28
3 files changed, 47 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a07b153..2e9ec72 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2002-12-02 Adam Fedor <fedor@gnu.org>
+ Klee Dienes <kdienes@apple.com>
+
+ * objc-lang.c (objc_printstr): Add width arg to match
+ printstr prototype.
+ (compare_selectors): Add 'const' to arg types.
+ (compare_classes): Likewise.
+ (find_imps): Cast msym pointer to avoid compiler warning.
+ (print_object_command): Validate the address before
+ passing it to the print routine.
+ (find_objc_msgcall_submethod): Change function argument to
+ return an int.
+ * objc-lang.h: Add 'extern' to all function declarations.
+ (value_nsstring): Add declaration.
+
2002-12-02 J. Brobecker <brobecker@gnat.com>
* somsolib.c (dld_cache): Replace boolean by int for field is_valid.
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 7309d00..1f83511 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -370,7 +370,7 @@ objc_printchar (int c, struct ui_file *stream)
static void
objc_printstr (struct ui_file *stream, char *string,
- unsigned int length, int force_ellipses)
+ unsigned int length, int width, int force_ellipses)
{
register unsigned int i;
unsigned int things_printed = 0;
@@ -796,14 +796,14 @@ int specialcmp(char *a, char *b)
}
/*
- * Function: compare_selectors (void *, void *)
+ * Function: compare_selectors (const void *, const void *)
*
* Comparison function for use with qsort. Arguments are symbols or
* msymbols Compares selector part of objc method name alphabetically.
*/
static int
-compare_selectors (void *a, void *b)
+compare_selectors (const void *a, const void *b)
{
char *aname, *bname;
@@ -954,14 +954,14 @@ selectors_info (char *regexp, int from_tty)
}
/*
- * Function: compare_classes (void *, void *)
+ * Function: compare_classes (const void *, const void *)
*
* Comparison function for use with qsort. Arguments are symbols or
* msymbols Compares class part of objc method name alphabetically.
*/
static int
-compare_classes (void *a, void *b)
+compare_classes (const void *a, const void *b)
{
char *aname, *bname;
@@ -1363,7 +1363,7 @@ find_methods (struct symtab *symtab, char type,
sym = find_pc_function (SYMBOL_VALUE_ADDRESS (msymbol));
if (sym != NULL)
{
- const char *newsymname = SYMBOL_DEMANGLED_NAME (sym);
+ const char *newsymname = SYMBOL_DEMANGLED_NAME (sym);
if (newsymname == NULL)
newsymname = SYMBOL_NAME (sym);
@@ -1461,7 +1461,7 @@ char *find_imps (struct symtab *symtab, struct block *block,
if (msym != NULL)
{
if (syms)
- syms[csym] = msym;
+ syms[csym] = (struct symbol *)msym;
csym++;
}
}
@@ -1538,7 +1538,7 @@ void
print_object_command (char *args, int from_tty)
{
struct value *object, *function, *description;
- CORE_ADDR string_addr;
+ CORE_ADDR string_addr, object_addr;
int i = 0;
char c = -1;
@@ -1552,18 +1552,17 @@ print_object_command (char *args, int from_tty)
make_cleanup (free_current_contents, &expr);
int pc = 0;
-#if 1
object = expr->language_defn->evaluate_exp (builtin_type_void_data_ptr,
expr, &pc, EVAL_NORMAL);
-#else
- object = evaluate_subexp (builtin_type_void_data_ptr,
- expr, &pc, EVAL_NORMAL);
-#endif
do_cleanups (old_chain);
}
+ /* Validate the address for sanity. */
+ object_addr = value_as_long (object);
+ read_memory (object_addr, &c, 1);
+
function = find_function_in_inferior ("_NSPrintForDebugger");
- if (!function)
+ if (function == NULL)
error ("Unable to locate _NSPrintForDebugger in child process");
description = call_function_by_hand (function, 1, &object);
@@ -1593,7 +1592,7 @@ print_object_command (char *args, int from_tty)
struct objc_methcall {
char *name;
/* Return instance method to be called. */
- CORE_ADDR (*stop_at) (CORE_ADDR);
+ int (*stop_at) (CORE_ADDR, CORE_ADDR *);
/* Start of pc range corresponding to method invocation. */
CORE_ADDR begin;
/* End of pc range corresponding to method invocation. */
@@ -1665,7 +1664,7 @@ find_objc_msgsend (void)
*/
struct objc_submethod_helper_data {
- CORE_ADDR (*f) (CORE_ADDR, CORE_ADDR *);
+ int (*f) (CORE_ADDR, CORE_ADDR *);
CORE_ADDR pc;
CORE_ADDR *new_pc;
};
@@ -1683,7 +1682,7 @@ find_objc_msgcall_submethod_helper (void * arg)
}
int
-find_objc_msgcall_submethod (CORE_ADDR (*f) (CORE_ADDR, CORE_ADDR *),
+find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
CORE_ADDR pc,
CORE_ADDR *new_pc)
{
@@ -1732,7 +1731,7 @@ _initialize_objc_language (void)
add_info ("classes", classes_info, /* INFO CLASSES command. */
"All Objective-C classes, or those matching REGEXP.");
add_com ("print-object", class_vars, print_object_command,
- "Ask an Objective-C object to print itself.\n");
+ "Ask an Objective-C object to print itself.");
add_com_alias ("po", "print-object", class_vars, 1);
}
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 9fd93e7..58f1884 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -35,21 +35,23 @@ extern int c_value_print (struct value *, struct ui_file *,
extern CORE_ADDR lookup_objc_class (char *classname);
extern int lookup_child_selector (char *methodname);
-char *objc_demangle (const char *mangled);
+extern char *objc_demangle (const char *mangled);
-int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc);
+extern int find_objc_msgcall (CORE_ADDR pc, CORE_ADDR *new_pc);
-char *parse_selector (char *method, char **selector);
+extern char *parse_selector (char *method, char **selector);
-char *parse_method (char *method, char *type,
- char **class, char **category,
- char **selector);
+extern char *parse_method (char *method, char *type,
+ char **class, char **category,
+ char **selector);
-void find_methods (struct symtab *symtab, char type,
- const char *class, const char *category,
- const char *selector, struct symbol **syms,
- unsigned int *nsym, unsigned int *ndebug);
+extern void find_methods (struct symtab *symtab, char type,
+ const char *class, const char *category,
+ const char *selector, struct symbol **syms,
+ unsigned int *nsym, unsigned int *ndebug);
-char *find_imps (struct symtab *symtab, struct block *block,
- char *method, struct symbol **syms,
- unsigned int *nsym, unsigned int *ndebug);
+extern char *find_imps (struct symtab *symtab, struct block *block,
+ char *method, struct symbol **syms,
+ unsigned int *nsym, unsigned int *ndebug);
+
+extern struct value *value_nsstring (char *ptr, int len);