diff options
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-finishbreakpoint.c | 2 | ||||
-rw-r--r-- | gdb/python/py-frame.c | 9 | ||||
-rw-r--r-- | gdb/python/py-framefilter.c | 29 | ||||
-rw-r--r-- | gdb/python/py-symbol.c | 6 |
4 files changed, 31 insertions, 15 deletions
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index e543bb3..351f68c 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -265,7 +265,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) /* Ignore Python errors at this stage. */ self_bpfinish->return_type = type_to_type_object (ret_type); PyErr_Clear (); - func_value = read_var_value (function, frame); + func_value = read_var_value (function, NULL, frame); self_bpfinish->function_value = value_to_value_object (func_value); PyErr_Clear (); diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 7e5dd17..b448686 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -504,6 +504,7 @@ frapy_read_var (PyObject *self, PyObject *args) struct frame_info *frame; PyObject *sym_obj, *block_obj = NULL; struct symbol *var = NULL; /* gcc-4.3.2 false warning. */ + const struct block *block = NULL; struct value *val = NULL; if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj)) @@ -514,7 +515,6 @@ frapy_read_var (PyObject *self, PyObject *args) else if (gdbpy_is_string (sym_obj)) { char *var_name; - const struct block *block = NULL; struct cleanup *cleanup; var_name = python_string_to_target_string (sym_obj); @@ -536,11 +536,14 @@ frapy_read_var (PyObject *self, PyObject *args) TRY { + struct block_symbol lookup_sym; FRAPY_REQUIRE_VALID (self, frame); if (!block) block = get_frame_block (frame, NULL); - var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL).symbol; + lookup_sym = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); + var = lookup_sym.symbol; + block = lookup_sym.block; } CATCH (except, RETURN_MASK_ALL) { @@ -572,7 +575,7 @@ frapy_read_var (PyObject *self, PyObject *args) { FRAPY_REQUIRE_VALID (self, frame); - val = read_var_value (var, frame); + val = read_var_value (var, block, frame); } CATCH (except, RETURN_MASK_ALL) { diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e3336b1..ac97723 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -43,16 +43,17 @@ enum mi_print_types NAME is a pass-through argument where the name of the symbol will be written. NAME is allocated in this function, but the caller is responsible for clean up. SYM is a pass-through argument where the - symbol will be written. In the case of the API returning a string, - this will be set to NULL. LANGUAGE is also a pass-through argument - denoting the language attributed to the Symbol. In the case of SYM - being NULL, this will be set to the current language. Returns - EXT_LANG_BT_ERROR on error with the appropriate Python exception set, and - EXT_LANG_BT_OK on success. */ + symbol will be written and SYM_BLOCK is a pass-through argument to + write the block where the symbol lies in. In the case of the API + returning a string, this will be set to NULL. LANGUAGE is also a + pass-through argument denoting the language attributed to the + Symbol. In the case of SYM being NULL, this will be set to the + current language. Returns EXT_LANG_BT_ERROR on error with the + appropriate Python exception set, and EXT_LANG_BT_OK on success. */ static enum ext_lang_bt_status extract_sym (PyObject *obj, char **name, struct symbol **sym, - const struct language_defn **language) + struct block **sym_block, const struct language_defn **language) { PyObject *result = PyObject_CallMethod (obj, "symbol", NULL); @@ -75,12 +76,18 @@ extract_sym (PyObject *obj, char **name, struct symbol **sym, python_language. */ *language = python_language; *sym = NULL; + *sym_block = NULL; } else { /* This type checks 'result' during the conversion so we just call it unconditionally and check the return. */ *sym = symbol_object_to_symbol (result); + /* TODO: currently, we have no way to recover the block in which SYMBOL + was found, so we have no block to return. Trying to evaluate SYMBOL + will yield an incorrect value when it's located in a FRAME and + evaluated from another frame (as permitted in nested functions). */ + *sym_block = NULL; Py_DECREF (result); @@ -537,10 +544,11 @@ enumerate_args (PyObject *iter, const struct language_defn *language; char *sym_name; struct symbol *sym; + struct block *sym_block; struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; - success = extract_sym (item, &sym_name, &sym, &language); + success = extract_sym (item, &sym_name, &sym, &sym_block, &language); if (success == EXT_LANG_BT_ERROR) { Py_DECREF (item); @@ -736,12 +744,13 @@ enumerate_locals (PyObject *iter, struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; struct symbol *sym; + struct block *sym_block; int local_indent = 8 + (8 * indent); struct cleanup *locals_cleanups; locals_cleanups = make_cleanup_py_decref (item); - success = extract_sym (item, &sym_name, &sym, &language); + success = extract_sym (item, &sym_name, &sym, &sym_block, &language); if (success == EXT_LANG_BT_ERROR) { do_cleanups (locals_cleanups); @@ -769,7 +778,7 @@ enumerate_locals (PyObject *iter, { TRY { - val = read_var_value (sym, frame); + val = read_var_value (sym, sym_block, frame); } CATCH (except, RETURN_MASK_ERROR) { diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index f6466bd..3d2fa91 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -278,7 +278,11 @@ sympy_value (PyObject *self, PyObject *args) if (symbol_read_needs_frame (symbol) && frame_info == NULL) error (_("symbol requires a frame to compute its value")); - value = read_var_value (symbol, frame_info); + /* TODO: currently, we have no way to recover the block in which SYMBOL + was found, so we have no block to pass to read_var_value. This will + yield an incorrect value when symbol is not local to FRAME_INFO (this + can happen with nested functions). */ + value = read_var_value (symbol, NULL, frame_info); } CATCH (except, RETURN_MASK_ALL) { |