diff options
author | Tom Tromey <tromey@adacore.com> | 2024-11-12 13:07:46 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-12-09 14:05:02 -0700 |
commit | 9ba5ef4bf1e3266db47eb500beab803d03c74b3f (patch) | |
tree | 1745f4b52e1c663b12626a269309647a694dc411 /gdb/python | |
parent | 6b9efd5c1a6ead15845ef5d40b0a4bdc2cb33480 (diff) | |
download | gdb-9ba5ef4bf1e3266db47eb500beab803d03c74b3f.zip gdb-9ba5ef4bf1e3266db47eb500beab803d03c74b3f.tar.gz gdb-9ba5ef4bf1e3266db47eb500beab803d03c74b3f.tar.bz2 |
Omit artificial symbols from DAP variables response
While testing DAP, we found a situation where a compiler-generated
variable caused the "variables" request to fail -- the variable in
question being an apparent 67-megabyte string.
It seems to me that artificial variables like this aren't interesting
to DAP users, and the gdb CLI omits these as well.
This patch changes DAP to omit these variables, adding a new
gdb.Symbol.is_artificial attribute to make this possible.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/FrameDecorator.py | 3 | ||||
-rw-r--r-- | gdb/python/lib/gdb/dap/globalvars.py | 2 | ||||
-rw-r--r-- | gdb/python/py-symbol.c | 14 |
3 files changed, 18 insertions, 1 deletions
diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py index 82412de..5cdfbe1 100644 --- a/gdb/python/lib/gdb/FrameDecorator.py +++ b/gdb/python/lib/gdb/FrameDecorator.py @@ -285,6 +285,9 @@ class FrameVars(object): # returns False for arguments as well. Anyway, # don't include non-variables here. continue + elif sym.is_artificial: + # Skip artificial symbols. + continue lvars.append(SymValueWrapper(frame, sym)) if block.function is not None: diff --git a/gdb/python/lib/gdb/dap/globalvars.py b/gdb/python/lib/gdb/dap/globalvars.py index 38bdc5c..104b242 100644 --- a/gdb/python/lib/gdb/dap/globalvars.py +++ b/gdb/python/lib/gdb/dap/globalvars.py @@ -86,7 +86,7 @@ def get_global_scope(frame): syms = [] block_iter = block while block_iter is not None: - syms += [sym for sym in block_iter if sym.is_variable] + syms += [sym for sym in block_iter if sym.is_variable and not sym.is_artificial] block_iter = block_iter.superblock if len(syms) == 0: diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 24b53bb..c1f8d6c 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -205,6 +205,18 @@ sympy_is_variable (PyObject *self, void *closure) || theclass == LOC_OPTIMIZED_OUT)); } +/* Implementation of Symbol.is_artificial. */ + +static PyObject * +sympy_is_artificial (PyObject *self, void *closure) +{ + struct symbol *symbol = nullptr; + + SYMPY_REQUIRE_VALID (self, symbol); + + return PyBool_FromLong (symbol->is_artificial ()); +} + /* Implementation of gdb.Symbol.needs_frame -> Boolean. Returns true iff the symbol needs a frame for evaluation. */ @@ -709,6 +721,8 @@ to display demangled or mangled names.", NULL }, { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." }, { "is_argument", sympy_is_argument, NULL, "True if the symbol is an argument of a function." }, + { "is_artificial", sympy_is_artificial, nullptr, + "True if the symbol is marked artificial." }, { "is_constant", sympy_is_constant, NULL, "True if the symbol is a constant." }, { "is_function", sympy_is_function, NULL, |