gdb: z80: Fix endless loop in frame unwinder and validate saved register types

In z80_frame_unwind_cache, the loop scanning for the frame base pointer
(for (;; ++sp)) could run into an endless loop or scan too far if the
termination condition (sp < this_base) was not met due to corrupted
or unexpected stack layouts. This patch introduces a loop_count to
limit the scan to a maximum of 2 * addr_len iterations.

Additionally, when iterating through saved registers to adjust their
offsets into concrete addresses, the code now explicitly checks if
the register actually holds an address using is_addr() before calling
addr(). This prevents potential assertions or undefined behavior for
registers that do not contain valid address data.

gdb/ChangeLog:

	* z80-tdep.c (z80_frame_unwind_cache): Limit stack scanning
	to 2 * addr_len iterations to prevent endless loops. Check
	is_addr() before adjusting saved register addresses.

Approved-By: Kevin Buettner <kevinb@redhat.com>
1 file changed