[Bug:cli] Loading user-defined function generates an internal error

Nick Roberts
2009-12-30T05:35:36Z

If the user-defined function below is put in a file user.cmd, say, then in
internal error is generated upon loading it:

..
(gdb) source user.cmd
utils.c:1206: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
utils.c:1206: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
Aborted (core dumped)

This didn't used to happen, say 3 months ago.

--
Nick http://users.snap.net.nz/~nickrob

define p_tree

set $tree = ($arg0)
set $i = 0
set $node = $tree->_M_t->_M_impl->_M_header->_M_left
set $tree_size = $tree->_M_t->_M_impl->_M_node_count

while ($i < $tree_size)
set $i++
printf "NODE %d: ", $i
set $value = (void *)($node + 1)
p *($arg1 *)$value
set $value = $value + 4
p *($arg2 *)$value

# Next (bigger) value must be to right...
if ($node->_M_right != 0)
set $node = $node->_M_right

# Descend tree while there is a left node.
while ($node->_M_left != 0)
set $node = $node->_M_left
end

# ...or further up the tree.
else
set $tmp_node = $node->_M_parent

# Ascend tree while at right node.
while ($node == $tmp_node->_M_right)
set $node = $tmp_node
set $tmp_node = $tmp_node->_M_parent
end

# Set to parent of first left node (condition always true?)
if ($node->_M_right != $tmp_node)
set $node = $tmp_node
end
end
end
end