(with instances of gdbserver running on both ports on the remotehost).
The errors I see are:
gdb in realloc(): warning: modified (page-) pointer
../../../gdb-w/gdb/utils.c:994: internal-error: virtual memory exhausted: can't allocate 2032 bytes
(the former error is from the NetBSD realloc call)
The problem is that update_current_inferior() will copy a valid
to_sections value out of one of the targets in the stack into
current_target, but that pointer may become invalid later when
target_resize_to_sections() is called again on any target using the
same pointer. Finally, when handle_inferior_event() calls
SOLIB_ADD(.., ¤t_target, ...), target_resize_to_sections() calls
realloc() again on a pointer that's already been realloc'd. "Boom."
My fix is to make target_resize_to_sections update current_target as
well as all of the targets in target_structs. Seems to do the job,
though I can't say it thrills me.
Comments? Suggestions for better approaches? It definitely fixes the
problem, and doesn't seem any messier than the rest of the target
stack stuff. It might be better to not use current_target with
anything that looks at to_sections, but I've no idea how difficult it
might be to do that.
- Nathan
2004-08-25 Nathan J. Williams <nathanw@wasabisystems.com>
* target.c (target_resize_to_sections): Check
current_target.to_sections for an old value when updating.