summaryrefslogtreecommitdiffstats
path: root/gdbstub.c
Commit message (Collapse)AuthorAgeFilesLines
* semihosting: create SemihostingConfig structure and semihost.hLeon Alrae2015-06-191-4/+4
| | | | | | | | | | | | | | | Remove semihosting_enabled and semihosting_target and replace them with SemihostingConfig structure containing equivalent fields. The structure is defined in vl.c where it is actually set. Also introduce separate header file include/exec/semihost.h allowing to access semihosting config related stuff from target specific semihosting code. Signed-off-by: Leon Alrae <leon.alrae@imgtec.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1434643256-16858-2-git-send-email-leon.alrae@imgtec.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* Revert "gdbstub: Do not kill target in system emulation mode"Fabien Chouteau2015-05-281-2/+0Star
| | | | | | | | | | | The requirements described in this patch are implemented by "Add GDB qAttached support". This reverts commit 00e94dbc7fd0110b0555d59592b004333adfb4b8. Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* Add GDB qAttached supportJan Kiszka2015-05-281-0/+10
| | | | | | | | | | | | | | | With this patch QEMU handles qAttached request from gdb. When QEMU replies 1, GDB sends a "detach" command at the end of a debugging session otherwise GDB sends "kill". The default value for qAttached is 1 on system emulation and 0 on user emulation. Based on original version by Fabien Chouteau. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* gdbstub: Introduce an is is_query_packet helperJan Kiszka2015-05-281-2/+10
| | | | | | | | | | This helper supports parsing of query packets with optional extensions. The separator can be specified so that we can use it already for both qqemu.sstep[=] and qSupported[:feature]. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* gdbstub: Fix qOffsets packet detectionJan Kiszka2015-05-281-1/+1
| | | | | | | | | | qOffsets has no additional optional parameters. So match the complete string to avoid stumbling over possible future commands with identical prefix. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* gdbstub: avoid possible NULL pointer dereferencePaolo Bonzini2015-03-101-3/+5
| | | | | | | | | Coverity reports that s->chr is checked after put_packet dereferences it. Move the check earlier, consistent with the code used for user-mode emulation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* Add the "-semihosting-config" option.Liviu Ionescu2014-12-111-2/+13
| | | | | | | | | | | | | | | | | | | | | | | The usual semihosting behaviour is to process the system calls locally and return; unfortuantelly the initial implementation dinamically changed the target to GDB during debug sessions, which, for the usual arm-none-eabi-gdb, is not implemented. The result was that during debug sessions the semihosting calls were discarded. This patch adds a configuration variable and an option to set it on the command line: -semihosting-config [enable=on|off,]target=native|gdb|auto This option enables semihosting and defines where the semihosting calls will be addressed, to QEMU ('native') or to GDB ('gdb'). The default is auto, which means 'gdb' during debug sessions and 'native' otherwise. Signed-off-by: Liviu Ionescu <ilg@livius.net> Message-id: 1416341957-9796-1-git-send-email-ilg@livius.net [PMM: moved declaration and definition of semihosting_target to gdbstub.h and gdbstub.c to fix build failure on linux-user] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* gdbstub: Add a missing case of signal number translation in gdbstubMartin Simmons2014-11-111-1/+4
| | | | | | | | | | | | | While using qemu with gdb "target remote" to debug an application that uses fork and exec, the qemu process receives SIGSTOP every time the forked process terminates (sending SIGCHLD). This is caused by a missing call to gdb_signal_to_target in gdbstub.c, which is fixed by this patch: Signed-off-by: Martin Simmons <martin@lispworks.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* gdbstub: Allow target CPUs to specify watchpoint STOP_BEFORE_ACCESS flagPeter Maydell2014-10-061-9/+23
| | | | | | | | | | | | | | | | | | | | | | GDB assumes that watchpoint set via the gdbstub remote protocol will behave in the same way as hardware watchpoints for the target. In particular, whether the CPU stops with the PC before or after the insn which triggers the watchpoint is target dependent. Allow guest CPU code to specify which behaviour to use. This fixes a bug where with guest CPUs which stop before the accessing insn GDB would manually step forward over what it thought was the insn and end up one insn further forward than it should be. We set this flag for the CPU architectures which set gdbarch_have_nonsteppable_watchpoint in gdb 7.7: ARM, CRIS, LM32, MIPS and Xtensa. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Tested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Tested-by: Michael Walle <michael@walle.cc> (for lm32) Message-id: 1410545057-14014-1-git-send-email-peter.maydell@linaro.org
* gdbstub: init mon_chr through qemu_chr_allocPavel Dovgalyuk2014-09-111-1/+1
| | | | | | | | | | | This patch initializes monitor for gdbstub with the qemu_chr_alloc function instead of just allocating the memory. Initialization function call is required, because it also creates chr_write_lock mutex, which is used when writing to this character device. Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* exec: Change cpu_breakpoint_{insert,remove{,_by_ref,_all}} argumentAndreas Färber2014-03-131-12/+8Star
| | | | | | Use CPUState. Allows to clean up CPUArchState in gdbstub. Signed-off-by: Andreas Färber <afaerber@suse.de>
* exec: Change cpu_watchpoint_{insert,remove{,_by_ref,_all}} argumentAndreas Färber2014-03-131-8/+9
| | | | | | Use CPUState. This lets us drop a few local env usages. Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Move watchpoint fields from CPU_COMMON to CPUStateAndreas Färber2014-03-131-4/+4
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Move opaque field from CPU_COMMON to CPUStateAndreas Färber2014-03-131-2/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* vl: allow "cont" from panicked statePaolo Bonzini2013-11-041-3/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After reporting the GUEST_PANICKED monitor event, QEMU stops the VM. The reason for this is that events are edge-triggered, and can be lost if management dies at the wrong time. Stopping a panicked VM lets management know of a panic even if it has crashed; management can learn about the panic when it restarts and queries running QEMU processes. The downside is of course that the VM will be paused while management is not running, but that is acceptable if it only happens with explicit "-device pvpanic". Upon learning of a panic, management (if configured to do so) can pick a variety of behaviors: leave the VM paused, reset it, destroy it. In addition to all of these behaviors, it is possible to dump the VM core from the host. However, right now, the panicked state is irreversible, and can only be exited by resetting the machine. This means that any policy decision is entirely in the hands of the host. In particular there is no way to use the "reboot on panic" option together with pvpanic. This patch makes the panicked state reversible (and removes various workarounds that were there because of the state being irreversible). With this change, management has a wider set of possible policies: it can just log the crash and leave policy to the guest, it can leave the VM paused. In particular, the "log the crash and continue" is implemented simply by sending a "cont" as soon as management learns about the panic. Management could also implement the "irreversible paused state" itself. And again, all such actions can be coupled with dumping the VM core. Unfortunately we cannot change the behavior of 1.6.0. Thus, even if it uses "-device pvpanic", management should check for "cont" failures. If "cont" fails, management can then log that the VM remained paused and urge the administrator to update QEMU. Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* gdbstub: call socket_set_fast_reuse instead of setting SO_REUSEADDRSebastian Ottlik2013-10-021-4/+2Star
| | | | | | | | | | SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik <ottlik@fzi.de> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cpu: Use QTAILQ for CPU listAndreas Färber2013-09-031-7/+7
| | | | | | | Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthand macros. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Fix gdb_register_coprocessor() register countingAndreas Färber2013-08-161-2/+4
| | | | | | | | | | | | | | | | | | Commit a0e372f0c49ac01faeaeb73a6e8f50e8ac615f34 reorganized the register counting for GDB. While it seems correct not to let the total number of registers skyrocket in an SMP scenario through a static variable, the distinction between total register count and 'g' packet register count (last_reg vs. num_g_regs) got lost among the way. Fix this by introducing CPUState::gdb_num_g_regs and using that in gdb_handle_packet(). Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Cc: qemu-stable@nongnu.org (stable-1.6) Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Introduce CPUClass::gdb_core_xml_file for GDB_CORE_XMLAndreas Färber2013-07-271-28/+14Star
| | | | | | | | Replace the GDB_CORE_XML define in gdbstub.c with a CPUClass field. Use first_cpu for qSupported and qXfer:features:read: for now. Add a stub for xml_builtin. Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Introduce CPUClass::gdb_{read,write}_register()Andreas Färber2013-07-271-73/+7Star
| | | | | | | | Completes migration of target-specific code to new target-*/gdbstub.c. Acked-by: Michael Walle <michael@walle.cc> (for lm32) Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa) Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Replace GET_REG*() macros with gdb_get_reg*() functionsAndreas Färber2013-07-271-29/+0Star
| | | | | | | | | | | | | This avoids polluting the global namespace with a non-prefixed macro and makes it obvious in the call sites that we return. Semi-automatic conversion using, e.g., sed -i 's/GET_REGL(/return gdb_get_regl(mem_buf, /g' target-*/gdbstub.c followed by manual tweaking for sparc's GET_REGA() and Coding Style. Acked-by: Michael Walle <michael@walle.cc> (for lm32) Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa) Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-xtensa: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-79/+1Star
| | | | | Acked-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-lm32: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-65/+1Star
| | | | | Acked-by: Michael Walle <michael@walle.cc> Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-s390x: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-59/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-alpha: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-65/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-cris: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-104/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-microblaze: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-28/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-sh4: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-116/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-openrisc: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-271-56/+1Star
| | | | | Reviewed-by: Jia Liu <proljc@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-mips: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-123/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-m68k: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-46/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-arm: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-73/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-sparc: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-179/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-ppc: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-100/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* target-i386: Move cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-202/+1Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Introduce CPUState::gdb_num_regs and CPUClass::gdb_num_core_regsAndreas Färber2013-07-261-64/+19Star
| | | | | | | | | | | | | CPUState::gdb_num_regs replaces num_g_regs. CPUClass::gdb_num_core_regs replaces NUM_CORE_REGS. Allows building gdb_register_coprocessor() for xtensa, too. As a side effect this should fix coprocessor register numbering for SMP. Acked-by: Michael Walle <michael@walle.cc> (for lm32) Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa) Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Drop dead code in cpu_gdb_{read,write}_register()Andreas Färber2013-07-261-25/+0Star
| | | | | | | GET_REG*() macros include a return statement, thus no need for break. Acked-by: Michael Walle <michael@walle.cc> (for lm32) Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Fix cpu_gdb_{read,write}_register() Coding StyleAndreas Färber2013-07-261-154/+292
| | | | | | | Add braces, replace tabs, remove trailing whitespace, drop space before parenthesis and place break etc. below case statements. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change gdb_register_coprocessor() argument to CPUStateAndreas Färber2013-07-231-4/+3Star
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Move gdb_regs field from CPU_COMMON to CPUStateAndreas Färber2013-07-231-5/+6
| | | | | | Prepares for changing gdb_register_coprocessor() argument to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change GDBState::{c,g}_cpu and find_cpu() to CPUStateAndreas Färber2013-07-231-52/+52
| | | | | | Use CPUState::env_ptr where still needed. Signed-off-by: Andreas Färber <afaerber@suse.de>
* cpu: Introduce CPUClass::memory_rw_debug() for target_memory_rw_debug()Andreas Färber2013-07-231-9/+12
| | | | | | | | | | | | 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>
* exec: Change cpu_memory_rw_debug() argument to CPUStateAndreas Färber2013-07-231-1/+1
| | | | | | Propagate X86CPU in kvmvapic for simplicity. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change gdb_{read,write}_register() argument to CPUStateAndreas Färber2013-07-231-6/+10
| | | | | | | | Use CPUState::env_ptr for now. Prepares for changing GDBState::g_cpu to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change gdb_handlesig() argument to CPUStateAndreas Färber2013-07-231-3/+3
| | | | | | Prepares for changing GDBState::c_cpu to CPUState. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change syscall callback argument to CPUStateAndreas Färber2013-07-231-1/+1
| | | | | | | | | 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>
* kvm: Change kvm_{insert,remove}_breakpoint() argument to CPUStateAndreas Färber2013-07-231-4/+8
| | | | | | | | | 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>
* cpu: Change cpu_single_step() argument to CPUStateAndreas Färber2013-07-231-4/+5
| | | | | | | | Use CPUState::env_ptr for now. Needed for GdbState::c_cpu. Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Update gdb_handlesig() and gdb_signalled() Coding StyleAndreas Färber2013-07-231-47/+47
| | | | | | | | 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: Introduce CPUClass::set_pc() for gdb_set_cpu_pc()Andreas Färber2013-07-231-33/+6Star
| | | | | | | 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>