gdbsx: debugger on xen for guests
PATCH 1/1 gdbsx: debugger on xen for guests
Hi,
Included and attached is a patch for gdbsx against c/s 20315. It was tested on c/s 20303 and compile tested on c/s 20315. I tested for following:
64bit hyp + 64bit dom0 : 32-pae and 64bit, both PV and HVM linux guests 64bit hyp + 32bit dom0 : 32-pae and 64bit both PV and HVM linux guests 32bit hyp: compile tested only.
Please note:
- I wasn't sure if I should add to tools/Makefile, so I didn't.
- x86 only
- I picked, 1000 - 1003 for gdbsx domctl subcalls. Please feel free to change.
Thanks,
Mukesh
# HG changeset patch
# User Mukesh Rathor
# Date 1255562790 25200
# Node ID 167e895ef770f26952d0ad7941658aecbc62cb9b
# Parent 18758847bf313a191731278c41af7519dfa85ecf
This patch implementes gdbsx, a gdbserver stub for xen. It allows for debugging of elf guests on xen. It can also be used to dump vcpu contexts. It should be run on dom0 on gdbsx enabled hypervisor. For details, please see tools/debugger/gdbsx/README
Config.mk +4 -0
@@ -114,6 +114,10 @@ CFLAGS += -g endif +ifeq ($(gdbsx),y) +XEN_GDBSX_CONFIG ?= y +endif + CFLAGS += -fno-strict-aliasing CFLAGS += -std=gnu99
tools/debugger/gdbsx/Makefile new file +28 -0
@@ -0,0 +1,28 @@ +XEN_ROOT = ../../.. +include ./Rules.mk + +sbindir=/usr/sbin + +.PHONY: all +all: + $(MAKE) -C gx + $(MAKE) -C xg + $(MAKE) gdbsx + +.PHONY: clean +clean: + rm -f xg_all.a gx_all.a gdbsx + set -e; for d in xg gx; do $(MAKE) -C $$d clean; done + +.PHONY: install +install: all + [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir) + $(INSTALL_PROG) gdbsx $(DESTDIR)$(sbindir)/gdbsx + +gdbsx: gx/gx_all.a xg/xg_all.a + $(CC) -o $@ $^ + +xg/xg_all.a: + $(MAKE) -C xg +gx/gx_all.a: + $(MAKE) -C gx
tools/debugger/gdbsx/README new file +143 -0
143 lines not on this page · raw message
tools/debugger/gdbsx/Rules.mk new file +11 -0
@@ -0,0 +1,11 @@ +include $(XEN_ROOT)/tools/Rules.mk + +CFLAGS += -Werror -Wmissing-prototypes +# (gcc 4.3x and later) -Wconversion -Wno-sign-conversion +CFLAGS += -DXEN_GDBSX_CONFIG + +# just in case have to debug gdbsx, keep life simple. +TMPFLAGS := $(CFLAGS) +CFLAGS := $(filter-out -O% -DNDEBUG -fomit-frame-pointer, $(TMPFLAGS)) +CFLAGS += -O0 +
tools/debugger/gdbsx/gx/Makefile new file +20 -0
@@ -0,0 +1,20 @@ +XEN_ROOT = ../../../.. +include ../Rules.mk + +GX_OBJS := gx_comm.o gx_main.o gx_utils.o gx_local.o +GX_HDRS := $(wildcard *.h) + +.PHONY: all +all: gx_all.a + +.PHONY: clean +clean: + rm -rf gx_all.a *.o + + +#%.o: %.c $(GX_HDRS) Makefile +# $(CC) -c $(CFLAGS) -o $@ $< + +gx_all.a: $(GX_OBJS) Makefile $(GX_HDRS) + ar cr $@ $(GX_OBJS) # problem with ld using -m32 +
tools/debugger/gdbsx/gx/gx.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2009, Mukesh Rathor, Oracle Corp. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 021110-1307, USA. +*/ + +typedef uint16_t domid_t ; +typedef unsigned char uchar ; + +#include "../xg/xg_public.h" + +int gx_remote_open (char *commstr); +void gx_remote_close (void ); +int gx_getpkt (char *buf); +void gx_write_ok (char *buf); +void gx_write_err (char *buf); +void gx_convert_int_to_ascii (char *from,char *to,int n); +void gx_convert_ascii_to_int (char *from,char *to,int n); +int gx_putpkt (char *buf); +void gx_decode_m_packet (char *,uint64_t *,int *); +char *gx_decode_M_packet (char *,uint64_t *,int *); +void gx_decode_zZ_packet (char *,uint64_t *); +void gx_reply_ok (char *); +void gx_reply_error (char *); +int gx_fromhex (int ); +int gx_tohex (int ); +int gx_local_cmd (domid_t domid,vcpuid_t vcpuid); +void gxprt (const char *fmt, ...);
tools/debugger/gdbsx/gx/gx_comm.c new file +328 -0
328 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_local.c new file +146 -0
146 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_main.c new file +696 -0
696 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_utils.c new file +145 -0
145 lines not on this page · raw message
tools/debugger/gdbsx/gx/xg_dummy.c new file +122 -0
122 lines not on this page · raw message
tools/debugger/gdbsx/xg/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +XEN_ROOT = ../../../.. +include ../Rules.mk + +XG_HDRS := xg_public.h +XG_OBJS := xg_main.o + +CFLAGS += $(INCLUDES) -I. -I../../../include + + +.PHONY: all +all: build + +.PHONY: build +build: xen-headers xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile +# build: mk-symlinks xg_all.a $(XG_HDRS) $(XG_OBJS) Makefile +# build: mk-symlinks xg_all.a + +xg_all.a: $(XG_OBJS) Makefile $(XG_HDRS) + ar cr $@ $(XG_OBJS) # problems using -m32 in ld +# $(LD) -b elf32-i386 $(LDFLAGS) -r -o $@ $^ +# $(CC) -m32 -c -o $@ $^ + +xen-headers: + $(MAKE) -C ../../../check + $(MAKE) -C ../../../include + +# xg_main.o: xg_main.c Makefile $(XG_HDRS) +#$(CC) -c $(CFLAGS) -o $@ $< + +# %.o: %.c $(XG_HDRS) Makefile -- doesn't work as it won't overwrite Rules.mk +#%.o: %.c -- doesn't recompile when .c changed + +.PHONY: clean +clean: + rm -rf xen xg_all.a $(XG_OBJS) +
tools/debugger/gdbsx/xg/xg_main.c new file +799 -0
799 lines not on this page · raw message
tools/debugger/gdbsx/xg/xg_public.h new file +110 -0
110 lines not on this page · raw message
xen/Rules.mk +1 -0
@@ -56,6 +56,7 @@ CFLAGS-$(lock_profile) += -DLOCK_PROFILE CFLAGS-$(frame_pointer) += -fno-omit-frame-pointer -DCONFIG_FRAME_POINTER CFLAGS-$(privileged_stubdoms) += -DPRIVILEGED_STUBDOMS +CFLAGS-$(XEN_GDBSX_CONFIG) += -DXEN_GDBSX_CONFIG ifneq ($(max_phys_cpus),) CFLAGS-y += -DMAX_PHYS_CPUS=$(max_phys_cpus)
xen/arch/x86/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-y += bzimage.o obj-$(crash_debug) += gdbstub.o +obj-$(gdbsx) += debug.o x86_emulate.o: x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h
xen/arch/x86/debug.c new file +260 -0
260 lines not on this page · raw message
xen/arch/x86/hvm/svm/svm.c +7 -0
@@ -52,6 +52,10 @@#include <asm/hvm/trace.h> #include <asm/hap.h> +#if defined(XEN_KDB_CONFIG ) || defined(XEN_GDBSX_CONFIG ) +#include <asm/debugger.h> +#endif +u32 svm_feature_flags;#define set_segment_register (name, value) \
@@ -1370,6 +1374,9 @@if ( (inst_len =__get_instruction_length (v,INSTR_INT3 )) ==0 )break ;__update_guest_eip (regs, inst_len); +#ifdef XEN_GDBSX_CONFIG + current->gdbsx_vcpu_event = TRAP_int3; +#endif domain_pause_for_debugger ();break ;
xen/arch/x86/hvm/vmx/vmx.c +7 -0
@@ -52,6 +52,10 @@#include <asm/hvm/trace.h> #include <asm/xenoprof.h> +#if defined(XEN_KDB_CONFIG ) || defined(XEN_GDBSX_CONFIG ) +#include <asm/debugger.h> +#endif +enum handler_return { HNDL_done, HNDL_unhandled, HNDL_exception_raised };static void vmx_ctxt_switch_from (struct vcpu *v);
@@ -2475,6 +2479,9 @@ goto exit_and_crash; inst_len =__get_instruction_length ();/* Safe: INT3 */ __update_guest_eip (inst_len); +#ifdef XEN_GDBSX_CONFIG + current->gdbsx_vcpu_event = TRAP_int3; +#endif domain_pause_for_debugger ();break ;case TRAP_no_device:
xen/arch/x86/setup.c +4 -0
@@ -1171,6 +1171,10 @@safe_strcat (*info, s);#endif } + +#ifdef XEN_GDBSX_CONFIG +safe_strcat (*info,"gdbsx " ); +#endif }int xen_in_range (paddr_t start,paddr_t end)
xen/common/domctl.c +119 -0
44 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
# HG changeset patch
# User Mukesh Rathor
# Date 1255562790 25200
# Node ID 167e895ef770f26952d0ad7941658aecbc62cb9b
# Parent 18758847bf313a191731278c41af7519dfa85ecf
This patch implementes gdbsx, a gdbserver stub for xen. It allows for debugging of elf guests on xen. It can also be used to dump vcpu contexts. It should be run on dom0 on gdbsx enabled hypervisor. For details, please see tools/debugger/gdbsx/README
tools/debugger/gdbsx/Makefile new file +28 -0
Lines of this file are not shown. View the raw message.
tools/debugger/gdbsx/README new file +143 -0
143 lines not on this page · raw message
tools/debugger/gdbsx/Rules.mk new file +11 -0
Lines of this file are not shown. View the raw message.
tools/debugger/gdbsx/gx/Makefile new file +20 -0
Lines of this file are not shown. View the raw message.
tools/debugger/gdbsx/gx/gx_comm.c new file +328 -0
328 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_local.c new file +146 -0
146 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_main.c new file +696 -0
696 lines not on this page · raw message
tools/debugger/gdbsx/gx/gx_utils.c new file +145 -0
145 lines not on this page · raw message
tools/debugger/gdbsx/gx/xg_dummy.c new file +122 -0
122 lines not on this page · raw message
tools/debugger/gdbsx/xg/Makefile new file +36 -0
Lines of this file are not shown. View the raw message.
tools/debugger/gdbsx/xg/xg_main.c new file +799 -0
799 lines not on this page · raw message
tools/debugger/gdbsx/xg/xg_public.h new file +110 -0
110 lines not on this page · raw message
xen/arch/x86/debug.c new file +260 -0
260 lines not on this page · raw message
xen/common/domctl.c +119 -0
119 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.