gdbstub: Change GDBState::query_cpu to CPUState

Since first_cpu/next_cpu are CPUState, CPUArchState is no longer needed.

This resolves a NULL pointer dereference of query_cpu, introduced
with commit 182735efaf956ccab50b6d74a4fed163e0f35660 and reported by
TeLeMan and Max Filippov.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Introduce vaddr type

vaddr is to target_ulong what uintmax_t is to unsigned int.

Its purpose is to allow turning per-target functions with target_ulong
arguments into CPUClass hooks.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
HACKING: Document vaddr type usage

Also extend documentation of target_ulong and abi_ulong.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Introduce CPUClass::set_pc() for gdb_set_cpu_pc()

This moves setting the Program Counter from gdbstub into target code.
Use vaddr type as upper-bound replacement for target_ulong.

Signed-off-by: Andreas Färber <afaerber@suse.de>
target-m68k: Implement CPUClass::set_pc()

This adds support for GDB's c addr (Continue) and s addr (Single Step).

Prepares for dropping cpu_pc_from_tb().

Signed-off-by: Andreas Färber <afaerber@suse.de>
target-moxie: Implement CPUClass::set_pc()

This adds support for GDB's c addr (Continue) and s addr (Single Step).

Prepares for dropping cpu_pc_from_tb().

Signed-off-by: Andreas Färber <afaerber@suse.de>
target-unicore32: Implement CPUClass::set_pc()

This adds support for GDB's c addr (Continue) and s addr (Single Step).

Prepares for dropping cpu_pc_from_tb().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Introduce CPUClass::synchronize_from_tb() for cpu_pc_from_tb()

Where no extra implementation is needed, fall back to CPUClass::set_pc().

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-alpha: Copy singlestep_enabled to DisasContext

Prepare for removing env from DisasContext.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-alpha: Copy implver to DisasContext

Which allows removing env from DisasContext.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Move singlestep_enabled field from CPU_COMMON to CPUState

Prepares for changing cpu_single_step() argument to CPUState.

Acked-by: Michael Walle <michael@walle.cc> (for lm32)
Signed-off-by: Andreas Färber <afaerber@suse.de>
gdbstub: Update gdb_handlesig() and gdb_signalled() Coding Style

In particular reindent to 4 instead of 2 spaces.

Prepares for changing cpu_single_step() argument in gdb_handlesig().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Change cpu_single_step() argument to CPUState

Use CPUState::env_ptr for now.

Needed for GdbState::c_cpu.

Signed-off-by: Andreas Färber <afaerber@suse.de>
kvm: Change kvm_{insert,remove}_breakpoint() argument to CPUState

CPUArchState is no longer directly used since converting CPU loops to
CPUState.

Prepares for changing GDBState::c_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
gdbstub: Change syscall callback argument to CPUState

Callback implementations were specific to arm and m68k, so can easily
cast to ARMCPU and M68kCPU respectively.

Prepares for changing GDBState::c_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
gdbstub: Change gdb_handlesig() argument to CPUState

Prepares for changing GDBState::c_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
gdbstub: Change gdb_{read,write}_register() argument to CPUState

Use CPUState::env_ptr for now.

Prepares for changing GDBState::g_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Turn cpu_get_phys_page_debug() into a CPUClass hook

Change breakpoint_invalidate() argument to CPUState alongside.

Since all targets now assign a softmmu-only field, we can drop helpers
cpu_class_set_{do_unassigned_access,vmsd}() and device_class_set_vmsd().

Prepares for changing cpu_memory_rw_debug() argument to CPUState.

Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa)
Signed-off-by: Andreas Färber <afaerber@suse.de>
exec: Change cpu_memory_rw_debug() argument to CPUState

Propagate X86CPU in kvmvapic for simplicity.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Introduce CPUClass::memory_rw_debug() for target_memory_rw_debug()

Make inline target_memory_rw_debug() always available and change its
argument to CPUState. Let it check if CPUClass::memory_rw_debug provides
a specialized callback and fall back to cpu_memory_rw_debug() otherwise.

The only overriding implementation is for 32-bit sparc.

This prepares for changing GDBState::g_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>