diff options
author | Adam Fedor <fedor@gnu.org> | 2002-10-14 02:02:42 +0000 |
---|---|---|
committer | Adam Fedor <fedor@gnu.org> | 2002-10-14 02:02:42 +0000 |
commit | d069f99d468405ae9e627a0112cdd06cd817eb5e (patch) | |
tree | bf45681490a0dcb655d6e8b6c6a00f34e4fac46e | |
parent | 53c551b7ca9c16f621072b09e45eb0c21fc7e91b (diff) | |
download | ppe42-binutils-d069f99d468405ae9e627a0112cdd06cd817eb5e.tar.gz ppe42-binutils-d069f99d468405ae9e627a0112cdd06cd817eb5e.zip |
valops.c (value_of_local): New function.
(value_of_this): Use it.
value.h (value_of_local): Declared.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/valops.c | 36 | ||||
-rw-r--r-- | gdb/value.h | 2 |
3 files changed, 32 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37c37a9e52..ace1c49ef8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2002-10-13 Adam Fedor <fedor@gnu.org> + * valops.c (value_of_local): New function. + (value_of_this): Use it. + * value.h (value_of_local): Declared. + +2002-10-13 Adam Fedor <fedor@gnu.org> + * parse.c: (length_of_subexp, prefixify_subexp): Handle OP_MSGCALL, OP_SELECTOR, OP_NSSTRING, and OP_SELF. diff --git a/gdb/valops.c b/gdb/valops.c index eaf4295310..e91e231d13 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3306,18 +3306,17 @@ value_full_object (struct value *argp, struct type *rtype, int xfull, int xtop, -/* C++: return the value of the class instance variable, if one exists. +/* Return the value of the local variable, if one exists. Flag COMPLAIN signals an error if the request is made in an inappropriate context. */ struct value * -value_of_this (int complain) +value_of_local (const char *name, int complain) { struct symbol *func, *sym; struct block *b; int i; - static const char funny_this[] = "this"; - struct value *this; + struct value * ret; if (selected_frame == 0) { @@ -3331,7 +3330,7 @@ value_of_this (int complain) if (!func) { if (complain) - error ("no `this' in nameless context"); + error ("no %s in nameless context", name); else return 0; } @@ -3341,26 +3340,39 @@ value_of_this (int complain) if (i <= 0) { if (complain) - error ("no args, no `this'"); + error ("no args, no %s", name); else return 0; } /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER symbol instead of the LOC_ARG one (if both exist). */ - sym = lookup_block_symbol (b, funny_this, NULL, VAR_NAMESPACE); + sym = lookup_block_symbol (b, name, NULL, VAR_NAMESPACE); if (sym == NULL) { if (complain) - error ("current stack frame not in method"); + error ("current stack frame does not contain a variable named \"%s\"", name); else return NULL; } - this = read_var_value (sym, selected_frame); - if (this == 0 && complain) - error ("`this' argument at unknown address"); - return this; + ret = read_var_value (sym, selected_frame); + if (ret == 0 && complain) + error ("%s argument unreadable", name); + return ret; +} + +/* C++/Objective-C: return the value of the class instance variable, + if one exists. Flag COMPLAIN signals an error if the request is + made in an inappropriate context. */ + +struct value * +value_of_this (int complain) +{ + if (current_language->la_language == language_objc) + return value_of_local ("self", complain); + else + return value_of_local ("this", complain); } /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH elements diff --git a/gdb/value.h b/gdb/value.h index efabecb880..a38b576947 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -566,4 +566,6 @@ extern CORE_ADDR default_push_arguments (int nargs, struct value ** args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr); +extern struct value *value_of_local (const char *name, int complain); + #endif /* !defined (VALUE_H) */ |