summaryrefslogtreecommitdiff
path: root/gdbstub.c
AgeCommit message (Collapse)AuthorFilesLines
2012-06-04make gdb_id() generally avialable and rename it to cpu_index()Wen Congyang1-14/+5
The following patch also needs this API, so make it generally avialable. The function gdb_id() will not be used in gdbstub.c now, so its name is not suitable, and rename it to cpu_index() Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-04-21gdbstub: Synchronize CPU state unconditionally in gdb_set_cpu_pcPeter Maydell1-2/+1
Synchronize the CPU state via cpu_sychronize_state() unconditionally in gdb_set_cpu_pc() rather than only in some of the target ifdef ladder cases. We can divide the CPUs into three categories: * non-KVM targets: no change of behaviour since we will use the kvm-stub.c no-op function. * i386 and s390: no change of behaviour since they were already calling this function * PPC (in KVM mode): this fixes an error: failing to synchronise was accidental and probably a bug. This also paves the way for other targets (specifically ARM) which can add KVM support in future without having to add another target specific change to this bit of code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-03-24gdbserver: Don't send a GDB syscall until the system CPU is stoppedMeador Inge1-15/+27
Fix an issue where the GDB server implementation was sending GDB syscall requests while the system CPU was still running. Syscall requests must be sent while the CPU is stopped otherwise replies from the GDB client might get dropped and the GDB server might be incorrectly transitioned into a 'RUN_STATE_PAUSED' state. Signed-off-by: Meador Inge <meadori@codesourcery.com> [PMM: trivial rebase, reinstated comma after last item in RSState enum] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-03-14Rename CPUState -> CPUArchStateAndreas Färber1-22/+22
Scripted conversion: for file in *.[hc] hw/*.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do sed -i "s/CPUState/CPUArchState/g" $file done All occurrences of CPUArchState are expected to be replaced by QOM CPUState, once all targets are QOM'ified and common fields have been extracted. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-14monitor: Avoid CPUState in read/write functionsAndreas Färber1-28/+28
Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-11gdbstub: Do not kill target in system emulation modeJan Kiszka1-0/+2
Too many VM kittens were killed since 7d03f82f81. Another one just died under my fat fingers. When you quit a kgdb session, does the Linux kernel power off? Or when you terminate gdb attached to a hardware debugger, does your board vanish in space? No. So let's stop terminating QEMU when the gdbstub receives a kill commando in system emulation mode. Real termination can still be achieved via "monitor quit". We keep the behavior for user mode emulation which is arguably more like a gdbserver scenario. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-01-06gdbstub: Fix fd leak in gdbserver_open() error pathPeter Maydell1-0/+2
Fix a leak of a file descriptor in error exit paths in gdbserver_open(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-14Fix spelling in comments, documentation and messagesStefan Weil1-1/+1
accidently->accidentally annother->another choosen->chosen consideres->considers decriptor->descriptor developement->development paramter->parameter preceed->precede preceeding->preceding priviledge->privilege propogation->propagation substraction->subtraction throught->through upto->up to usefull->useful Fix also grammar in posix-aio-compat.c Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-19gdbstub: Fix memory leakStefan Weil1-6/+8
cppcheck report: gdbstub.c:1781: error: Memory leak: s Rearranging of the code avoids the leak. v2: Replace the g_malloc0() by g_new0() (suggested by Stuart Brady). Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-26target-sparc: Change fpr representation to doubles.Richard Henderson1-11/+24
This allows a more efficient representation for 64-bit hosts. It should be about the same for 32-bit hosts, as we can still access the individual pieces of the double. Signed-off-by: Richard Henderson <rth@twiddle.net>
2011-10-10Merge remote-tracking branch 'qmp/queue/qmp' into stagingAnthony Liguori1-13/+13
2011-10-06Gdbstub: handle read of fpscrFabien Chouteau1-1/+1
Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2011-10-04RunState: Rename enum values as generated by the QAPILuiz Capitulino1-13/+13
Next commit will convert the query-status command to use the RunState type as generated by the QAPI. In order to "transparently" replace the current enum by the QAPI one, we have to make some changes to some enum values. As the changes are simple renames, I'll do them in one shot. The changes are: - Rename the prefix from RSTATE_ to RUN_STATE_ - RUN_STATE_SAVEVM to RUN_STATE_SAVE_VM - RUN_STATE_IN_MIGRATE to RUN_STATE_INMIGRATE - RUN_STATE_PANICKED to RUN_STATE_INTERNAL_ERROR - RUN_STATE_POST_MIGRATE to RUN_STATE_POSTMIGRATE - RUN_STATE_PRE_LAUNCH to RUN_STATE_PRELAUNCH - RUN_STATE_PRE_MIGRATE to RUN_STATE_PREMIGRATE - RUN_STATE_RESTORE to RUN_STATE_RESTORE_VM - RUN_STATE_PRE_MIGRATE to RUN_STATE_FINISH_MIGRATE Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Drop the vm_running global variableLuiz Capitulino1-2/+2
Use runstate_is_running() instead, which is introduced by this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Replace the VMSTOP macros with a proper state typeLuiz Capitulino1-15/+15
Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-10Gdbstub: Fix back-trace on SPARC32Fabien Chouteau1-3/+13
Gdb expects all registers windows to be flushed in ram, which is not the case in Qemu. Therefore the back-trace generation doesn't work. This patch adds a function to handle reads (and only read) in stack frames as if windows were flushed. Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-10target-xtensa: add gdb supportMax Filippov1-0/+96
Specific xtensa processor overlay for GDB contains register map in the gdb/xtensa-config.c. This description is used by the GDB to e.g. parse 'g' response packets and it may be reused in the qemu's gdbstub (only XTREG definitions for non-pseudoregisters are needed). Currently mainline GDB does not support operations with privileged SRs (see http://sourceware.org/ml/gdb/2011-07/msg00075.html). This support may be enabled, see NUM_CORE_REGS comment in the gdbstub.c Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-22char: rename qemu_chr_close() -> qemu_chr_delete()Anthony Liguori1-2/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_open() -> qemu_chr_new()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_read() -> qemu_chr_be_write()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22char: rename qemu_chr_write() -> qemu_chr_fe_write()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-4/+4
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-25Wrap recv to avoid warningsBlue Swirl1-1/+1
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o /src/qemu/slirp/ip_icmp.c: In function 'icmp_receive': /src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror] /usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *' Remove also casts used to avoid warnings. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-06-26Remove exec-all.h include directivesBlue Swirl1-1/+1
Most exec-all.h include directives are now useless, remove them. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-06-03target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndefAurelien Jarno1-4/+0
target-mips has been switched to softfloat only long ago, but a #ifndef CONFIG_SOFTFLOAT has been forgotten. Remove it. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-05-20s390x: Adjust GDB stubAlexander Graf1-2/+6
We have successfully lazilized cc computation, so we need to manually trigger its calculation when gdb wants to fetch it. We also changed the variable name, so writing it writes into a different field now. Signed-off-by: Alexander Graf <agraf@suse.de>
2011-04-03gdbstub: Catch and report more vmstop reasonsJan Kiszka1-10/+39
When the VM goes into stop state while there is a gdb frontend attached, it makes sense to inform gdb about this fact and at least a bit about the stop reason. Basically, all stops are interesting except for the temporary VMSTOP_SAVE/LOADVM. The patch maps the relevant VMSTOP reasons on unique and more or less associatable signals that gdb understands. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-03-07lm32: gdbstub supportMichael Walle1-0/+76
This patch adds lm32 support to the gdbstub. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2011-02-14Improve vm_stop reason declarationsJan Kiszka1-9/+10
Define and use dedicated constants for vm_stop reasons, they actually have nothing to do with the EXCP_* defines used so far. At this chance, specify more detailed reasons so that VM state change handlers can evaluate them. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-01-16gdbstub: Close connection in gdb_exitFabien Chouteau1-0/+6
On Windows, this is required to flush the remaining data in the IO stream, otherwise Gdb do not receive the last packet. Version 2: Fix linux-user build error. Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
2010-09-18Use gcc warning flag -Wnested-externsBlue Swirl1-1/+0
If the compiler supports the warning flag -Wnested-externs, use it. Avoid the only warning by moving the declaration of xml_builtin to a more proper place. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-03remove exec-all.h inclusion from cpu.hPaolo Bonzini1-0/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-16GDB exit status for semihostingPaul Brook1-14/+20
Report exit status to GDB when a semihosted application exits. Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-05-09sparc: Fix lazy flag calculation on interrupts, refactorBlue Swirl1-8/+8
Recalculate Sparc64 CPU flags on interrupts, otherwise some earlier flags could be stored to pstate. Refactor PSR/CCR/CWP handling: concentrate the actual functions to op_helper.c. Thanks to Igor Kovalenko for reporting. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-02-27target-sh4: Fix gdb read/write registertakasi-y@ops.dti.ne.jp1-13/+14
cpu_gdb_read_register(): Fix n={8...15} case. cpu_gdb_write_register(): Fix n={8...15} case and runaway "case:". Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-27Fix to 'gdb detach' stubDaniel Gutson1-0/+1
With this patch, 'gdb detach' correctly resumes the inferior execution after detaching the debugger. The bug was caused by qemu asking gdb to execute a syscall (isatty) after the detach, and then waiting (forever) for the reply. I fixed this by properly setting gdb_syscall_mode appropriately in the 'detach' packet handling, so subsequent syscalls are solved by qemu rather than gdb. Signed-off-by: Daniel Gutson <dgutson@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-23target-alpha: Fix gdb access to fpcr and unique.Richard Henderson1-34/+54
cpu_gdb_read/write_register need to access the fpcr via the cpu_alpha_load/store_fpcr functions. The unique register is number 66 in the gdb remote protocol. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-20cris: Add CRISv10 gdbstub support.Edgar E. Iglesias1-0/+36
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2010-01-14target-m68k: fix a typo in 'P' packet processingKazu Hirata1-1/+1
Attached is a patch to fix a typo in 'P' packet processing for M68K. Without this patch, QEMU fails to honor GDB's P packets from GDB (writing to registers) for the address registers (A0 - A7). The problem is because of an obvious typo. Notice that the second "if" condition is meant to be n < 16 in: if (n < 8) { : } else if (n < 8) { Signed-off-by: Kazu Hirata <kazu@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-13gdbstub: add MIPS16 supportNathan Froyd1-3/+15
The only thing to do here is to expose the current processor mode to GDB and to set the processor mode properly when we change the PC. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-05S390 GDB stubAlexander Graf1-0/+52
In order to debug funny kernel breakages it's always good to have a working gdb stub around. While Uli's patches don't include one one, I needed one that's at least good enough for 'bt' and some variable examinations during early bootup. So here it is - the absolute basics to get the qemu gdb stub running with s390x targets. Sgined-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-03Don't leak file descriptorsKevin Wolf1-0/+6
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-21char: rename CHR_EVENT_RESET to CHR_EVENT_OPENEDAmit Shah1-1/+1
The char event RESET is emitted when a char device is opened. Give it a better name. Patchworks-ID: 35287 Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05gdbstub: x86: Switch 64/32 bit registers dynamicallyJan Kiszka1-13/+42
Commit 56aebc891674cd2d07b3f64183415697be200084 changed gdbstub in way that debugging 32 or 16-bit guest code is no longer possible with qemu for x86_64 guest CPUs. Since that commit, qemu only provides registers sets for 64-bit, forcing current and foreseeable gdb to also switch its architecture to 64-bit. And this breaks if the inferior is 32 or 16 bit. No question, this is a gdb issue. But, as it was confirmed in several discusssions with gdb people, it is a non-trivial thing to fix. So until qemu finds a gdb version attach with a rework x86 support, we have to work around it by switching the register layout as the guest switches its execution mode between 16/32 and 64 bit. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-30gdbstub: fix coding style nitMichael S. Tsirkin1-1/+1
Put space between = and * when dereferencing a pointer, to avoid confusion with old-style "*=" Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-27kvm: Simplify cpu_synchronize_state()Avi Kivity1-4/+4
cpu_synchronize_state() is a little unreadable since the 'modified' argument isn't self-explanatory. Simplify it by making it always synchronize the kernel state into qemu, and automatically flush the registers back to the kernel if they've been synchronized on this exit. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27rename USE_NPTL to CONFIG_USE_NPTLJuan Quintela1-1/+1
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16Update to a hopefully more future proof FSF addressBlue Swirl1-2/+1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-16gdbstub: x86: Support for setting segment registersJan Kiszka1-17/+31
This allows to set segment registers via gdb also in system emulation mode. Basic sanity checks are applied and nothing is changed if they fail. But screwing up the target via this interface will never be complicated, so I avoided being too paranoid here. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16gdbstub: x86: Refactor register accessJan Kiszka1-73/+83
Clarify gdb's register set layout by using constants for cpu_gdb_read/write_register. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>