aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2008-09-11 14:27:34 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2008-09-11 14:27:34 +0000
commit3e3b026fee8cd62ac6c2cfc7f86cec972d8f5676 (patch)
treebc601c999d48b731197ac2a508aafb6c06ad054c
parentf8dcfc0affda04681b337c807c15d3c59badc33c (diff)
downloadgdb-3e3b026fee8cd62ac6c2cfc7f86cec972d8f5676.zip
gdb-3e3b026fee8cd62ac6c2cfc7f86cec972d8f5676.tar.gz
gdb-3e3b026fee8cd62ac6c2cfc7f86cec972d8f5676.tar.bz2
* valops.c: Include "objfiles.h" and "symtab.h".
(find_function_in_inferior): New argument OBJF_P. Use it to return objfile where function is defined. Use per-objfile arch types instead of builtin_type_ to define default return type. * linux-fork.c (checkpoint_command): Update calls. Use per-objfile architecture to define inferior call argument types. * gcore.c (derive_heap_segment): Likewise. * objc-lang.c (value_nsstring): Likewise. * scm-lang.c (scm_lookup_name): Likewise. * scm-valprint.c (scm_inferior_print): Likewise. * valops.c (value_allocate_space_in_inferior): Likewise. * eval.c (evaluate_subexp_standard): Update calls. * objc-lang.c (lookup_objc_class, print_object_command): Likewise. * linux-fork.c: Include "objfiles.h". * scm-lang.c: Include "objfiles.h". * scm-valprint.c: Include "objfiles.h".
-rw-r--r--gdb/ChangeLog22
-rw-r--r--gdb/eval.c10
-rw-r--r--gdb/gcore.c9
-rw-r--r--gdb/linux-fork.c10
-rw-r--r--gdb/objc-lang.c43
-rw-r--r--gdb/scm-lang.c12
-rw-r--r--gdb/scm-valprint.c10
-rw-r--r--gdb/valops.c27
-rw-r--r--gdb/value.h3
9 files changed, 106 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 189beab..eaca9d8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,27 @@
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
+ * valops.c: Include "objfiles.h" and "symtab.h".
+ (find_function_in_inferior): New argument OBJF_P. Use it to return
+ objfile where function is defined. Use per-objfile arch types
+ instead of builtin_type_ to define default return type.
+
+ * linux-fork.c (checkpoint_command): Update calls. Use per-objfile
+ architecture to define inferior call argument types.
+ * gcore.c (derive_heap_segment): Likewise.
+ * objc-lang.c (value_nsstring): Likewise.
+ * scm-lang.c (scm_lookup_name): Likewise.
+ * scm-valprint.c (scm_inferior_print): Likewise.
+ * valops.c (value_allocate_space_in_inferior): Likewise.
+
+ * eval.c (evaluate_subexp_standard): Update calls.
+ * objc-lang.c (lookup_objc_class, print_object_command): Likewise.
+
+ * linux-fork.c: Include "objfiles.h".
+ * scm-lang.c: Include "objfiles.h".
+ * scm-valprint.c: Include "objfiles.h".
+
+2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
+
* gdbarch.sh (name_of_malloc): Remove.
* gdbarch.c, gdbarch.h: Re-generate.
* valops.c (value_allocate_space_in_inferior): Do not call
diff --git a/gdb/eval.c b/gdb/eval.c
index 66259b9..3366a06 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1076,8 +1076,9 @@ evaluate_subexp_standard (struct type *expect_type,
type = lookup_function_type (type);
type = lookup_pointer_type (type);
- msg_send = find_function_in_inferior ("objc_msg_lookup");
- msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+ msg_send = find_function_in_inferior ("objc_msg_lookup", NULL);
+ msg_send_stret
+ = find_function_in_inferior ("objc_msg_lookup", NULL);
msg_send = value_from_pointer (type, value_as_address (msg_send));
msg_send_stret = value_from_pointer (type,
@@ -1085,9 +1086,10 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
- msg_send = find_function_in_inferior ("objc_msgSend");
+ msg_send = find_function_in_inferior ("objc_msgSend", NULL);
/* Special dispatcher for methods returning structs */
- msg_send_stret = find_function_in_inferior ("objc_msgSend_stret");
+ msg_send_stret
+ = find_function_in_inferior ("objc_msgSend_stret", NULL);
}
/* Verify the target object responds to this method. The
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 2784a5e..bcdb8f9 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -215,6 +215,8 @@ derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
static int
derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
{
+ struct objfile *sbrk_objf;
+ struct gdbarch *gdbarch;
bfd_vma top_of_data_memory = 0;
bfd_vma top_of_heap = 0;
bfd_size_type sec_size;
@@ -256,20 +258,21 @@ derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
/* Now get the top-of-heap by calling sbrk in the inferior. */
if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
{
- sbrk = find_function_in_inferior ("sbrk");
+ sbrk = find_function_in_inferior ("sbrk", &sbrk_objf);
if (sbrk == NULL)
return 0;
}
else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
{
- sbrk = find_function_in_inferior ("_sbrk");
+ sbrk = find_function_in_inferior ("_sbrk", &sbrk_objf);
if (sbrk == NULL)
return 0;
}
else
return 0;
- zero = value_from_longest (builtin_type_int, 0);
+ gdbarch = get_objfile_arch (sbrk_objf);
+ zero = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
gdb_assert (zero);
sbrk = call_function_by_hand (sbrk, 1, &zero);
if (sbrk == NULL)
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index fcc8a29..443b63d 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -22,6 +22,7 @@
#include "regcache.h"
#include "gdbcmd.h"
#include "infcall.h"
+#include "objfiles.h"
#include "gdb_assert.h"
#include "gdb_string.h"
#include "linux-fork.h"
@@ -528,6 +529,8 @@ save_detach_fork (int *saved_val)
static void
checkpoint_command (char *args, int from_tty)
{
+ struct objfile *fork_objf;
+ struct gdbarch *gdbarch;
struct target_waitstatus last_target_waitstatus;
ptid_t last_target_ptid;
struct value *fork_fn = NULL, *ret;
@@ -545,14 +548,15 @@ checkpoint_command (char *args, int from_tty)
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
- fork_fn = find_function_in_inferior ("fork");
+ fork_fn = find_function_in_inferior ("fork", &fork_objf);
if (!fork_fn)
if (lookup_minimal_symbol ("_fork", NULL, NULL) != NULL)
- fork_fn = find_function_in_inferior ("fork");
+ fork_fn = find_function_in_inferior ("fork", &fork_objf);
if (!fork_fn)
error (_("checkpoint: can't find fork function in inferior."));
- ret = value_from_longest (builtin_type_int, 0);
+ gdbarch = get_objfile_arch (fork_objf);
+ ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
old_chain = save_detach_fork (&temp_detach_fork);
detach_fork = 0;
ret = call_function_by_hand (fork_fn, 0, &ret);
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 0ff2ebc..1692c3d 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -117,9 +117,9 @@ lookup_objc_class (char *classname)
}
if (lookup_minimal_symbol("objc_lookUpClass", 0, 0))
- function = find_function_in_inferior("objc_lookUpClass");
+ function = find_function_in_inferior("objc_lookUpClass", NULL);
else if (lookup_minimal_symbol ("objc_lookup_class", 0, 0))
- function = find_function_in_inferior("objc_lookup_class");
+ function = find_function_in_inferior("objc_lookup_class", NULL);
else
{
complaint (&symfile_complaints, _("no way to lookup Objective-C classes"));
@@ -144,9 +144,9 @@ lookup_child_selector (char *selname)
}
if (lookup_minimal_symbol("sel_getUid", 0, 0))
- function = find_function_in_inferior("sel_getUid");
+ function = find_function_in_inferior("sel_getUid", NULL);
else if (lookup_minimal_symbol ("sel_get_any_uid", 0, 0))
- function = find_function_in_inferior("sel_get_any_uid");
+ function = find_function_in_inferior("sel_get_any_uid", NULL);
else
{
complaint (&symfile_complaints, _("no way to lookup Objective-C selectors"));
@@ -165,43 +165,50 @@ value_nsstring (char *ptr, int len)
struct value *function, *nsstringValue;
struct symbol *sym;
struct type *type;
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
if (!target_has_execution)
return 0; /* Can't call into inferior to create NSString. */
- sym = lookup_struct_typedef("NSString", 0, 1);
- if (sym == NULL)
- sym = lookup_struct_typedef("NXString", 0, 1);
- if (sym == NULL)
- type = builtin_type_void_data_ptr;
- else
- type = lookup_pointer_type(SYMBOL_TYPE (sym));
-
stringValue[2] = value_string(ptr, len);
stringValue[2] = value_coerce_array(stringValue[2]);
/* _NSNewStringFromCString replaces "istr" after Lantern2A. */
if (lookup_minimal_symbol("_NSNewStringFromCString", 0, 0))
{
- function = find_function_in_inferior("_NSNewStringFromCString");
+ function = find_function_in_inferior("_NSNewStringFromCString", &objf);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("istr", 0, 0))
{
- function = find_function_in_inferior("istr");
+ function = find_function_in_inferior("istr", &objf);
nsstringValue = call_function_by_hand(function, 1, &stringValue[2]);
}
else if (lookup_minimal_symbol("+[NSString stringWithCString:]", 0, 0))
{
- function = find_function_in_inferior("+[NSString stringWithCString:]");
+ function
+ = find_function_in_inferior("+[NSString stringWithCString:]", &objf);
+ type = builtin_type (get_objfile_arch (objf))->builtin_long;
+
stringValue[0] = value_from_longest
- (builtin_type_long, lookup_objc_class ("NSString"));
+ (type, lookup_objc_class ("NSString"));
stringValue[1] = value_from_longest
- (builtin_type_long, lookup_child_selector ("stringWithCString:"));
+ (type, lookup_child_selector ("stringWithCString:"));
nsstringValue = call_function_by_hand(function, 3, &stringValue[0]);
}
else
error (_("NSString: internal error -- no way to create new NSString"));
+ gdbarch = get_objfile_arch (objf);
+
+ sym = lookup_struct_typedef("NSString", 0, 1);
+ if (sym == NULL)
+ sym = lookup_struct_typedef("NXString", 0, 1);
+ if (sym == NULL)
+ type = builtin_type (gdbarch)->builtin_data_ptr;
+ else
+ type = lookup_pointer_type(SYMBOL_TYPE (sym));
+
deprecated_set_value_type (nsstringValue, type);
return nsstringValue;
}
@@ -1386,7 +1393,7 @@ print_object_command (char *args, int from_tty)
object_addr = value_as_long (object);
read_memory (object_addr, &c, 1);
- function = find_function_in_inferior ("_NSPrintForDebugger");
+ function = find_function_in_inferior ("_NSPrintForDebugger", NULL);
if (function == NULL)
error (_("Unable to locate _NSPrintForDebugger in child process"));
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 08f016d..003e27a 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -32,6 +32,7 @@
#include "gdb_string.h"
#include "gdbcore.h"
#include "infcall.h"
+#include "objfiles.h"
extern void _initialize_scheme_language (void);
static struct value *evaluate_subexp_scm (struct type *, struct expression *,
@@ -147,13 +148,19 @@ in_eval_c (void)
static struct value *
scm_lookup_name (char *str)
{
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
struct value *args[3];
int len = strlen (str);
struct value *func;
struct value *val;
struct symbol *sym;
+
+ func = find_function_in_inferior ("scm_lookup_cstr", &objf);
+ gdbarch = get_objfile_arch (objf);
+
args[0] = value_allocate_space_in_inferior (len);
- args[1] = value_from_longest (builtin_type_int, len);
+ args[1] = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
write_memory (value_as_long (args[0]), (gdb_byte *) str, len);
if (in_eval_c ()
@@ -165,7 +172,6 @@ scm_lookup_name (char *str)
/* FIXME in this case, we should try lookup_symbol first */
args[2] = value_from_longest (builtin_type_scm, SCM_EOL);
- func = find_function_in_inferior ("scm_lookup_cstr");
val = call_function_by_hand (func, 3, args);
if (!value_logical_not (val))
return value_ind (val);
@@ -187,7 +193,7 @@ scm_evaluate_string (char *str, int len)
write_memory (iaddr, (gdb_byte *) str, len);
/* FIXME - should find and pass env */
write_memory (iaddr + len, (gdb_byte *) "", 1);
- func = find_function_in_inferior ("scm_evstr");
+ func = find_function_in_inferior ("scm_evstr", NULL);
return call_function_by_hand (func, 1, &addr);
}
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index 746bd03..feb43dd 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -30,6 +30,7 @@
#include "gdbcore.h"
#include "c-lang.h"
#include "infcall.h"
+#include "objfiles.h"
static void scm_ipruk (char *, LONGEST, struct ui_file *);
static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
@@ -45,13 +46,16 @@ static int
scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty)
{
+ struct objfile *objf;
+ struct gdbarch *gdbarch;
struct value *func, *arg, *result;
struct symbol *gdb_output_sym, *gdb_output_len_sym;
char *output;
int ret, output_len;
- func = find_function_in_inferior ("gdb_print");
- arg = value_from_longest (builtin_type_CORE_ADDR, value);
+ func = find_function_in_inferior ("gdb_print", &objf);
+ gdbarch = get_objfile_arch (objf);
+ arg = value_from_longest (builtin_type (gdbarch)->builtin_core_addr, value);
result = call_function_by_hand (func, 1, &arg);
ret = (int) value_as_long (result);
@@ -73,7 +77,7 @@ scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
(char *) &output_len, sizeof (output_len));
output = (char *) alloca (output_len);
- remote_buffer = value_at (builtin_type_CORE_ADDR,
+ remote_buffer = value_at (builtin_type (gdbarch)->builtin_core_addr,
SYMBOL_VALUE_ADDRESS (gdb_output_sym));
read_memory (value_as_address (remote_buffer),
output, output_len);
diff --git a/gdb/valops.c b/gdb/valops.c
index 1f5f00b..5232e3f 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -44,6 +44,8 @@
#include "gdb_assert.h"
#include "cp-support.h"
#include "observer.h"
+#include "objfiles.h"
+#include "symtab.h"
extern int overload_debug;
/* Local functions. */
@@ -122,10 +124,12 @@ Overload resolution in evaluating C++ functions is %s.\n"),
value);
}
-/* Find the address of function name NAME in the inferior. */
+/* Find the address of function name NAME in the inferior. If OBJF_P
+ is non-NULL, *OBJF_P will be set to the OBJFILE where the function
+ is defined. */
struct value *
-find_function_in_inferior (const char *name)
+find_function_in_inferior (const char *name, struct objfile **objf_p)
{
struct symbol *sym;
sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
@@ -136,6 +140,10 @@ find_function_in_inferior (const char *name)
error (_("\"%s\" exists in this program but is not a function."),
name);
}
+
+ if (objf_p)
+ *objf_p = SYMBOL_SYMTAB (sym)->objfile;
+
return value_of_variable (sym, NULL);
}
else
@@ -144,12 +152,19 @@ find_function_in_inferior (const char *name)
lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
{
+ struct objfile *objfile = msymbol_objfile (msymbol);
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
struct type *type;
CORE_ADDR maddr;
- type = lookup_pointer_type (builtin_type_char);
+ type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
type = lookup_function_type (type);
type = lookup_pointer_type (type);
maddr = SYMBOL_VALUE_ADDRESS (msymbol);
+
+ if (objf_p)
+ *objf_p = objfile;
+
return value_from_pointer (type, maddr);
}
else
@@ -169,10 +184,12 @@ find_function_in_inferior (const char *name)
struct value *
value_allocate_space_in_inferior (int len)
{
+ struct objfile *objf;
+ struct value *val = find_function_in_inferior ("malloc", &objf);
+ struct gdbarch *gdbarch = get_objfile_arch (objf);
struct value *blocklen;
- struct value *val = find_function_in_inferior ("malloc");
- blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
+ blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
val = call_function_by_hand (val, 1, &blocklen);
if (value_logical_not (val))
{
diff --git a/gdb/value.h b/gdb/value.h
index 9665303..deb2629 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -571,7 +571,8 @@ extern struct value *value_slice (struct value *, int, int);
extern struct value *value_literal_complex (struct value *, struct value *,
struct type *);
-extern struct value *find_function_in_inferior (const char *);
+extern struct value *find_function_in_inferior (const char *,
+ struct objfile **);
extern struct value *value_allocate_space_in_inferior (int);