diff options
author | Tom Tromey <tromey@adacore.com> | 2025-07-30 08:30:49 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-08-11 07:39:10 -0600 |
commit | 9ef3249a00f50ee00e3973e5901cd2936abc79b3 (patch) | |
tree | 60c3bdc16947c5634ac312a69c3b051e0b8985b0 /gdb/python | |
parent | ddd2795c52228cbbdf11aa95e11b68647b10df88 (diff) | |
download | binutils-9ef3249a00f50ee00e3973e5901cd2936abc79b3.zip binutils-9ef3249a00f50ee00e3973e5901cd2936abc79b3.tar.gz binutils-9ef3249a00f50ee00e3973e5901cd2936abc79b3.tar.bz2 |
Emit DAPException when too many variable children are reqeusted
PR dap/33228 points out a failure that occurs when the DAP client
requests more children of a variable than actually exist. Currently,
gdb throws a somewhat confusing exception. This patch changes this
code to throw a DAPException instead, resulting in a more ordinary and
readable failure.
The spec seems to be silent on what to do in this case. I chose an
exception on the theory that it's easier to be strict now and lift the
restriction later (if needed) than vice versa.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33228
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/varref.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py index 8a13c51..1b54fe7 100644 --- a/gdb/python/lib/gdb/dap/varref.py +++ b/gdb/python/lib/gdb/dap/varref.py @@ -146,6 +146,10 @@ class BaseReference(ABC): if self._children is None: self._children = [None] * self.child_count() for idx in range(start, start + count): + if idx >= len(self._children): + raise DAPException( + f"requested child {idx} outside range of variable {self._ref}" + ) if self._children[idx] is None: (name, value) = self.fetch_one_child(idx) name = self._compute_name(name) |