mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-29 21:04:22 +08:00
Change how Python architecture and language are handled
Currently, gdb's Python layer captures the current architecture and language when "entering" Python code. This has some undesirable effects, and so this series changes how this is handled. First, there is code like this: gdbpy_enter enter_py (python_gdbarch, python_language); This is incorrect, because both of these are NULL when not otherwise assigned. This can cause crashes in some cases -- I've added one to the test suite. (Note that this crasher is just an example, other ones along the same lines are possible.) Second, when the language is captured in this way, it means that Python code cannot affect the current language for its own purposes. It's reasonable to want to write code like this: gdb.execute('set language mumble') ... stuff using the current language gdb.execute('set language previous-value') However, this won't actually work, because the language is captured on entry. I've added a test to show this as well. This patch changes gdb to try to avoid capturing the current values. The Python concept of the current gdbarch is only set in those few cases where a non-default value is computed or needed; and the language is not captured at all -- instead, in the cases where it's required, the current language is temporarily changed.
This commit is contained in:
@ -74,11 +74,11 @@ extract_sym (PyObject *obj, gdb::unique_xmalloc_ptr<char> *name,
|
||||
if (*name == NULL)
|
||||
return EXT_LANG_BT_ERROR;
|
||||
/* If the API returns a string (and not a symbol), then there is
|
||||
no symbol derived language available and the frame filter has
|
||||
either overridden the symbol with a string, or supplied a
|
||||
entirely synthetic symbol/value pairing. In that case, use
|
||||
python_language. */
|
||||
*language = python_language;
|
||||
no symbol derived language available and the frame filter has
|
||||
either overridden the symbol with a string, or supplied a
|
||||
entirely synthetic symbol/value pairing. In that case, use
|
||||
the current language. */
|
||||
*language = current_language;
|
||||
*sym = NULL;
|
||||
*sym_block = NULL;
|
||||
}
|
||||
@ -1157,7 +1157,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
|
||||
return EXT_LANG_BT_NO_FILTERS;
|
||||
}
|
||||
|
||||
gdbpy_enter enter_py (gdbarch, current_language);
|
||||
gdbpy_enter enter_py (gdbarch);
|
||||
|
||||
/* When we're limiting the number of frames, be careful to request
|
||||
one extra frame, so that we can print a message if there are more
|
||||
|
Reference in New Issue
Block a user