aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
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 /gdb/valops.c
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".
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c27
1 files changed, 22 insertions, 5 deletions
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))
{