direct-io.hg

changeset 11662:80388aea02a1

Remove dead pdb code from tools directory.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Sep 29 11:13:01 2006 +0100 (2006-09-29)
parents e5cdebf9d8ef
children 16759bdbd6c2
files tools/debugger/pdb/Domain.ml tools/debugger/pdb/Domain.mli tools/debugger/pdb/Intel.ml tools/debugger/pdb/Makefile tools/debugger/pdb/OCamlMakefile tools/debugger/pdb/PDB.ml tools/debugger/pdb/Process.ml tools/debugger/pdb/Process.mli tools/debugger/pdb/Util.ml tools/debugger/pdb/Xen_domain.ml tools/debugger/pdb/Xen_domain.mli tools/debugger/pdb/debugger.ml tools/debugger/pdb/evtchn.ml tools/debugger/pdb/evtchn.mli tools/debugger/pdb/linux-2.6-module/Makefile tools/debugger/pdb/linux-2.6-module/debug.c tools/debugger/pdb/linux-2.6-module/module.c tools/debugger/pdb/linux-2.6-module/pdb_debug.h tools/debugger/pdb/linux-2.6-module/pdb_module.h tools/debugger/pdb/linux-2.6-patches/Makefile tools/debugger/pdb/linux-2.6-patches/i386_ksyms.patch tools/debugger/pdb/linux-2.6-patches/kdebug.patch tools/debugger/pdb/linux-2.6-patches/makefile.patch tools/debugger/pdb/linux-2.6-patches/ptrace.patch tools/debugger/pdb/linux-2.6-patches/traps.patch tools/debugger/pdb/pdb_caml_domain.c tools/debugger/pdb/pdb_caml_evtchn.c tools/debugger/pdb/pdb_caml_process.c tools/debugger/pdb/pdb_caml_xc.c tools/debugger/pdb/pdb_caml_xcs.c tools/debugger/pdb/pdb_caml_xen.h tools/debugger/pdb/pdb_xen.c tools/debugger/pdb/readme tools/debugger/pdb/server.ml tools/debugger/pdb/xcs.ml tools/debugger/pdb/xcs.mli
line diff
     1.1 --- a/tools/debugger/pdb/Domain.ml	Fri Sep 29 11:11:49 2006 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,61 +0,0 @@
     1.4 -(** Domain.ml
     1.5 - *
     1.6 - *  domain context implementation
     1.7 - *
     1.8 - *  @author copyright (c) 2005 alex ho
     1.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    1.10 - *  @version 1
    1.11 - *)
    1.12 -
    1.13 -open Int32
    1.14 -open Intel
    1.15 -
    1.16 -type context_t =
    1.17 -{
    1.18 -  mutable domain : int;
    1.19 -  mutable vcpu : int
    1.20 -}
    1.21 -
    1.22 -let default_context = { domain = 0; vcpu = 0 }
    1.23 -
    1.24 -let new_context new_dom new_vcpu = {domain = new_dom; vcpu = new_vcpu}
    1.25 -
    1.26 -let set_domain ctx value =
    1.27 -  ctx.domain <- value
    1.28 -
    1.29 -let set_vcpu ctx value =
    1.30 -  ctx.vcpu <- value
    1.31 -
    1.32 -let get_domain ctx =
    1.33 -  ctx.domain
    1.34 -
    1.35 -let get_vcpu ctx =
    1.36 -  ctx.vcpu
    1.37 -
    1.38 -let string_of_context ctx =
    1.39 -      Printf.sprintf "{domain} domain: %d, vcpu: %d"
    1.40 -                      ctx.domain  ctx.vcpu
    1.41 -
    1.42 -external read_register : context_t -> int -> int32 = "dom_read_register"
    1.43 -external read_registers : context_t -> registers = "dom_read_registers"
    1.44 -external write_register : context_t -> register -> int32 -> unit =
    1.45 -  "dom_write_register"
    1.46 -external read_memory : context_t -> int32 -> int -> int list = 
    1.47 -  "dom_read_memory"
    1.48 -external write_memory : context_t -> int32 -> int list -> unit = 
    1.49 -  "dom_write_memory"
    1.50 -	
    1.51 -external continue : context_t -> unit = "dom_continue_target"
    1.52 -external step : context_t -> unit = "dom_step_target"
    1.53 -
    1.54 -external insert_memory_breakpoint : context_t -> int32 -> int -> unit = 
    1.55 -  "dom_insert_memory_breakpoint"
    1.56 -external remove_memory_breakpoint : context_t -> int32 -> int -> unit = 
    1.57 -  "dom_remove_memory_breakpoint"
    1.58 -
    1.59 -external attach_debugger : int -> int -> unit = "dom_attach_debugger"
    1.60 -external detach_debugger : int -> int -> unit = "dom_detach_debugger"
    1.61 -external pause_target : int -> unit = "dom_pause_target"
    1.62 -
    1.63 -let pause ctx =
    1.64 -  pause_target ctx.domain
     2.1 --- a/tools/debugger/pdb/Domain.mli	Fri Sep 29 11:11:49 2006 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,39 +0,0 @@
     2.4 -(** Domain.mli
     2.5 - *
     2.6 - *  domain context interface
     2.7 - *
     2.8 - *  @author copyright (c) 2005 alex ho
     2.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    2.10 - *  @version 1
    2.11 - *)
    2.12 -
    2.13 -open Int32
    2.14 -open Intel
    2.15 -
    2.16 -type context_t
    2.17 -
    2.18 -val default_context : context_t
    2.19 -val new_context : int -> int -> context_t 
    2.20 -
    2.21 -val set_domain : context_t -> int -> unit
    2.22 -val get_domain : context_t -> int
    2.23 -val set_vcpu : context_t -> int -> unit
    2.24 -val get_vcpu : context_t -> int
    2.25 -
    2.26 -val string_of_context : context_t -> string
    2.27 -
    2.28 -val read_register : context_t -> int -> int32
    2.29 -val read_registers : context_t -> registers
    2.30 -val write_register : context_t -> register -> int32 -> unit
    2.31 -val read_memory : context_t -> int32 -> int -> int list
    2.32 -val write_memory : context_t -> int32 -> int list -> unit
    2.33 -	
    2.34 -val continue : context_t -> unit
    2.35 -val step : context_t -> unit
    2.36 -
    2.37 -val insert_memory_breakpoint : context_t -> int32 -> int -> unit
    2.38 -val remove_memory_breakpoint : context_t -> int32 -> int -> unit
    2.39 -
    2.40 -val attach_debugger : int -> int -> unit
    2.41 -val detach_debugger : int -> int -> unit
    2.42 -val pause : context_t -> unit
     3.1 --- a/tools/debugger/pdb/Intel.ml	Fri Sep 29 11:11:49 2006 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,66 +0,0 @@
     3.4 -(** Intel.ml
     3.5 - *
     3.6 - *  various sundry Intel x86 definitions
     3.7 - *
     3.8 - *  @author copyright (c) 2005 alex ho
     3.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    3.10 - *  @version 1
    3.11 - *)
    3.12 -
    3.13 -
    3.14 -type register =
    3.15 -  | EAX
    3.16 -  | ECX
    3.17 -  | EDX
    3.18 -  | EBX
    3.19 -  | ESP
    3.20 -  | EBP
    3.21 -  | ESI
    3.22 -  | EDI
    3.23 -  | EIP
    3.24 -  | EFL
    3.25 -  | CS
    3.26 -  | SS
    3.27 -  | DS
    3.28 -  | ES
    3.29 -  | FS
    3.30 -  | GS
    3.31 -
    3.32 -type registers =
    3.33 -    { eax : int32;
    3.34 -      ecx : int32;
    3.35 -      edx : int32;
    3.36 -      ebx : int32;
    3.37 -      esp : int32;
    3.38 -      ebp : int32;
    3.39 -      esi : int32;
    3.40 -      edi : int32;
    3.41 -      eip : int32;
    3.42 -      efl : int32;
    3.43 -      cs  : int32;
    3.44 -      ss  : int32;
    3.45 -      ds  : int32;
    3.46 -      es  : int32;
    3.47 -      fs  : int32;
    3.48 -      gs  : int32
    3.49 -    }
    3.50 -
    3.51 -let null_registers =
    3.52 -    { eax = 0l;
    3.53 -      ecx = 0l;
    3.54 -      edx = 0l;
    3.55 -      ebx = 0l;
    3.56 -      esp = 0l;
    3.57 -      ebp = 0l;
    3.58 -      esi = 0l;
    3.59 -      edi = 0l;
    3.60 -      eip = 0l;
    3.61 -      efl = 0l;
    3.62 -      cs  = 0l;
    3.63 -      ss  = 0l;
    3.64 -      ds  = 0l;
    3.65 -      es  = 0l;
    3.66 -      fs  = 0l;
    3.67 -      gs  = 0l
    3.68 -    }
    3.69 -
     4.1 --- a/tools/debugger/pdb/Makefile	Fri Sep 29 11:11:49 2006 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,57 +0,0 @@
     4.4 -OCAMLMAKEFILE = OCamlMakefile
     4.5 -
     4.6 -XEN_ROOT    = ../../..
     4.7 -include $(XEN_ROOT)/tools/Rules.mk
     4.8 -
     4.9 -# overwrite LDFLAGS from xen/tool/Rules.mk
    4.10 -# otherwise, ocamlmktop gets confused.
    4.11 -LDFLAGS     =
    4.12 -
    4.13 -# force ocaml 3.08
    4.14 -OCAML_ROOT  = /usr/local
    4.15 -OCAMLC      = $(OCAML_ROOT)/bin/ocamlc
    4.16 -OCAMLMKTOP  = $(OCAML_ROOT)/bin/ocamlmktop
    4.17 -OCAMLLIBPATH= $(OCAML_ROOT)/lib/ocaml
    4.18 -
    4.19 -INCLUDES   += -I $(XEN_XC)
    4.20 -INCLUDES   += -I $(XEN_LIBXC)
    4.21 -INCLUDES   += -I ../libxendebug
    4.22 -INCLUDES   += -I ./linux-2.6-module
    4.23 -INCLUDES   += -I $(OCAML_ROOT)/lib/ocaml
    4.24 -
    4.25 -CFLAGS     += $(INCLUDES)
    4.26 -CFLAGS     += -Werror
    4.27 -CFLAGS     += -g
    4.28 -
    4.29 -CLIBS      += xc
    4.30 -CLIBS      += xendebug
    4.31 -
    4.32 -LIBDIRS    += $(XEN_LIBXC)
    4.33 -LIBDIRS    += ../libxendebug
    4.34 -
    4.35 -LIBS       += unix str
    4.36 -
    4.37 -# bc = byte-code, dc = debug byte-code
    4.38 -# patches = patch linux domU source code
    4.39 -.PHONY: all 
    4.40 -all : dc
    4.41 -
    4.42 -SOURCES    += pdb_caml_xc.c 
    4.43 -SOURCES    += pdb_caml_domain.c pdb_caml_process.c
    4.44 -SOURCES    += pdb_caml_evtchn.c pdb_caml_xcs.c pdb_xen.c
    4.45 -SOURCES    += Util.ml Intel.ml 
    4.46 -SOURCES    += evtchn.ml evtchn.mli
    4.47 -SOURCES    += xcs.ml xcs.mli
    4.48 -SOURCES    += Xen_domain.ml Xen_domain.mli
    4.49 -SOURCES    += Domain.ml  Process.ml
    4.50 -SOURCES    += Domain.mli Process.mli
    4.51 -SOURCES    += PDB.ml debugger.ml server.ml
    4.52 -
    4.53 -RESULT      = pdb
    4.54 -
    4.55 -include $(OCAMLMAKEFILE)
    4.56 -
    4.57 -PATCHDIR    = ./linux-2.6-patches
    4.58 -.PHONY: patches 
    4.59 -patches :
    4.60 -	make -C $(PATCHDIR) patches
     5.1 --- a/tools/debugger/pdb/OCamlMakefile	Fri Sep 29 11:11:49 2006 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,1149 +0,0 @@
     5.4 -###########################################################################
     5.5 -#                              OCamlMakefile
     5.6 -#                  Copyright (C) 1999-2004  Markus Mottl
     5.7 -#
     5.8 -#                             For updates see:
     5.9 -#                http://www.oefai.at/~markus/ocaml_sources
    5.10 -#
    5.11 -#        $Id: OCamlMakefile,v 1.1 2005/05/19 09:30:48 root Exp $
    5.12 -#
    5.13 -###########################################################################
    5.14 -
    5.15 -# Modified by damien for .glade.ml compilation
    5.16 -
    5.17 -# Set these variables to the names of the sources to be processed and
    5.18 -# the result variable. Order matters during linkage!
    5.19 -
    5.20 -ifndef SOURCES
    5.21 -  SOURCES := foo.ml
    5.22 -endif
    5.23 -export SOURCES
    5.24 -
    5.25 -ifndef RES_CLIB_SUF
    5.26 -  RES_CLIB_SUF := _stubs
    5.27 -endif
    5.28 -export RES_CLIB_SUF
    5.29 -
    5.30 -ifndef RESULT
    5.31 -  RESULT := foo
    5.32 -endif
    5.33 -export RESULT
    5.34 -
    5.35 -export LIB_PACK_NAME
    5.36 -
    5.37 -ifndef DOC_FILES
    5.38 -  DOC_FILES := $(filter %.mli, $(SOURCES))
    5.39 -endif
    5.40 -export DOC_FILES
    5.41 -
    5.42 -export BCSUFFIX
    5.43 -export NCSUFFIX
    5.44 -
    5.45 -ifndef TOPSUFFIX
    5.46 -  TOPSUFFIX := .top
    5.47 -endif
    5.48 -export TOPSUFFIX
    5.49 -
    5.50 -# Eventually set include- and library-paths, libraries to link,
    5.51 -# additional compilation-, link- and ocamlyacc-flags
    5.52 -# Path- and library information needs not be written with "-I" and such...
    5.53 -# Define THREADS if you need it, otherwise leave it unset (same for
    5.54 -# USE_CAMLP4)!
    5.55 -
    5.56 -export THREADS
    5.57 -export VMTHREADS
    5.58 -export ANNOTATE
    5.59 -export USE_CAMLP4
    5.60 -
    5.61 -export INCDIRS
    5.62 -export LIBDIRS
    5.63 -export EXTLIBDIRS
    5.64 -export RESULTDEPS
    5.65 -export OCAML_DEFAULT_DIRS
    5.66 -
    5.67 -export LIBS
    5.68 -export CLIBS
    5.69 -
    5.70 -export OCAMLFLAGS
    5.71 -export OCAMLNCFLAGS
    5.72 -export OCAMLBCFLAGS
    5.73 -
    5.74 -export OCAMLLDFLAGS
    5.75 -export OCAMLNLDFLAGS
    5.76 -export OCAMLBLDFLAGS
    5.77 -
    5.78 -ifndef OCAMLCPFLAGS
    5.79 -  OCAMLCPFLAGS := a
    5.80 -endif
    5.81 -
    5.82 -export OCAMLCPFLAGS
    5.83 -
    5.84 -export PPFLAGS
    5.85 -
    5.86 -export YFLAGS
    5.87 -export IDLFLAGS
    5.88 -
    5.89 -export OCAMLDOCFLAGS
    5.90 -
    5.91 -export OCAMLFIND_INSTFLAGS
    5.92 -
    5.93 -export DVIPSFLAGS
    5.94 -
    5.95 -export STATIC
    5.96 -
    5.97 -# Add a list of optional trash files that should be deleted by "make clean"
    5.98 -export TRASH
    5.99 -
   5.100 -####################  variables depending on your OCaml-installation
   5.101 -
   5.102 -ifdef MINGW
   5.103 -  export MINGW
   5.104 -  WIN32   := 1
   5.105 -  CFLAGS_WIN32 := -mno-cygwin
   5.106 -endif
   5.107 -ifdef MSVC
   5.108 -  export MSVC
   5.109 -  WIN32   := 1
   5.110 -  ifndef STATIC
   5.111 -    CPPFLAGS_WIN32 := -DCAML_DLL
   5.112 -  endif
   5.113 -  CFLAGS_WIN32 += -nologo
   5.114 -  EXT_OBJ := obj
   5.115 -  EXT_LIB := lib
   5.116 -  ifeq ($(CC),gcc)
   5.117 -    # work around GNU Make default value
   5.118 -    ifdef THREADS
   5.119 -      CC := cl -MT
   5.120 -    else
   5.121 -      CC := cl
   5.122 -    endif
   5.123 -  endif
   5.124 -  ifeq ($(CXX),g++)
   5.125 -    # work around GNU Make default value
   5.126 -    CXX := $(CC)
   5.127 -  endif
   5.128 -  CFLAG_O := -Fo
   5.129 -endif
   5.130 -ifdef WIN32
   5.131 -  EXT_CXX := cpp
   5.132 -  EXE     := .exe
   5.133 -endif
   5.134 -
   5.135 -ifndef EXT_OBJ
   5.136 -  EXT_OBJ := o
   5.137 -endif
   5.138 -ifndef EXT_LIB
   5.139 -  EXT_LIB := a
   5.140 -endif
   5.141 -ifndef EXT_CXX
   5.142 -  EXT_CXX := cc
   5.143 -endif
   5.144 -ifndef EXE
   5.145 -  EXE := # empty
   5.146 -endif
   5.147 -ifndef CFLAG_O
   5.148 -  CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)!
   5.149 -endif
   5.150 -
   5.151 -export CC
   5.152 -export CXX
   5.153 -export CFLAGS
   5.154 -export CXXFLAGS
   5.155 -export LDFLAGS
   5.156 -export CPPFLAGS
   5.157 -
   5.158 -ifndef RPATH_FLAG
   5.159 -  RPATH_FLAG := -R
   5.160 -endif
   5.161 -export RPATH_FLAG
   5.162 -
   5.163 -ifndef MSVC
   5.164 -ifndef PIC_CFLAGS
   5.165 -  PIC_CFLAGS := -fPIC
   5.166 -endif
   5.167 -ifndef PIC_CPPFLAGS
   5.168 -  PIC_CPPFLAGS := -DPIC
   5.169 -endif
   5.170 -endif
   5.171 -
   5.172 -export PIC_CFLAGS
   5.173 -export PIC_CPPFLAGS
   5.174 -
   5.175 -BCRESULT  := $(addsuffix $(BCSUFFIX), $(RESULT))
   5.176 -NCRESULT  := $(addsuffix $(NCSUFFIX), $(RESULT))
   5.177 -TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT))
   5.178 -
   5.179 -ifndef OCAMLFIND
   5.180 -  OCAMLFIND := ocamlfind
   5.181 -endif
   5.182 -export OCAMLFIND
   5.183 -
   5.184 -ifndef OCAMLC
   5.185 -  OCAMLC := ocamlc
   5.186 -endif
   5.187 -export OCAMLC
   5.188 -
   5.189 -ifndef OCAMLOPT
   5.190 -  OCAMLOPT := ocamlopt
   5.191 -endif
   5.192 -export OCAMLOPT
   5.193 -
   5.194 -ifndef OCAMLMKTOP
   5.195 -  OCAMLMKTOP := ocamlmktop
   5.196 -endif
   5.197 -export OCAMLMKTOP
   5.198 -
   5.199 -ifndef OCAMLCP
   5.200 -  OCAMLCP := ocamlcp
   5.201 -endif
   5.202 -export OCAMLCP
   5.203 -
   5.204 -ifndef OCAMLDEP
   5.205 -  OCAMLDEP := ocamldep
   5.206 -endif
   5.207 -export OCAMLDEP
   5.208 -
   5.209 -ifndef OCAMLLEX
   5.210 -  OCAMLLEX := ocamllex
   5.211 -endif
   5.212 -export OCAMLLEX
   5.213 -
   5.214 -ifndef OCAMLYACC
   5.215 -  OCAMLYACC := ocamlyacc
   5.216 -endif
   5.217 -export OCAMLYACC
   5.218 -
   5.219 -ifndef OCAMLMKLIB
   5.220 -  OCAMLMKLIB := ocamlmklib
   5.221 -endif
   5.222 -export OCAMLMKLIB
   5.223 -
   5.224 -ifndef OCAML_GLADECC
   5.225 -  OCAML_GLADECC := lablgladecc2
   5.226 -endif
   5.227 -export OCAML_GLADECC
   5.228 -
   5.229 -ifndef OCAML_GLADECC_FLAGS
   5.230 -  OCAML_GLADECC_FLAGS :=
   5.231 -endif
   5.232 -export OCAML_GLADECC_FLAGS
   5.233 -
   5.234 -ifndef CAMELEON_REPORT
   5.235 -  CAMELEON_REPORT := report
   5.236 -endif
   5.237 -export CAMELEON_REPORT
   5.238 -
   5.239 -ifndef CAMELEON_REPORT_FLAGS
   5.240 -  CAMELEON_REPORT_FLAGS :=
   5.241 -endif
   5.242 -export CAMELEON_REPORT_FLAGS
   5.243 -
   5.244 -ifndef CAMELEON_ZOGGY
   5.245 -  CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo
   5.246 -endif
   5.247 -export CAMELEON_ZOGGY
   5.248 -
   5.249 -ifndef CAMELEON_ZOGGY_FLAGS
   5.250 -  CAMELEON_ZOGGY_FLAGS :=
   5.251 -endif
   5.252 -export CAMELEON_ZOGGY_FLAGS
   5.253 -
   5.254 -ifndef OXRIDL
   5.255 -  OXRIDL := oxridl
   5.256 -endif
   5.257 -export OXRIDL
   5.258 -
   5.259 -ifndef CAMLIDL
   5.260 -  CAMLIDL := camlidl
   5.261 -endif
   5.262 -export CAMLIDL
   5.263 -
   5.264 -ifndef CAMLIDLDLL
   5.265 -  CAMLIDLDLL := camlidldll
   5.266 -endif
   5.267 -export CAMLIDLDLL
   5.268 -
   5.269 -ifndef NOIDLHEADER
   5.270 -  MAYBE_IDL_HEADER := -header
   5.271 -endif
   5.272 -export NOIDLHEADER
   5.273 -
   5.274 -export NO_CUSTOM
   5.275 -
   5.276 -ifndef CAMLP4
   5.277 -  CAMLP4 := camlp4
   5.278 -endif
   5.279 -export CAMLP4
   5.280 -
   5.281 -ifndef REAL_OCAMLFIND
   5.282 -  ifdef PACKS
   5.283 -    ifndef CREATE_LIB
   5.284 -      ifdef THREADS
   5.285 -	PACKS += threads
   5.286 -      endif
   5.287 -    endif
   5.288 -    empty :=
   5.289 -    space := $(empty) $(empty)
   5.290 -    comma := ,
   5.291 -    ifdef PREDS
   5.292 -      PRE_OCAML_FIND_PREDICATES := $(subst $(space),$(comma),$(PREDS))
   5.293 -      PRE_OCAML_FIND_PACKAGES := $(subst $(space),$(comma),$(PACKS))
   5.294 -      OCAML_FIND_PREDICATES := -predicates $(PRE_OCAML_FIND_PREDICATES)
   5.295 -  #    OCAML_DEP_PREDICATES := -syntax $(PRE_OCAML_FIND_PREDICATES)
   5.296 -      OCAML_FIND_PACKAGES := $(OCAML_FIND_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
   5.297 -      OCAML_DEP_PACKAGES := $(OCAML_DEP_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
   5.298 -    else
   5.299 -      OCAML_FIND_PACKAGES := -package $(subst $(space),$(comma),$(PACKS))
   5.300 -      OCAML_DEP_PACKAGES :=
   5.301 -    endif
   5.302 -    OCAML_FIND_LINKPKG := -linkpkg
   5.303 -    REAL_OCAMLFIND := $(OCAMLFIND)
   5.304 -  endif
   5.305 -endif
   5.306 -
   5.307 -export OCAML_FIND_PACKAGES
   5.308 -export OCAML_DEP_PACKAGES
   5.309 -export OCAML_FIND_LINKPKG
   5.310 -export REAL_OCAMLFIND
   5.311 -
   5.312 -ifndef OCAMLDOC
   5.313 -  OCAMLDOC := ocamldoc
   5.314 -endif
   5.315 -export OCAMLDOC
   5.316 -
   5.317 -ifndef LATEX
   5.318 -  LATEX := latex
   5.319 -endif
   5.320 -export LATEX
   5.321 -
   5.322 -ifndef DVIPS
   5.323 -  DVIPS := dvips
   5.324 -endif
   5.325 -export DVIPS
   5.326 -
   5.327 -ifndef PS2PDF
   5.328 -  PS2PDF := ps2pdf
   5.329 -endif
   5.330 -export PS2PDF
   5.331 -
   5.332 -ifndef OCAMLMAKEFILE
   5.333 -  OCAMLMAKEFILE := OCamlMakefile
   5.334 -endif
   5.335 -export OCAMLMAKEFILE
   5.336 -
   5.337 -ifndef OCAMLLIBPATH
   5.338 -  OCAMLLIBPATH := \
   5.339 -    $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml)
   5.340 -endif
   5.341 -export OCAMLLIBPATH
   5.342 -
   5.343 -ifndef OCAML_LIB_INSTALL
   5.344 -  OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib
   5.345 -endif
   5.346 -export OCAML_LIB_INSTALL
   5.347 -
   5.348 -###########################################################################
   5.349 -
   5.350 -####################  change following sections only if
   5.351 -####################    you know what you are doing!
   5.352 -
   5.353 -# delete target files when a build command fails
   5.354 -.PHONY: .DELETE_ON_ERROR
   5.355 -.DELETE_ON_ERROR:
   5.356 -
   5.357 -# for pedants using "--warn-undefined-variables"
   5.358 -export MAYBE_IDL
   5.359 -export REAL_RESULT
   5.360 -export CAMLIDLFLAGS
   5.361 -export THREAD_FLAG
   5.362 -export RES_CLIB
   5.363 -export MAKEDLL
   5.364 -export ANNOT_FLAG
   5.365 -export C_OXRIDL
   5.366 -export SUBPROJS
   5.367 -export CFLAGS_WIN32
   5.368 -export CPPFLAGS_WIN32
   5.369 -
   5.370 -INCFLAGS :=
   5.371 -
   5.372 -SHELL := /bin/sh
   5.373 -
   5.374 -MLDEPDIR := ._d
   5.375 -BCDIDIR  := ._bcdi
   5.376 -NCDIDIR  := ._ncdi
   5.377 -
   5.378 -FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.$(EXT_CXX) %.rep %.zog %.glade
   5.379 -
   5.380 -FILTERED     := $(filter $(FILTER_EXTNS), $(SOURCES))
   5.381 -SOURCE_DIRS  := $(filter-out ./, $(sort $(dir $(FILTERED))))
   5.382 -
   5.383 -FILTERED_REP := $(filter %.rep, $(FILTERED))
   5.384 -DEP_REP      := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d)
   5.385 -AUTO_REP     := $(FILTERED_REP:.rep=.ml)
   5.386 -
   5.387 -FILTERED_ZOG := $(filter %.zog, $(FILTERED))
   5.388 -DEP_ZOG      := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d)
   5.389 -AUTO_ZOG     := $(FILTERED_ZOG:.zog=.ml)
   5.390 -
   5.391 -FILTERED_GLADE := $(filter %.glade, $(FILTERED))
   5.392 -DEP_GLADE      := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d)
   5.393 -AUTO_GLADE     := $(FILTERED_GLADE:.glade=.ml)
   5.394 -
   5.395 -FILTERED_ML  := $(filter %.ml, $(FILTERED))
   5.396 -DEP_ML       := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d)
   5.397 -
   5.398 -FILTERED_MLI := $(filter %.mli, $(FILTERED))
   5.399 -DEP_MLI      := $(FILTERED_MLI:.mli=.di)
   5.400 -
   5.401 -FILTERED_MLL := $(filter %.mll, $(FILTERED))
   5.402 -DEP_MLL      := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d)
   5.403 -AUTO_MLL     := $(FILTERED_MLL:.mll=.ml)
   5.404 -
   5.405 -FILTERED_MLY := $(filter %.mly, $(FILTERED))
   5.406 -DEP_MLY      := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di)
   5.407 -AUTO_MLY     := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml)
   5.408 -
   5.409 -FILTERED_IDL := $(filter %.idl, $(FILTERED))
   5.410 -DEP_IDL      := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di)
   5.411 -C_IDL        := $(FILTERED_IDL:%.idl=%_stubs.c)
   5.412 -ifndef NOIDLHEADER
   5.413 - C_IDL += $(FILTERED_IDL:.idl=.h)
   5.414 -endif
   5.415 -OBJ_C_IDL    := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ))
   5.416 -AUTO_IDL     := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL)
   5.417 -
   5.418 -FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED))
   5.419 -DEP_OXRIDL      := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di)
   5.420 -AUTO_OXRIDL     := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL)
   5.421 -
   5.422 -FILTERED_C_CXX := $(filter %.c %.$(EXT_CXX), $(FILTERED))
   5.423 -OBJ_C_CXX      := $(FILTERED_C_CXX:.c=.$(EXT_OBJ))
   5.424 -OBJ_C_CXX      := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ))
   5.425 -
   5.426 -PRE_TARGETS  += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE)
   5.427 -
   5.428 -ALL_DEPS     := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE)
   5.429 -
   5.430 -MLDEPS       := $(filter %.d, $(ALL_DEPS))
   5.431 -MLIDEPS      := $(filter %.di, $(ALL_DEPS))
   5.432 -BCDEPIS      := $(MLIDEPS:%.di=$(BCDIDIR)/%.di)
   5.433 -NCDEPIS      := $(MLIDEPS:%.di=$(NCDIDIR)/%.di)
   5.434 -
   5.435 -ALLML        := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED))
   5.436 -
   5.437 -IMPLO_INTF   := $(ALLML:%.mli=%.mli.__)
   5.438 -IMPLO_INTF   := $(foreach file, $(IMPLO_INTF), \
   5.439 -                  $(basename $(file)).cmi $(basename $(file)).cmo)
   5.440 -IMPLO_INTF   := $(filter-out %.mli.cmo, $(IMPLO_INTF))
   5.441 -IMPLO_INTF   := $(IMPLO_INTF:%.mli.cmi=%.cmi)
   5.442 -
   5.443 -IMPLX_INTF   := $(IMPLO_INTF:.cmo=.cmx)
   5.444 -
   5.445 -INTF         := $(filter %.cmi, $(IMPLO_INTF))
   5.446 -IMPL_CMO     := $(filter %.cmo, $(IMPLO_INTF))
   5.447 -IMPL_CMX     := $(IMPL_CMO:.cmo=.cmx)
   5.448 -IMPL_ASM     := $(IMPL_CMO:.cmo=.asm)
   5.449 -IMPL_S       := $(IMPL_CMO:.cmo=.s)
   5.450 -
   5.451 -OBJ_LINK     := $(OBJ_C_IDL) $(OBJ_C_CXX)
   5.452 -OBJ_FILES    := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK)
   5.453 -
   5.454 -EXECS        := $(addsuffix $(EXE), \
   5.455 -                            $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT)))
   5.456 -ifdef WIN32
   5.457 -  EXECS      += $(BCRESULT).dll $(NCRESULT).dll
   5.458 -endif
   5.459 -
   5.460 -CLIB_BASE    := $(RESULT)$(RES_CLIB_SUF)
   5.461 -ifneq ($(strip $(OBJ_LINK)),)
   5.462 -  RES_CLIB     := lib$(CLIB_BASE).$(EXT_LIB)
   5.463 -endif
   5.464 -
   5.465 -ifdef WIN32
   5.466 -DLLSONAME := $(CLIB_BASE).dll
   5.467 -else
   5.468 -DLLSONAME := dll$(CLIB_BASE).so
   5.469 -endif
   5.470 -
   5.471 -NONEXECS     := $(INTF) $(IMPL_CMO) $(IMPL_CMX) $(IMPL_ASM) $(IMPL_S) \
   5.472 -		$(OBJ_FILES) $(PRE_TARGETS) $(BCRESULT).cma $(NCRESULT).cmxa \
   5.473 -		$(NCRESULT).$(EXT_LIB) $(BCRESULT).cmi $(BCRESULT).cmo \
   5.474 -		$(NCRESULT).cmi $(NCRESULT).cmx $(NCRESULT).o \
   5.475 -		$(RES_CLIB) $(IMPL_CMO:.cmo=.annot) \
   5.476 -		$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(LIB_PACK_NAME).cmx $(LIB_PACK_NAME).o
   5.477 -
   5.478 -ifndef STATIC
   5.479 -  NONEXECS += $(DLLSONAME)
   5.480 -endif
   5.481 -
   5.482 -ifndef LIBINSTALL_FILES
   5.483 -  LIBINSTALL_FILES := $(RESULT).mli $(RESULT).cmi $(RESULT).cma \
   5.484 -		      $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB)
   5.485 -  ifndef STATIC
   5.486 -    ifneq ($(strip $(OBJ_LINK)),)
   5.487 -      LIBINSTALL_FILES += $(DLLSONAME)
   5.488 -    endif
   5.489 -  endif
   5.490 -endif
   5.491 -
   5.492 -export LIBINSTALL_FILES
   5.493 -
   5.494 -ifdef WIN32
   5.495 -  # some extra stuff is created while linking DLLs
   5.496 -  NONEXECS   += $(BCRESULT).$(EXT_LIB) $(BCRESULT).exp $(NCRESULT).exp $(CLIB_BASE).exp $(CLIB_BASE).lib
   5.497 -endif
   5.498 -
   5.499 -TARGETS      := $(EXECS) $(NONEXECS)
   5.500 -
   5.501 -# If there are IDL-files
   5.502 -ifneq ($(strip $(FILTERED_IDL)),)
   5.503 -  MAYBE_IDL := -cclib -lcamlidl
   5.504 -endif
   5.505 -
   5.506 -ifdef USE_CAMLP4
   5.507 -  CAMLP4PATH := \
   5.508 -    $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/local/lib/camlp4)
   5.509 -  INCFLAGS := -I $(CAMLP4PATH)
   5.510 -  CINCFLAGS := -I$(CAMLP4PATH)
   5.511 -endif
   5.512 -
   5.513 -DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %)
   5.514 -INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %)
   5.515 -CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%)
   5.516 -
   5.517 -ifndef MSVC
   5.518 -CLIBFLAGS += $(SOURCE_DIRS:%=-L%) $(LIBDIRS:%=-L%) \
   5.519 -             $(EXTLIBDIRS:%=-L%) $(EXTLIBDIRS:%=-Wl,$(RPATH_FLAG)%) \
   5.520 -             $(OCAML_DEFAULT_DIRS:%=-L%)
   5.521 -endif
   5.522 -
   5.523 -ifndef PROFILING
   5.524 -  INTF_OCAMLC := $(OCAMLC)
   5.525 -else
   5.526 -  ifndef THREADS
   5.527 -    INTF_OCAMLC := $(OCAMLCP) -p $(OCAMLCPFLAGS)
   5.528 -  else
   5.529 -    # OCaml does not support profiling byte code
   5.530 -    # with threads (yet), therefore we force an error.
   5.531 -    ifndef REAL_OCAMLC
   5.532 -      $(error Profiling of multithreaded byte code not yet supported by OCaml)
   5.533 -    endif
   5.534 -    INTF_OCAMLC := $(OCAMLC)
   5.535 -  endif
   5.536 -endif
   5.537 -
   5.538 -ifndef MSVC
   5.539 -COMMON_LDFLAGS := $(LDFLAGS:%=-ccopt %) $(SOURCE_DIRS:%=-ccopt -L%) \
   5.540 -		  $(LIBDIRS:%=-ccopt -L%) $(EXTLIBDIRS:%=-ccopt -L%) \
   5.541 -		  $(EXTLIBDIRS:%=-ccopt -Wl,$(RPATH_FLAG)%) \
   5.542 -		  $(OCAML_DEFAULT_DIRS:%=-ccopt -L%)
   5.543 -else
   5.544 -COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \
   5.545 -		  $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \
   5.546 -		  $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) "
   5.547 -endif
   5.548 -
   5.549 -CLIBS_OPTS := $(CLIBS:%=-cclib -l%)
   5.550 -ifdef MSVC
   5.551 -  ifndef STATIC
   5.552 -  # MSVC libraries do not have 'lib' prefix
   5.553 -  CLIBS_OPTS := $(CLIBS:%=-cclib %.lib)
   5.554 -  endif
   5.555 -endif
   5.556 -
   5.557 -ifneq ($(strip $(OBJ_LINK)),)
   5.558 -  ifdef CREATE_LIB
   5.559 -    OBJS_LIBS := -cclib -l$(CLIB_BASE) $(CLIBS_OPTS) $(MAYBE_IDL)
   5.560 -  else
   5.561 -    OBJS_LIBS := $(OBJ_LINK) $(CLIBS_OPTS) $(MAYBE_IDL)
   5.562 -  endif
   5.563 -else
   5.564 -  OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL)
   5.565 -endif
   5.566 -
   5.567 -# If we have to make byte-code
   5.568 -ifndef REAL_OCAMLC
   5.569 -  BYTE_OCAML := y
   5.570 -
   5.571 -  # EXTRADEPS is added dependencies we have to insert for all
   5.572 -  # executable files we generate.  Ideally it should be all of the
   5.573 -  # libraries we use, but it's hard to find the ones that get searched on
   5.574 -  # the path since I don't know the paths built into the compiler, so
   5.575 -  # just include the ones with slashes in their names.
   5.576 -  EXTRADEPS := $(addsuffix .cma,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
   5.577 -  SPECIAL_OCAMLFLAGS := $(OCAMLBCFLAGS)
   5.578 -
   5.579 -  REAL_OCAMLC := $(INTF_OCAMLC)
   5.580 -
   5.581 -  REAL_IMPL := $(IMPL_CMO)
   5.582 -  REAL_IMPL_INTF := $(IMPLO_INTF)
   5.583 -  IMPL_SUF := .cmo
   5.584 -
   5.585 -  DEPFLAGS  :=
   5.586 -  MAKE_DEPS := $(MLDEPS) $(BCDEPIS)
   5.587 -
   5.588 -  ifdef CREATE_LIB
   5.589 -    CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
   5.590 -    CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
   5.591 -    ifndef STATIC
   5.592 -      ifneq ($(strip $(OBJ_LINK)),)
   5.593 -	MAKEDLL := $(DLLSONAME)
   5.594 -	ALL_LDFLAGS := -dllib $(DLLSONAME)
   5.595 -      endif
   5.596 -    endif
   5.597 -  endif
   5.598 -
   5.599 -  ifndef NO_CUSTOM
   5.600 -    ifneq "$(strip $(OBJ_LINK) $(THREADS) $(MAYBE_IDL) $(CLIBS))" ""
   5.601 -      ALL_LDFLAGS += -custom
   5.602 -    endif
   5.603 -  endif
   5.604 -
   5.605 -  ALL_LDFLAGS += $(INCFLAGS) $(OCAMLLDFLAGS) $(OCAMLBLDFLAGS) \
   5.606 -                 $(COMMON_LDFLAGS) $(LIBS:%=%.cma)
   5.607 -  CAMLIDLDLLFLAGS :=
   5.608 -
   5.609 -  ifdef THREADS
   5.610 -    ifdef VMTHREADS
   5.611 -      THREAD_FLAG := -vmthread
   5.612 -    else
   5.613 -      THREAD_FLAG := -thread
   5.614 -    endif
   5.615 -    ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
   5.616 -    ifndef CREATE_LIB
   5.617 -      ifndef REAL_OCAMLFIND
   5.618 -        ALL_LDFLAGS := unix.cma threads.cma $(ALL_LDFLAGS)
   5.619 -      endif
   5.620 -    endif
   5.621 -  endif
   5.622 -
   5.623 -# we have to make native-code
   5.624 -else
   5.625 -  EXTRADEPS := $(addsuffix .cmxa,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
   5.626 -  ifndef PROFILING
   5.627 -    SPECIAL_OCAMLFLAGS := $(OCAMLNCFLAGS)
   5.628 -    PLDFLAGS :=
   5.629 -  else
   5.630 -    SPECIAL_OCAMLFLAGS := -p $(OCAMLNCFLAGS)
   5.631 -    PLDFLAGS := -p
   5.632 -  endif
   5.633 -
   5.634 -  REAL_IMPL := $(IMPL_CMX)
   5.635 -  REAL_IMPL_INTF := $(IMPLX_INTF)
   5.636 -  IMPL_SUF := .cmx
   5.637 -
   5.638 -  CPPFLAGS := -DNATIVE_CODE $(CPPFLAGS)
   5.639 -
   5.640 -  DEPFLAGS  := -native
   5.641 -  MAKE_DEPS := $(MLDEPS) $(NCDEPIS)
   5.642 -
   5.643 -  ALL_LDFLAGS := $(PLDFLAGS) $(INCFLAGS) $(OCAMLLDFLAGS) \
   5.644 -                 $(OCAMLNLDFLAGS) $(COMMON_LDFLAGS)
   5.645 -  CAMLIDLDLLFLAGS := -opt
   5.646 -
   5.647 -  ifndef CREATE_LIB
   5.648 -    ALL_LDFLAGS += $(LIBS:%=%.cmxa)
   5.649 -  else
   5.650 -    CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
   5.651 -    CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
   5.652 -  endif
   5.653 -
   5.654 -  ifdef THREADS
   5.655 -    THREAD_FLAG := -thread
   5.656 -    ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
   5.657 -    ifndef CREATE_LIB
   5.658 -      ifndef REAL_OCAMLFIND
   5.659 -        ALL_LDFLAGS := unix.cmxa threads.cmxa $(ALL_LDFLAGS)
   5.660 -      endif
   5.661 -    endif
   5.662 -  endif
   5.663 -endif
   5.664 -
   5.665 -export MAKE_DEPS
   5.666 -
   5.667 -ifdef ANNOTATE
   5.668 -  ANNOT_FLAG := -dtypes
   5.669 -else
   5.670 -endif
   5.671 -
   5.672 -ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \
   5.673 -                   $(INCFLAGS) $(SPECIAL_OCAMLFLAGS)
   5.674 -
   5.675 -ifdef make_deps
   5.676 -  -include $(MAKE_DEPS)
   5.677 -  PRE_TARGETS :=
   5.678 -endif
   5.679 -
   5.680 -###########################################################################
   5.681 -# USER RULES
   5.682 -
   5.683 -# Call "OCamlMakefile QUIET=" to get rid of all of the @'s.
   5.684 -QUIET=@
   5.685 -
   5.686 -# generates byte-code (default)
   5.687 -byte-code:		$(PRE_TARGETS)
   5.688 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
   5.689 -				REAL_RESULT="$(BCRESULT)" make_deps=yes
   5.690 -bc:	byte-code
   5.691 -
   5.692 -byte-code-nolink:	$(PRE_TARGETS)
   5.693 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
   5.694 -				REAL_RESULT="$(BCRESULT)" make_deps=yes
   5.695 -bcnl:	byte-code-nolink
   5.696 -
   5.697 -top:			$(PRE_TARGETS)
   5.698 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \
   5.699 -				REAL_RESULT="$(BCRESULT)" make_deps=yes
   5.700 -
   5.701 -# generates native-code
   5.702 -
   5.703 -native-code:		$(PRE_TARGETS)
   5.704 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
   5.705 -				REAL_RESULT="$(NCRESULT)" \
   5.706 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.707 -				make_deps=yes
   5.708 -nc:	native-code
   5.709 -
   5.710 -native-code-nolink:	$(PRE_TARGETS)
   5.711 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
   5.712 -				REAL_RESULT="$(NCRESULT)" \
   5.713 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.714 -				make_deps=yes
   5.715 -ncnl:	native-code-nolink
   5.716 -
   5.717 -# generates byte-code libraries
   5.718 -byte-code-library:	$(PRE_TARGETS)
   5.719 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.720 -				$(RES_CLIB) $(BCRESULT).cma \
   5.721 -				REAL_RESULT="$(BCRESULT)" \
   5.722 -				CREATE_LIB=yes \
   5.723 -				make_deps=yes
   5.724 -bcl:	byte-code-library
   5.725 -
   5.726 -# generates native-code libraries
   5.727 -native-code-library:	$(PRE_TARGETS)
   5.728 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.729 -				$(RES_CLIB) $(NCRESULT).cmxa \
   5.730 -				REAL_RESULT="$(NCRESULT)" \
   5.731 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.732 -				CREATE_LIB=yes \
   5.733 -				make_deps=yes
   5.734 -ncl:	native-code-library
   5.735 -
   5.736 -ifdef WIN32
   5.737 -# generates byte-code dll
   5.738 -byte-code-dll:		$(PRE_TARGETS)
   5.739 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.740 -				$(RES_CLIB) $(BCRESULT).dll \
   5.741 -				REAL_RESULT="$(BCRESULT)" \
   5.742 -				make_deps=yes
   5.743 -bcd:	byte-code-dll
   5.744 -
   5.745 -# generates native-code dll
   5.746 -native-code-dll:	$(PRE_TARGETS)
   5.747 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.748 -				$(RES_CLIB) $(NCRESULT).dll \
   5.749 -				REAL_RESULT="$(NCRESULT)" \
   5.750 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.751 -				make_deps=yes
   5.752 -ncd:	native-code-dll
   5.753 -endif
   5.754 -
   5.755 -# generates byte-code with debugging information
   5.756 -debug-code:		$(PRE_TARGETS)
   5.757 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
   5.758 -				REAL_RESULT="$(BCRESULT)" make_deps=yes \
   5.759 -				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
   5.760 -				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
   5.761 -dc:	debug-code
   5.762 -
   5.763 -debug-code-nolink:	$(PRE_TARGETS)
   5.764 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
   5.765 -				REAL_RESULT="$(BCRESULT)" make_deps=yes \
   5.766 -				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
   5.767 -				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
   5.768 -dcnl:	debug-code-nolink
   5.769 -
   5.770 -# generates byte-code libraries with debugging information
   5.771 -debug-code-library:	$(PRE_TARGETS)
   5.772 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.773 -				$(RES_CLIB) $(BCRESULT).cma \
   5.774 -				REAL_RESULT="$(BCRESULT)" make_deps=yes \
   5.775 -				CREATE_LIB=yes \
   5.776 -				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
   5.777 -				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
   5.778 -dcl:	debug-code-library
   5.779 -
   5.780 -# generates byte-code for profiling
   5.781 -profiling-byte-code:		$(PRE_TARGETS)
   5.782 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
   5.783 -				REAL_RESULT="$(BCRESULT)" PROFILING="y" \
   5.784 -				make_deps=yes
   5.785 -pbc:	profiling-byte-code
   5.786 -
   5.787 -# generates native-code
   5.788 -
   5.789 -profiling-native-code:		$(PRE_TARGETS)
   5.790 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
   5.791 -				REAL_RESULT="$(NCRESULT)" \
   5.792 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.793 -				PROFILING="y" \
   5.794 -				make_deps=yes
   5.795 -pnc:	profiling-native-code
   5.796 -
   5.797 -# generates byte-code libraries
   5.798 -profiling-byte-code-library:	$(PRE_TARGETS)
   5.799 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.800 -				$(RES_CLIB) $(BCRESULT).cma \
   5.801 -				REAL_RESULT="$(BCRESULT)" PROFILING="y" \
   5.802 -				CREATE_LIB=yes \
   5.803 -				make_deps=yes
   5.804 -pbcl:	profiling-byte-code-library
   5.805 -
   5.806 -# generates native-code libraries
   5.807 -profiling-native-code-library:	$(PRE_TARGETS)
   5.808 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.809 -				$(RES_CLIB) $(NCRESULT).cmxa \
   5.810 -				REAL_RESULT="$(NCRESULT)" PROFILING="y" \
   5.811 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.812 -				CREATE_LIB=yes \
   5.813 -				make_deps=yes
   5.814 -pncl:	profiling-native-code-library
   5.815 -
   5.816 -# packs byte-code objects
   5.817 -pack-byte-code:			$(PRE_TARGETS)
   5.818 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \
   5.819 -				REAL_RESULT="$(BCRESULT)" \
   5.820 -				PACK_LIB=yes make_deps=yes
   5.821 -pabc:	pack-byte-code
   5.822 -
   5.823 -# packs native-code objects
   5.824 -pack-native-code:		$(PRE_TARGETS)
   5.825 -			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
   5.826 -				$(NCRESULT).cmx $(NCRESULT).o \
   5.827 -				REAL_RESULT="$(NCRESULT)" \
   5.828 -				REAL_OCAMLC="$(OCAMLOPT)" \
   5.829 -				PACK_LIB=yes make_deps=yes
   5.830 -panc:	pack-native-code
   5.831 -
   5.832 -# generates HTML-documentation
   5.833 -htdoc:	doc/$(RESULT)/html
   5.834 -
   5.835 -# generates Latex-documentation
   5.836 -ladoc:	doc/$(RESULT)/latex
   5.837 -
   5.838 -# generates PostScript-documentation
   5.839 -psdoc:	doc/$(RESULT)/latex/doc.ps
   5.840 -
   5.841 -# generates PDF-documentation
   5.842 -pdfdoc:	doc/$(RESULT)/latex/doc.pdf
   5.843 -
   5.844 -# generates all supported forms of documentation
   5.845 -doc: htdoc ladoc psdoc pdfdoc
   5.846 -
   5.847 -###########################################################################
   5.848 -# LOW LEVEL RULES
   5.849 -
   5.850 -$(REAL_RESULT):		$(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS)
   5.851 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) \
   5.852 -				$(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
   5.853 -				$(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
   5.854 -				$(REAL_IMPL)
   5.855 -
   5.856 -nolink:			$(REAL_IMPL_INTF) $(OBJ_LINK)
   5.857 -
   5.858 -ifdef WIN32
   5.859 -$(REAL_RESULT).dll:	$(REAL_IMPL_INTF) $(OBJ_LINK)
   5.860 -			$(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \
   5.861 -				-o $@ $(REAL_IMPL)
   5.862 -endif
   5.863 -
   5.864 -%$(TOPSUFFIX):		$(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
   5.865 -			$(REAL_OCAMLFIND) $(OCAMLMKTOP) \
   5.866 -				$(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
   5.867 -				$(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
   5.868 -				$(REAL_IMPL)
   5.869 -
   5.870 -.SUFFIXES:		.mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \
   5.871 -                        .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .$(EXT_CXX) .h .so \
   5.872 -                        .rep .zog .glade
   5.873 -
   5.874 -ifndef STATIC
   5.875 -ifdef MINGW
   5.876 -$(DLLSONAME):		$(OBJ_LINK)
   5.877 -			$(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
   5.878 -			-Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
   5.879 -			 $(OCAMLLIBPATH)/ocamlrun.a \
   5.880 -			-Wl,--export-all-symbols \
   5.881 -			-Wl,--no-whole-archive
   5.882 -else
   5.883 -ifdef MSVC
   5.884 -$(DLLSONAME):		$(OBJ_LINK)
   5.885 -			link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
   5.886 -			 $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
   5.887 -			 $(OCAMLLIBPATH)/ocamlrun.lib
   5.888 -
   5.889 -else
   5.890 -$(DLLSONAME):		$(OBJ_LINK)
   5.891 -			$(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
   5.892 -				-o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) \
   5.893 -				$(OCAMLMKLIB_FLAGS)
   5.894 -endif
   5.895 -endif
   5.896 -endif
   5.897 -
   5.898 -ifndef LIB_PACK_NAME
   5.899 -$(RESULT).cma:		$(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
   5.900 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
   5.901 -				$(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(REAL_IMPL)
   5.902 -
   5.903 -$(RESULT).cmxa $(RESULT).$(EXT_LIB):	$(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS)
   5.904 -			$(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
   5.905 -				$(OCAMLNLDFLAGS) -o $@ $(REAL_IMPL)
   5.906 -else
   5.907 -ifdef BYTE_OCAML
   5.908 -$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF)
   5.909 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(REAL_IMPL)
   5.910 -else
   5.911 -$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF)
   5.912 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmx $(REAL_IMPL)
   5.913 -endif
   5.914 -
   5.915 -$(RESULT).cma:		$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
   5.916 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
   5.917 -				$(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(LIB_PACK_NAME).cmo
   5.918 -
   5.919 -$(RESULT).cmxa $(RESULT).$(EXT_LIB):	$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS)
   5.920 -			$(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
   5.921 -				$(OCAMLNLDFLAGS) -o $@ $(LIB_PACK_NAME).cmx
   5.922 -endif
   5.923 -
   5.924 -$(RES_CLIB): 		$(OBJ_LINK)
   5.925 -ifndef MSVC
   5.926 -  ifneq ($(strip $(OBJ_LINK)),)
   5.927 -		      $(AR) rcs $@ $(OBJ_LINK)
   5.928 -  endif
   5.929 -else
   5.930 -  ifneq ($(strip $(OBJ_LINK)),)
   5.931 -			lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK)
   5.932 -  endif
   5.933 -endif
   5.934 -
   5.935 -.mli.cmi: $(EXTRADEPS)
   5.936 -			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
   5.937 -			if [ -z "$$pp" ]; then \
   5.938 -			  echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.939 -				-c $(THREAD_FLAG) $(ANNOT_FLAG) \
   5.940 -				$(OCAMLFLAGS) $(INCFLAGS) $<; \
   5.941 -			  $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.942 -				-c $(THREAD_FLAG) $(ANNOT_FLAG) \
   5.943 -				$(OCAMLFLAGS) $(INCFLAGS) $<; \
   5.944 -			else \
   5.945 -			    echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.946 -				-c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
   5.947 -				$(OCAMLFLAGS) $(INCFLAGS) $<; \
   5.948 -			    $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.949 -				-c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \
   5.950 -				$(OCAMLFLAGS) $(INCFLAGS) $<; \
   5.951 -			fi
   5.952 -
   5.953 -.ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS)
   5.954 -			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
   5.955 -			if [ -z "$$pp" ]; then \
   5.956 -			  echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.957 -				-c $(ALL_OCAMLCFLAGS) $<; \
   5.958 -			  $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.959 -				-c $(ALL_OCAMLCFLAGS) $<; \
   5.960 -			else \
   5.961 -			  echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.962 -				-c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
   5.963 -			  $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
   5.964 -				-c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \
   5.965 -			fi
   5.966 -
   5.967 -ifdef PACK_LIB
   5.968 -$(REAL_RESULT).cmo $(REAL_RESULT).cmx $(REAL_RESULT).o: $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
   5.969 -			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack $(ALL_LDFLAGS) \
   5.970 -				$(OBJS_LIBS) -o $@ $(REAL_IMPL)
   5.971 -endif
   5.972 -
   5.973 -.PRECIOUS:		%.ml
   5.974 -%.ml:			%.mll
   5.975 -			$(OCAMLLEX) $<
   5.976 -
   5.977 -.PRECIOUS:              %.ml %.mli
   5.978 -%.ml %.mli:             %.mly
   5.979 -			$(OCAMLYACC) $(YFLAGS) $<
   5.980 -			$(QUIET)pp=`sed -n -e 's/.*(\*pp \([^*]*\) \*).*/\1/p;q' $<`; \
   5.981 -			if [ ! -z "$$pp" ]; then \
   5.982 -			  mv $*.ml $*.ml.temporary; \
   5.983 -			  echo "(*pp $$pp $(PPFLAGS)*)" > $*.ml; \
   5.984 -			  cat $*.ml.temporary >> $*.ml; \
   5.985 -			  rm $*.ml.temporary; \
   5.986 -			  mv $*.mli $*.mli.temporary; \
   5.987 -			  echo "(*pp $$pp $(PPFLAGS)*)" > $*.mli; \
   5.988 -			  cat $*.mli.temporary >> $*.mli; \
   5.989 -			  rm $*.mli.temporary; \
   5.990 -			fi
   5.991 -
   5.992 -
   5.993 -.PRECIOUS:		%.ml
   5.994 -%.ml:			%.rep
   5.995 -			$(CAMELEON_REPORT) $(CAMELEON_REPORT_FLAGS) -gen $<
   5.996 -
   5.997 -.PRECIOUS:		%.ml
   5.998 -%.ml:			%.zog
   5.999 -			$(CAMELEON_ZOGGY)  $(CAMELEON_ZOGGY_FLAGS) -impl $< > $@
  5.1000 -
  5.1001 -.PRECIOUS:		%.ml
  5.1002 -%.ml:			%.glade
  5.1003 -			$(OCAML_GLADECC)  $(OCAML_GLADECC_FLAGS) $< > $@
  5.1004 -
  5.1005 -.PRECIOUS:		%.ml %.mli
  5.1006 -%.ml %.mli:		%.oxridl
  5.1007 -			$(OXRIDL) $<
  5.1008 -
  5.1009 -.PRECIOUS:		%.ml %.mli %_stubs.c %.h
  5.1010 -%.ml %.mli %_stubs.c %.h:		%.idl
  5.1011 -			$(CAMLIDL) $(MAYBE_IDL_HEADER) $(IDLFLAGS) \
  5.1012 -				$(CAMLIDLFLAGS) $<
  5.1013 -			$(QUIET)if [ $(NOIDLHEADER) ]; then touch $*.h; fi
  5.1014 -
  5.1015 -.c.$(EXT_OBJ):
  5.1016 -			$(OCAMLC) -c -cc "$(CC)" -ccopt "$(CFLAGS) \
  5.1017 -				$(CPPFLAGS) $(CPPFLAGS_WIN32) \
  5.1018 -				$(CFLAGS_WIN32) $(CINCFLAGS) $(CFLAG_O)$@ " $< 
  5.1019 -
  5.1020 -.$(EXT_CXX).$(EXT_OBJ):
  5.1021 -			$(CXX) -c $(CXXFLAGS) $(CINCFLAGS) $(CPPFLAGS) \
  5.1022 -				-I'$(OCAMLLIBPATH)' \
  5.1023 -				$< $(CFLAG_O)$@
  5.1024 -
  5.1025 -$(MLDEPDIR)/%.d:	%.ml
  5.1026 -			$(QUIET)echo making $@ from $<
  5.1027 -			$(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
  5.1028 -			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  5.1029 -			if [ -z "$$pp" ]; then \
  5.1030 -			  $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
  5.1031 -				$(DINCFLAGS) $< > $@; \
  5.1032 -			else \
  5.1033 -			  $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
  5.1034 -				-pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
  5.1035 -			fi
  5.1036 -
  5.1037 -$(BCDIDIR)/%.di $(NCDIDIR)/%.di:	%.mli
  5.1038 -			$(QUIET)echo making $@ from $<
  5.1039 -			$(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
  5.1040 -			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  5.1041 -			if [ -z "$$pp" ]; then \
  5.1042 -			  $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< > $@; \
  5.1043 -			else \
  5.1044 -			  $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
  5.1045 -			    -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
  5.1046 -			fi
  5.1047 -
  5.1048 -doc/$(RESULT)/html: $(DOC_FILES)
  5.1049 -	rm -rf $@
  5.1050 -	mkdir -p $@
  5.1051 -	$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  5.1052 -	if [ -z "$$pp" ]; then \
  5.1053 -	  echo $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
  5.1054 -	  $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
  5.1055 -	else \
  5.1056 -	  echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -html -d $@ $(OCAMLDOCFLAGS) \
  5.1057 -	  	$(INCFLAGS) $(DOC_FILES); \
  5.1058 -	  $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -html -d $@ $(OCAMLDOCFLAGS) \
  5.1059 -	  	$(INCFLAGS) $(DOC_FILES); \
  5.1060 -	fi
  5.1061 -
  5.1062 -doc/$(RESULT)/latex: $(DOC_FILES)
  5.1063 -	rm -rf $@
  5.1064 -	mkdir -p $@
  5.1065 -	$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  5.1066 -	if [ -z "$$pp" ]; then \
  5.1067 -	  echo $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) \
  5.1068 -	  	$(DOC_FILES) -o $@/doc.tex; \
  5.1069 -	  $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES) \
  5.1070 -	  	-o $@/doc.tex; \
  5.1071 -	else \
  5.1072 -	  echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -latex $(OCAMLDOCFLAGS) \
  5.1073 -	  	$(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
  5.1074 -	  $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -latex $(OCAMLDOCFLAGS) \
  5.1075 -	  	$(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
  5.1076 -	fi
  5.1077 -
  5.1078 -doc/$(RESULT)/latex/doc.ps: doc/$(RESULT)/latex
  5.1079 -	cd doc/$(RESULT)/latex && \
  5.1080 -	  $(LATEX) doc.tex && \
  5.1081 -	  $(LATEX) doc.tex && \
  5.1082 -	  $(DVIPS) $(DVIPSFLAGS) doc.dvi -o $(@F)
  5.1083 -
  5.1084 -doc/$(RESULT)/latex/doc.pdf: doc/$(RESULT)/latex/doc.ps
  5.1085 -	cd doc/$(RESULT)/latex && $(PS2PDF) $(<F)
  5.1086 -
  5.1087 -define make_subproj
  5.1088 -.PHONY:
  5.1089 -subproj_$(1):
  5.1090 -	$$(eval $$(call PROJ_$(1)))
  5.1091 -	$(QUIET)if [ "$(SUBTARGET)" != "all" ]; then \
  5.1092 -	  $(MAKE) -f $(OCAMLMAKEFILE) $(SUBTARGET); \
  5.1093 -	fi
  5.1094 -endef
  5.1095 -
  5.1096 -$(foreach subproj,$(SUBPROJS),$(eval $(call make_subproj,$(subproj))))
  5.1097 -
  5.1098 -.PHONY:
  5.1099 -subprojs: $(SUBPROJS:%=subproj_%)
  5.1100 -
  5.1101 -###########################################################################
  5.1102 -# (UN)INSTALL RULES FOR LIBRARIES
  5.1103 -
  5.1104 -.PHONY: libinstall
  5.1105 -libinstall:	all
  5.1106 -	$(QUIET)printf "\nInstalling library with ocamlfind\n"
  5.1107 -	$(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META $(LIBINSTALL_FILES)
  5.1108 -	$(QUIET)printf "\nInstallation successful.\n"
  5.1109 -
  5.1110 -.PHONY: libuninstall
  5.1111 -libuninstall:
  5.1112 -	$(QUIET)printf "\nUninstalling library with ocamlfind\n"
  5.1113 -	$(OCAMLFIND) remove $(OCAMLFIND_INSTFLAGS) $(RESULT)
  5.1114 -	$(QUIET)printf "\nUninstallation successful.\n"
  5.1115 -
  5.1116 -.PHONY: rawinstall
  5.1117 -rawinstall:	all
  5.1118 -	$(QUIET)printf "\nInstalling library to: $(OCAML_LIB_INSTALL)\n"
  5.1119 -	-install -d $(OCAML_LIB_INSTALL)
  5.1120 -	for i in $(LIBINSTALL_FILES); do \
  5.1121 -	  if [ -f $$i ]; then \
  5.1122 -	    install -c -m 0644 $$i $(OCAML_LIB_INSTALL); \
  5.1123 -	  fi; \
  5.1124 -	done
  5.1125 -	$(QUIET)printf "\nInstallation successful.\n"
  5.1126 -
  5.1127 -.PHONY: rawuninstall
  5.1128 -rawuninstall:
  5.1129 -	$(QUIET)printf "\nUninstalling library from: $(OCAML_LIB_INSTALL)\n"
  5.1130 -	cd $(OCAML_LIB_INSTALL) && rm $(notdir $(LIBINSTALL_FILES))
  5.1131 -	$(QUIET)printf "\nUninstallation successful.\n"
  5.1132 -
  5.1133 -###########################################################################
  5.1134 -# MAINTAINANCE RULES
  5.1135 -
  5.1136 -.PHONY:	clean
  5.1137 -clean::
  5.1138 -	rm -f $(TARGETS) $(TRASH)
  5.1139 -	rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
  5.1140 -
  5.1141 -.PHONY:	cleanup
  5.1142 -cleanup::
  5.1143 -	rm -f $(NONEXECS) $(TRASH)
  5.1144 -	rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
  5.1145 -
  5.1146 -.PHONY: clean-doc
  5.1147 -clean-doc::
  5.1148 -	rm -rf doc
  5.1149 -
  5.1150 -.PHONY: nobackup
  5.1151 -nobackup:
  5.1152 -	rm -f *.bak *~ *.dup
     6.1 --- a/tools/debugger/pdb/PDB.ml	Fri Sep 29 11:11:49 2006 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,342 +0,0 @@
     6.4 -(** PDB.ml
     6.5 - *
     6.6 - *  Dispatch debugger commands to the appropriate context
     6.7 - *
     6.8 - *  @author copyright (c) 2005 alex ho
     6.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    6.10 - *  @version 1
    6.11 - *)
    6.12 -
    6.13 -open Util
    6.14 -
    6.15 -exception Unimplemented of string
    6.16 -exception Unknown_context of string
    6.17 -exception Unknown_domain
    6.18 -exception Unknown_process
    6.19 -
    6.20 -type context_t =
    6.21 -  | Void
    6.22 -  | Xen_virq
    6.23 -  | Xen_xcs
    6.24 -  | Xen_domain of Xen_domain.context_t
    6.25 -  | Domain of Domain.context_t
    6.26 -  | Process of Process.context_t
    6.27 -
    6.28 -let string_of_context ctx =
    6.29 -  match ctx with
    6.30 -  | Void -> "{void}"
    6.31 -  | Xen_virq  -> "{Xen virq evtchn}"
    6.32 -  | Xen_xcs   -> "{Xen xcs socket}"
    6.33 -  | Xen_domain d -> Xen_domain.string_of_context d
    6.34 -  | Domain d  -> Domain.string_of_context d
    6.35 -  | Process p -> Process.string_of_context p
    6.36 -
    6.37 -
    6.38 -let hash = Hashtbl.create 10
    6.39 -
    6.40 -
    6.41 -(***************************************************************************)
    6.42 -
    6.43 -let find_context key =
    6.44 -  try
    6.45 -    Hashtbl.find hash key
    6.46 -  with
    6.47 -    Not_found ->
    6.48 -      print_endline "error: (find_context) PDB context not found";
    6.49 -      raise Not_found
    6.50 -
    6.51 -let delete_context key =
    6.52 -  Hashtbl.remove hash key
    6.53 -
    6.54 -
    6.55 -(**
    6.56 -   find_process : Locate the socket associated with the context(s)
    6.57 -   matching a particular (domain, process id) pair.  if there are multiple
    6.58 -   contexts (there shouldn't be), then return the first one.
    6.59 - *)
    6.60 -
    6.61 -let find_process dom pid =
    6.62 -    let find key ctx list =
    6.63 -      match ctx with
    6.64 -      |	Process p ->
    6.65 -	  if (((Process.get_domain p) = dom) &&
    6.66 -	      ((Process.get_process p) = pid))
    6.67 -	  then
    6.68 -	    key :: list
    6.69 -	  else
    6.70 -	    list
    6.71 -      | _ -> list
    6.72 -    in
    6.73 -    let sock_list = Hashtbl.fold find hash [] in
    6.74 -    match sock_list with
    6.75 -    | hd::tl -> hd
    6.76 -    | [] -> raise Unknown_process
    6.77 -
    6.78 -
    6.79 -(**
    6.80 -   find_domain : Locate the socket associated with the context(s)
    6.81 -   matching a particular (domain, vcpu) pair.  if there are multiple
    6.82 -   contexts (there shouldn't be), then return the first one.
    6.83 - *)
    6.84 -
    6.85 -let find_domain dom vcpu =
    6.86 -    let find key ctx list =
    6.87 -      match ctx with
    6.88 -      |	Domain d ->
    6.89 -	  if (((Domain.get_domain d) = dom) &&
    6.90 -	      ((Domain.get_vcpu d) = vcpu))
    6.91 -	  then
    6.92 -	    key :: list
    6.93 -	  else
    6.94 -	    list
    6.95 -      | _ -> list
    6.96 -    in
    6.97 -    let sock_list = Hashtbl.fold find hash [] in
    6.98 -    match sock_list with
    6.99 -    | hd::tl -> hd
   6.100 -    | [] -> raise Unknown_domain
   6.101 -
   6.102 -(**
   6.103 -   find_xen_domain_context : fetch the socket associated with the
   6.104 -   xen_domain context for a domain.  if there are multiple contexts
   6.105 -   (there shouldn't be), then return the first one.
   6.106 - *)
   6.107 -
   6.108 -let find_xen_domain_context domain =
   6.109 -  let find key ctx list =
   6.110 -    match ctx with
   6.111 -      | Xen_domain d ->
   6.112 -	  if ((Xen_domain.get_domain d) = domain)
   6.113 -	  then
   6.114 -	    key :: list
   6.115 -	  else
   6.116 -	    list
   6.117 -      | _ -> list
   6.118 -  in
   6.119 -  let sock_list = Hashtbl.fold find hash [] in
   6.120 -  match sock_list with
   6.121 -    | hd::tl -> hd
   6.122 -    | [] -> raise Unknown_domain
   6.123 -
   6.124 -let attach_debugger ctx =
   6.125 -  match ctx with
   6.126 -  | Domain d  -> Domain.attach_debugger (Domain.get_domain d) 
   6.127 -	                                (Domain.get_vcpu d)
   6.128 -  | Process p ->
   6.129 -      begin
   6.130 -	let xdom_sock = find_xen_domain_context (Process.get_domain p) in
   6.131 -	let xdom_ctx = find_context xdom_sock in
   6.132 -	begin
   6.133 -	  match xdom_ctx with
   6.134 -	    | Xen_domain d ->
   6.135 -		Process.attach_debugger p d
   6.136 -	    | _ -> failwith ("context has wrong xen domain type")
   6.137 -	end;
   6.138 -	raise No_reply
   6.139 -      end
   6.140 -  | _ -> raise (Unimplemented "attach debugger")
   6.141 -
   6.142 -let detach_debugger ctx =
   6.143 -  match ctx with
   6.144 -  | Domain d  -> 
   6.145 -      Domain.detach_debugger (Domain.get_domain d) 
   6.146 -	                     (Domain.get_vcpu d);
   6.147 -      "OK"
   6.148 -  | Process p  ->
   6.149 -      Process.detach_debugger p;
   6.150 -      raise No_reply
   6.151 -  | _ -> raise (Unimplemented "detach debugger")
   6.152 -
   6.153 -
   6.154 -let debug_contexts () =
   6.155 -  print_endline "context list:";
   6.156 -  let print_context key ctx = 
   6.157 -    match ctx with
   6.158 -    | Void -> print_endline (Printf.sprintf "  [%s] {void}" 
   6.159 -			       (Util.get_connection_info key))
   6.160 -    | Xen_virq  -> print_endline (Printf.sprintf "  [%s] {xen virq evtchn}" 
   6.161 -	                          (Util.get_connection_info key))
   6.162 -    | Xen_xcs   -> print_endline (Printf.sprintf "  [%s] {xen xcs socket}" 
   6.163 -			          (Util.get_connection_info key))
   6.164 -    | Xen_domain d -> print_endline (Printf.sprintf "  [%s] %s" 
   6.165 -			          (Util.get_connection_info key) 
   6.166 -                                  (Xen_domain.string_of_context d))
   6.167 -    | Domain d  -> print_endline (Printf.sprintf "  [%s] %s" 
   6.168 -				  (Util.get_connection_info key)
   6.169 -				  (Domain.string_of_context d))
   6.170 -    | Process p -> print_endline (Printf.sprintf "  [%s] %s" 
   6.171 -				  (Util.get_connection_info key)
   6.172 -				  (Process.string_of_context p))
   6.173 -  in
   6.174 -  Hashtbl.iter print_context hash
   6.175 -
   6.176 -(** add_context : add a new context to the hash table.
   6.177 - *  if there is an existing context for the same key then it 
   6.178 - *  is first removed implictly by the hash table replace function.
   6.179 - *)
   6.180 -let add_context (key:Unix.file_descr) context params =
   6.181 -  match context with
   6.182 -  | "void"     -> Hashtbl.replace hash key Void
   6.183 -  | "xen virq" -> Hashtbl.replace hash key Xen_virq
   6.184 -  | "xen xcs"  -> Hashtbl.replace hash key Xen_xcs
   6.185 -  | "domain" -> 
   6.186 -      begin
   6.187 -	match params with
   6.188 -	| dom::vcpu::_ ->
   6.189 -            let d = Domain(Domain.new_context dom vcpu) in
   6.190 -	    attach_debugger d;
   6.191 -            Hashtbl.replace hash key d
   6.192 -	| _ -> failwith "bogus parameters to domain context"
   6.193 -      end
   6.194 -  | "process" -> 
   6.195 -      begin
   6.196 -	match params with
   6.197 -	| dom::pid::_ ->
   6.198 -	    let p = Process(Process.new_context dom pid) in
   6.199 -	    Hashtbl.replace hash key p;
   6.200 -	    attach_debugger p
   6.201 -	| _ -> failwith "bogus parameters to process context"
   6.202 -      end
   6.203 -  | "xen domain"
   6.204 -  | _ -> raise (Unknown_context context)
   6.205 -
   6.206 -(* 
   6.207 - * this is really bogus.  add_xen_domain_context should really
   6.208 - * be a case within add_context.  however, we need to pass in
   6.209 - * a pointer that can only be represented as an int32.
   6.210 - * this would require a different type for params... :(
   6.211 - * 31 bit integers suck.
   6.212 - *)
   6.213 -let add_xen_domain_context (key:Unix.file_descr) dom evtchn sring =
   6.214 -  let d = Xen_domain.new_context dom evtchn sring in
   6.215 -  Hashtbl.replace hash key (Xen_domain(d))
   6.216 -
   6.217 -
   6.218 -let add_default_context sock =
   6.219 -  add_context sock "void" []
   6.220 -
   6.221 -(***************************************************************************)
   6.222 -
   6.223 -(***************************************************************************)
   6.224 -
   6.225 -let read_register ctx register =    (* register is int32 because of sscanf *)
   6.226 -  match ctx with
   6.227 -  | Void -> 0l                                      (* default for startup *)
   6.228 -  | Domain d  -> Domain.read_register d register
   6.229 -  | Process p ->
   6.230 -      begin
   6.231 -	Process.read_register p register;
   6.232 -	raise No_reply
   6.233 -      end
   6.234 -  | _ -> raise (Unimplemented "read registers")
   6.235 -
   6.236 -let read_registers ctx =
   6.237 -  match ctx with
   6.238 -  | Void -> Intel.null_registers                    (* default for startup *)
   6.239 -  | Domain d  -> Domain.read_registers d 
   6.240 -  | Process p ->
   6.241 -      begin
   6.242 -	Process.read_registers p;
   6.243 -	raise No_reply
   6.244 -      end
   6.245 -  | _ -> raise (Unimplemented "read registers")
   6.246 -
   6.247 -let write_register ctx register value =
   6.248 -  match ctx with
   6.249 -  | Domain d  -> Domain.write_register d register value
   6.250 -  | Process p ->
   6.251 -      begin
   6.252 -	Process.write_register p register value;
   6.253 -	raise No_reply
   6.254 -      end
   6.255 -  | _ -> raise (Unimplemented "write register")
   6.256 -
   6.257 -
   6.258 -let read_memory ctx addr len =
   6.259 -  match ctx with
   6.260 -  | Domain d  -> Domain.read_memory d addr len
   6.261 -  | Process p ->
   6.262 -      begin
   6.263 -	Process.read_memory p addr len;
   6.264 -	raise No_reply
   6.265 -      end
   6.266 -  | _ -> raise (Unimplemented "read memory")
   6.267 -
   6.268 -let write_memory ctx addr values =
   6.269 -  match ctx with
   6.270 -  | Domain d  -> Domain.write_memory d addr values
   6.271 -  | Process p ->
   6.272 -      begin
   6.273 -	Process.write_memory p addr values;
   6.274 -	raise No_reply
   6.275 -      end
   6.276 -  | _ -> raise (Unimplemented "write memory")
   6.277 -
   6.278 -
   6.279 -let continue ctx =
   6.280 -  match ctx with
   6.281 -  | Domain d  -> Domain.continue d
   6.282 -  | Process p  -> Process.continue p
   6.283 -  | _ -> raise (Unimplemented "continue")
   6.284 -
   6.285 -let step ctx =
   6.286 -  match ctx with
   6.287 -  | Domain d  -> Domain.step d
   6.288 -  | Process p  -> Process.step p
   6.289 -  | _ -> raise (Unimplemented "step")
   6.290 -
   6.291 -
   6.292 -let insert_memory_breakpoint ctx addr len =
   6.293 -  match ctx with
   6.294 -  | Domain d  -> Domain.insert_memory_breakpoint d addr len
   6.295 -  | Process p  ->
   6.296 -      begin
   6.297 -	Process.insert_memory_breakpoint p addr len;
   6.298 -	raise No_reply
   6.299 -      end
   6.300 -  | _ -> raise (Unimplemented "insert memory breakpoint")
   6.301 -
   6.302 -let remove_memory_breakpoint ctx addr len =
   6.303 -  match ctx with
   6.304 -  | Domain d  -> Domain.remove_memory_breakpoint d addr len
   6.305 -  | Process p  ->
   6.306 -      begin
   6.307 -	Process.remove_memory_breakpoint p addr len;
   6.308 -	raise No_reply
   6.309 -      end
   6.310 -  | _ -> raise (Unimplemented "remove memory breakpoint")
   6.311 -
   6.312 -let insert_watchpoint ctx kind addr len =
   6.313 -  match ctx with
   6.314 -(*  | Domain d  -> Domain.insert_watchpoint d kind addr len  TODO *)
   6.315 -  | Process p  ->
   6.316 -      begin
   6.317 -	Process.insert_watchpoint p kind addr len;
   6.318 -	raise No_reply
   6.319 -      end
   6.320 -  | _ -> raise (Unimplemented "insert watchpoint")
   6.321 -
   6.322 -let remove_watchpoint ctx kind addr len =
   6.323 -  match ctx with
   6.324 -(*  | Domain d  -> Domain.remove_watchpoint d kind addr len  TODO *)
   6.325 -  | Process p  ->
   6.326 -      begin
   6.327 -	Process.remove_watchpoint p kind addr len;
   6.328 -	raise No_reply
   6.329 -      end
   6.330 -  | _ -> raise (Unimplemented "remove watchpoint")
   6.331 -
   6.332 -
   6.333 -let pause ctx =
   6.334 -  match ctx with
   6.335 -  | Domain d  -> Domain.pause d
   6.336 -  | Process p  -> Process.pause p
   6.337 -  | _ -> raise (Unimplemented "pause target")
   6.338 -
   6.339 -
   6.340 -external open_debugger : unit -> unit = "open_context"
   6.341 -external close_debugger : unit -> unit = "close_context"
   6.342 -
   6.343 -(* this is just the domains right now... expand to other contexts later *)
   6.344 -external debugger_status : unit -> unit = "debugger_status"
   6.345 -
     7.1 --- a/tools/debugger/pdb/Process.ml	Fri Sep 29 11:11:49 2006 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,79 +0,0 @@
     7.4 -(** Process.ml
     7.5 - *
     7.6 - *  process context implementation
     7.7 - *
     7.8 - *  @author copyright (c) 2005 alex ho
     7.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    7.10 - *  @version 1
    7.11 - *)
    7.12 -
    7.13 -open Int32
    7.14 -open Intel
    7.15 -
    7.16 -type context_t =
    7.17 -{
    7.18 -  mutable domain  : int;
    7.19 -  mutable process : int;
    7.20 -  mutable evtchn  : int;
    7.21 -  mutable ring    : int32;
    7.22 -}
    7.23 -
    7.24 -let default_context = { domain = 0; process = 0; evtchn = 0; ring = 0l }
    7.25 -
    7.26 -let new_context dom proc = { domain = dom; process = proc; 
    7.27 -                             evtchn = 0; ring = 0l }
    7.28 -
    7.29 -let string_of_context ctx =
    7.30 -  Printf.sprintf "{process} domain: %d, process: %d"
    7.31 -                 ctx.domain  ctx.process
    7.32 -
    7.33 -let set_domain ctx value =
    7.34 -  ctx.domain <- value;
    7.35 -  print_endline (Printf.sprintf "ctx.domain <- %d" ctx.domain)
    7.36 -
    7.37 -let set_process ctx value =
    7.38 -  ctx.process <- value;
    7.39 -  print_endline (Printf.sprintf "ctx.process <- %d" ctx.process)
    7.40 -
    7.41 -let get_domain ctx =
    7.42 -  ctx.domain
    7.43 -
    7.44 -let get_process ctx =
    7.45 -  ctx.process
    7.46 -
    7.47 -external _attach_debugger : context_t -> unit = "proc_attach_debugger"
    7.48 -external detach_debugger : context_t -> unit = "proc_detach_debugger"
    7.49 -external pause_target : context_t -> unit = "proc_pause_target"
    7.50 -
    7.51 -(* save the event channel and ring for the domain for future use *)
    7.52 -let attach_debugger proc_ctx dom_ctx =
    7.53 -  print_endline (Printf.sprintf "%d %lx"
    7.54 -    (Xen_domain.get_evtchn dom_ctx)
    7.55 -    (Xen_domain.get_ring dom_ctx));
    7.56 -  proc_ctx.evtchn <- Xen_domain.get_evtchn dom_ctx;
    7.57 -  proc_ctx.ring   <- Xen_domain.get_ring   dom_ctx;
    7.58 -  _attach_debugger proc_ctx
    7.59 -
    7.60 -external read_register : context_t -> int -> unit = "proc_read_register"
    7.61 -external read_registers : context_t -> unit = "proc_read_registers"
    7.62 -external write_register : context_t -> register -> int32 -> unit =
    7.63 -  "proc_write_register"
    7.64 -external read_memory : context_t -> int32 -> int -> unit = 
    7.65 -  "proc_read_memory"
    7.66 -external write_memory : context_t -> int32 -> int list -> unit = 
    7.67 -  "proc_write_memory"
    7.68 -
    7.69 -external continue : context_t -> unit = "proc_continue_target"
    7.70 -external step : context_t -> unit = "proc_step_target"
    7.71 -
    7.72 -external insert_memory_breakpoint : context_t -> int32 -> int -> unit = 
    7.73 -  "proc_insert_memory_breakpoint"
    7.74 -external remove_memory_breakpoint : context_t -> int32 -> int -> unit = 
    7.75 -  "proc_remove_memory_breakpoint"
    7.76 -external insert_watchpoint : context_t -> int -> int32 -> int -> unit =
    7.77 -  "proc_insert_watchpoint"
    7.78 -external remove_watchpoint : context_t -> int -> int32 -> int -> unit =
    7.79 -  "proc_remove_watchpoint"
    7.80 -
    7.81 -let pause ctx =
    7.82 -  pause_target ctx
     8.1 --- a/tools/debugger/pdb/Process.mli	Fri Sep 29 11:11:49 2006 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,41 +0,0 @@
     8.4 -(** Process.mli
     8.5 - *
     8.6 - *  process context interface
     8.7 - *
     8.8 - *  @author copyright (c) 2005 alex ho
     8.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    8.10 - *  @version 1
    8.11 - *)
    8.12 -
    8.13 -open Int32
    8.14 -open Intel
    8.15 -
    8.16 -type context_t
    8.17 -
    8.18 -val default_context : context_t
    8.19 -val new_context : int -> int -> context_t
    8.20 -
    8.21 -val set_domain : context_t -> int -> unit
    8.22 -val get_domain : context_t -> int
    8.23 -val set_process : context_t -> int -> unit
    8.24 -val get_process : context_t -> int
    8.25 -
    8.26 -val string_of_context : context_t -> string
    8.27 -
    8.28 -val attach_debugger : context_t -> Xen_domain.context_t -> unit
    8.29 -val detach_debugger : context_t -> unit
    8.30 -val pause : context_t -> unit
    8.31 -
    8.32 -val read_register : context_t -> int -> unit
    8.33 -val read_registers : context_t -> unit
    8.34 -val write_register : context_t -> register -> int32 -> unit
    8.35 -val read_memory : context_t -> int32 -> int -> unit
    8.36 -val write_memory : context_t -> int32 -> int list -> unit
    8.37 -	
    8.38 -val continue : context_t -> unit
    8.39 -val step : context_t -> unit
    8.40 -
    8.41 -val insert_memory_breakpoint : context_t -> int32 -> int -> unit
    8.42 -val remove_memory_breakpoint : context_t -> int32 -> int -> unit
    8.43 -val insert_watchpoint : context_t -> int -> int32 -> int -> unit
    8.44 -val remove_watchpoint : context_t -> int -> int32 -> int -> unit
     9.1 --- a/tools/debugger/pdb/Util.ml	Fri Sep 29 11:11:49 2006 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,165 +0,0 @@
     9.4 -(** Util.ml
     9.5 - *
     9.6 - *  various utility functions
     9.7 - *
     9.8 - *  @author copyright (c) 2005 alex ho
     9.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
    9.10 - *  @version 1
    9.11 - *)
    9.12 -
    9.13 -let int_of_hexchar h = 
    9.14 -  let i = int_of_char h in
    9.15 -  match h with
    9.16 -  | '0' .. '9' -> i - (int_of_char '0')
    9.17 -  | 'a' .. 'f' -> i - (int_of_char 'a') + 10
    9.18 -  | 'A' .. 'F' -> i - (int_of_char 'A') + 10
    9.19 -  | _ -> raise (Invalid_argument "unknown hex character")
    9.20 -
    9.21 -let hexchar_of_int i = 
    9.22 -  let hexchars = [| '0'; '1'; '2'; '3'; '4'; '5'; '6'; '7';
    9.23 -		    '8'; '9'; 'a'; 'b'; 'c'; 'd'; 'e'; 'f' |]
    9.24 -  in
    9.25 -  hexchars.(i)
    9.26 -
    9.27 -
    9.28 -(** flip the bytes of a four byte int 
    9.29 - *)
    9.30 -
    9.31 -let flip_int num =
    9.32 -  let a = num mod 256
    9.33 -  and b = (num / 256) mod 256
    9.34 -  and c = (num / (256 * 256)) mod 256
    9.35 -  and d = (num / (256 * 256 * 256)) in
    9.36 -  (a * 256 * 256 * 256) + (b * 256 * 256) + (c * 256) + d
    9.37 -
    9.38 -    
    9.39 -let flip_int32 num =
    9.40 -  let a = Int32.logand num 0xffl
    9.41 -  and b = Int32.logand (Int32.shift_right_logical num 8)  0xffl
    9.42 -  and c = Int32.logand (Int32.shift_right_logical num 16) 0xffl
    9.43 -  and d =              (Int32.shift_right_logical num 24)       in
    9.44 -  (Int32.logor
    9.45 -     (Int32.logor (Int32.shift_left a 24) (Int32.shift_left b 16))
    9.46 -     (Int32.logor (Int32.shift_left c 8)  d))
    9.47 -
    9.48 -
    9.49 -let int_list_of_string_list list =
    9.50 -  List.map (fun x -> int_of_string x) list
    9.51 -    
    9.52 -let int_list_of_string str len =
    9.53 -  let array_of_string s =
    9.54 -    let int_array = Array.make len 0 in
    9.55 -    for loop = 0 to len - 1 do
    9.56 -      int_array.(loop) <- (Char.code s.[loop]);
    9.57 -    done;
    9.58 -    int_array
    9.59 -  in
    9.60 -  Array.to_list (array_of_string str)
    9.61 -
    9.62 -
    9.63 -(* remove leading and trailing whitespace from a string *)
    9.64 -
    9.65 -let chomp str =
    9.66 -  let head = Str.regexp "^[ \t\r\n]+" in
    9.67 -  let tail = Str.regexp "[ \t\r\n]+$" in
    9.68 -  let str = Str.global_replace head "" str in
    9.69 -  Str.global_replace tail "" str
    9.70 -
    9.71 -(* Stupid little parser for    "<key>=<value>[,<key>=<value>]*"
    9.72 -   It first chops the entire command at each ',', so no ',' in key or value!
    9.73 -   Mucked to return a list of words for "value"
    9.74 - *)
    9.75 -
    9.76 -let list_of_string str =
    9.77 -  let delim c = Str.regexp ("[ \t]*" ^ c ^ "[ \t]*") in
    9.78 -  let str_list = Str.split (delim " ") str in
    9.79 -  List.map (fun x -> chomp(x)) str_list
    9.80 -
    9.81 -let little_parser fn str =
    9.82 -  let delim c = Str.regexp ("[ \t]*" ^ c ^ "[ \t]*") in
    9.83 -  let str_list = Str.split (delim ",") str in
    9.84 -  let pair s =
    9.85 -    match Str.split (delim "=") s with
    9.86 -    | [key;value] -> fn (chomp key) (list_of_string value)
    9.87 -    | [key] -> fn (chomp key) []
    9.88 -    | _ -> failwith (Printf.sprintf "error: (little_parser) parse error [%s]" str)
    9.89 -  in
    9.90 -  List.iter pair str_list
    9.91 -
    9.92 -(* boolean list membership test *)
    9.93 -let not_list_member the_list element =
    9.94 -  try 
    9.95 -    List.find (fun x -> x = element) the_list;
    9.96 -    false
    9.97 -  with
    9.98 -    Not_found -> true
    9.99 -
   9.100 -(* a very inefficient way to remove the elements of one list from another *)
   9.101 -let list_remove the_list remove_list =
   9.102 -  List.filter (not_list_member remove_list) the_list
   9.103 -
   9.104 -(* get a description of a file descriptor *)
   9.105 -let get_connection_info fd =
   9.106 -  let get_local_info fd =
   9.107 -    let sockname = Unix.getsockname fd in
   9.108 -    match sockname with
   9.109 -    | Unix.ADDR_UNIX(s) -> "unix"
   9.110 -    | Unix.ADDR_INET(a,p) -> ((Unix.string_of_inet_addr a) ^ ":" ^
   9.111 -			      (string_of_int p))
   9.112 -  and get_remote_info fd =
   9.113 -    let sockname = Unix.getpeername fd in 
   9.114 -    match sockname with
   9.115 -    | Unix.ADDR_UNIX(s) -> s
   9.116 -    | Unix.ADDR_INET(a,p) -> ((Unix.string_of_inet_addr a) ^ ":" ^
   9.117 -			      (string_of_int p))
   9.118 -  in
   9.119 -  try
   9.120 -    get_remote_info fd
   9.121 -  with
   9.122 -  | Unix.Unix_error (Unix.ENOTSOCK, s1, s2) -> 
   9.123 -      let s = Unix.fstat fd in
   9.124 -      Printf.sprintf "dev: %d, inode: %d" s.Unix.st_dev s.Unix.st_ino
   9.125 -  | Unix.Unix_error (Unix.EBADF, s1, s2) -> 
   9.126 -      let s = Unix.fstat fd in
   9.127 -      Printf.sprintf "dev: %d, inode: %d" s.Unix.st_dev s.Unix.st_ino
   9.128 -  | _ -> get_local_info fd
   9.129 -
   9.130 -
   9.131 -(* really write a string *)
   9.132 -let really_write fd str =
   9.133 -  let strlen = String.length str in
   9.134 -  let sent = ref 0 in
   9.135 -  while (!sent < strlen) do
   9.136 -    sent := !sent + (Unix.write fd str !sent (strlen - !sent))
   9.137 -  done
   9.138 -
   9.139 -let write_character fd ch =
   9.140 -  let str = String.create 1 in
   9.141 -  str.[0] <- ch;
   9.142 -  really_write fd str
   9.143 -
   9.144 -
   9.145 -
   9.146 -let send_reply fd reply =
   9.147 -  let checksum = ref 0 in
   9.148 -  write_character fd '$';
   9.149 -  for loop = 0 to (String.length reply) - 1 do
   9.150 -    write_character fd reply.[loop];
   9.151 -    checksum := !checksum + int_of_char reply.[loop]
   9.152 -  done;
   9.153 -  write_character fd '#';
   9.154 -  write_character fd (hexchar_of_int ((!checksum mod 256) / 16));
   9.155 -  write_character fd (hexchar_of_int ((!checksum mod 256) mod 16))
   9.156 -  (*
   9.157 -   * BUG NEED TO LISTEN FOR REPLY +/- AND POSSIBLY RE-TRANSMIT
   9.158 -   *)
   9.159 -
   9.160 -
   9.161 -(** A few debugger commands such as step 's' and continue 'c' do 
   9.162 - *  not immediately return a response to the debugger.  In these 
   9.163 - *  cases we raise No_reply instead. 
   9.164 - *  This is also used by some contexts (such as Linux processes)
   9.165 - *  which utilize an asynchronous request / response protocol when
   9.166 - *  communicating with their respective backends.
   9.167 - *)
   9.168 -exception No_reply
    10.1 --- a/tools/debugger/pdb/Xen_domain.ml	Fri Sep 29 11:11:49 2006 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,43 +0,0 @@
    10.4 -(** Xen_domain.ml
    10.5 - *
    10.6 - *  domain assist for debugging processes
    10.7 - *
    10.8 - *  @author copyright (c) 2005 alex ho
    10.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   10.10 - *  @version 1
   10.11 - *)
   10.12 -
   10.13 -type context_t =
   10.14 -{
   10.15 -  mutable domain : int;
   10.16 -  mutable evtchn : int;
   10.17 -  mutable pdb_front_ring : int32
   10.18 -}
   10.19 -
   10.20 -let default_context = { domain = 0; evtchn = 0; pdb_front_ring = 0l }
   10.21 -
   10.22 -let new_context dom evtchn ring = 
   10.23 -  {domain = dom; evtchn = evtchn; pdb_front_ring = ring}
   10.24 -
   10.25 -let set_domain ctx value =
   10.26 -  ctx.domain <- value
   10.27 -
   10.28 -let set_evtchn ctx value =
   10.29 -  ctx.evtchn <- value
   10.30 -
   10.31 -let set_ring ctx value =
   10.32 -  ctx.pdb_front_ring <- value
   10.33 -
   10.34 -let get_domain ctx =
   10.35 -  ctx.domain
   10.36 -
   10.37 -let get_evtchn ctx =
   10.38 -  ctx.evtchn
   10.39 -
   10.40 -let get_ring ctx =
   10.41 -  ctx.pdb_front_ring
   10.42 -
   10.43 -let string_of_context ctx =
   10.44 -      Printf.sprintf "{xen domain assist} domain: %d" ctx.domain 
   10.45 -
   10.46 -external process_response : int32 -> int * int * string = "process_handle_response"
    11.1 --- a/tools/debugger/pdb/Xen_domain.mli	Fri Sep 29 11:11:49 2006 +0100
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,25 +0,0 @@
    11.4 -(** Xen_domain.ml
    11.5 - *
    11.6 - *  domain assist for debugging processes
    11.7 - *
    11.8 - *  @author copyright (c) 2005 alex ho
    11.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   11.10 - *  @version 1
   11.11 - *)
   11.12 -
   11.13 -type context_t
   11.14 -
   11.15 -val default_context : context_t
   11.16 -val new_context : int -> int -> int32 -> context_t 
   11.17 -
   11.18 -val set_domain : context_t -> int -> unit
   11.19 -val get_domain : context_t -> int
   11.20 -val set_evtchn : context_t -> int -> unit
   11.21 -val get_evtchn : context_t -> int
   11.22 -val set_ring   : context_t -> int32 -> unit
   11.23 -val get_ring   : context_t -> int32
   11.24 -
   11.25 -val string_of_context : context_t -> string
   11.26 -
   11.27 -val process_response : int32 -> int * int * string
   11.28 -
    12.1 --- a/tools/debugger/pdb/debugger.ml	Fri Sep 29 11:11:49 2006 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,372 +0,0 @@
    12.4 -(** debugger.ml
    12.5 - *
    12.6 - *  main debug functionality
    12.7 - *
    12.8 - *  @author copyright (c) 2005 alex ho
    12.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   12.10 - *  @version 1
   12.11 - *)
   12.12 -
   12.13 -open Intel
   12.14 -open PDB
   12.15 -open Util
   12.16 -open Str
   12.17 -
   12.18 -let initialize_debugger () =
   12.19 -  ()
   12.20 -
   12.21 -let exit_debugger () =
   12.22 -  ()
   12.23 -
   12.24 -
   12.25 -(**
   12.26 -   Detach Command
   12.27 -   Note: response is ignored by gdb.  We leave the context in the
   12.28 -   hash.  It will be cleaned up with the socket is closed.
   12.29 - *)
   12.30 -let gdb_detach ctx =
   12.31 -  PDB.detach_debugger ctx
   12.32 -
   12.33 -(**
   12.34 -   Kill Command
   12.35 -   Note: response is ignored by gdb.  We leave the context in the
   12.36 -   hash.  It will be cleaned up with the socket is closed.
   12.37 - *)
   12.38 -let gdb_kill () =
   12.39 -  ""
   12.40 -
   12.41 -
   12.42 -
   12.43 -(**
   12.44 -   Continue Command.
   12.45 -   resume the target
   12.46 - *)
   12.47 -let gdb_continue ctx =
   12.48 -  PDB.continue ctx;
   12.49 -  raise No_reply
   12.50 -
   12.51 -(**
   12.52 -   Step Command.
   12.53 -   single step the target
   12.54 - *)
   12.55 -let gdb_step ctx =
   12.56 -  PDB.step ctx;
   12.57 -  raise No_reply
   12.58 -
   12.59 -(**
   12.60 -   Read Register Command.
   12.61 -   return register as a 4-byte value.
   12.62 - *)
   12.63 -let gdb_read_register ctx command =
   12.64 -  let read_reg register =
   12.65 -    (Printf.sprintf "%08lx" (Util.flip_int32 (PDB.read_register ctx register)))
   12.66 -  in
   12.67 -  Scanf.sscanf command "p%x" read_reg
   12.68 -    
   12.69 -
   12.70 -(**
   12.71 -   Read Registers Command.
   12.72 -   returns 16 4-byte registers in a particular format defined by gdb.
   12.73 - *)
   12.74 -let gdb_read_registers ctx =
   12.75 -  let regs = PDB.read_registers ctx in
   12.76 -  let str = 
   12.77 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.eax)) ^
   12.78 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.ecx)) ^
   12.79 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.edx)) ^
   12.80 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.ebx)) ^
   12.81 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.esp)) ^
   12.82 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.ebp)) ^
   12.83 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.esi)) ^
   12.84 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.edi)) ^
   12.85 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.eip)) ^
   12.86 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.efl)) ^
   12.87 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.cs)) ^
   12.88 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.ss)) ^
   12.89 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.ds)) ^
   12.90 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.es)) ^
   12.91 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.fs)) ^
   12.92 -    (Printf.sprintf "%08lx" (Util.flip_int32 regs.gs)) in
   12.93 -  str
   12.94 -      
   12.95 -(**
   12.96 -   Set Thread Command
   12.97 - *)
   12.98 -let gdb_set_thread command =
   12.99 -  "OK"
  12.100 -
  12.101 -
  12.102 -(**
  12.103 -   Read Memory Packets
  12.104 - *)
  12.105 -let gdb_read_memory ctx command =
  12.106 -  let int_list_to_string i str =
  12.107 -    (Printf.sprintf "%02x" i) ^ str
  12.108 -  in
  12.109 -  let read_mem addr len =
  12.110 -    try
  12.111 -      let mem = PDB.read_memory ctx addr len  in
  12.112 -      List.fold_right int_list_to_string mem ""
  12.113 -    with
  12.114 -      Failure s -> "E02"
  12.115 -  in
  12.116 -  Scanf.sscanf command "m%lx,%x" read_mem
  12.117 -
  12.118 -
  12.119 -
  12.120 -(**
  12.121 -   Write Memory Packets
  12.122 - *)
  12.123 -let gdb_write_memory ctx command =
  12.124 -  let write_mem addr len =
  12.125 -    print_endline (Printf.sprintf "  gdb_write_memory %lx %x\n" addr len);
  12.126 -    print_endline (Printf.sprintf "  [[ unimplemented ]]\n")
  12.127 -  in
  12.128 -  Scanf.sscanf command "M%lx,%d" write_mem;
  12.129 -  "OK"
  12.130 -
  12.131 -
  12.132 -
  12.133 -(**
  12.134 -   Write Register Packets
  12.135 - *)
  12.136 -let gdb_write_register ctx command =
  12.137 -  let write_reg reg goofy_val =
  12.138 -    let new_val = Util.flip_int32 goofy_val in
  12.139 -    match reg with
  12.140 -    |  0 -> PDB.write_register ctx EAX new_val
  12.141 -    |  1 -> PDB.write_register ctx ECX new_val
  12.142 -    |  2 -> PDB.write_register ctx EDX new_val
  12.143 -    |  3 -> PDB.write_register ctx EBX new_val
  12.144 -    |  4 -> PDB.write_register ctx ESP new_val
  12.145 -    |  5 -> PDB.write_register ctx EBP new_val
  12.146 -    |  6 -> PDB.write_register ctx ESI new_val
  12.147 -    |  7 -> PDB.write_register ctx EDI new_val
  12.148 -    |  8 -> PDB.write_register ctx EIP new_val
  12.149 -    |  9 -> PDB.write_register ctx EFL new_val
  12.150 -    | 10 -> PDB.write_register ctx CS new_val
  12.151 -    | 11 -> PDB.write_register ctx SS new_val
  12.152 -    | 12 -> PDB.write_register ctx DS new_val
  12.153 -    | 13 -> PDB.write_register ctx ES new_val
  12.154 -    | 14 -> PDB.write_register ctx FS new_val
  12.155 -    | 15 -> PDB.write_register ctx GS new_val
  12.156 -    | _  -> print_endline (Printf.sprintf "write unknown register [%d]" reg)
  12.157 -  in
  12.158 -  Scanf.sscanf command "P%x=%lx" write_reg;
  12.159 -  "OK"
  12.160 -
  12.161 -
  12.162 -(**
  12.163 -   General Query Packets
  12.164 - *)
  12.165 -let gdb_query command =
  12.166 -  match command with
  12.167 -  | "qC" -> ""
  12.168 -  | "qOffsets" -> ""
  12.169 -  | "qSymbol::" -> ""
  12.170 -  | _ -> 
  12.171 -      print_endline (Printf.sprintf "unknown gdb query packet [%s]" command);
  12.172 -      "E01"
  12.173 -
  12.174 -
  12.175 -(**
  12.176 -   Write Memory Binary Packets
  12.177 - *)
  12.178 -let gdb_write_memory_binary ctx command =
  12.179 -  let write_mem addr len =
  12.180 -    let pos = Str.search_forward (Str.regexp ":") command 0 in
  12.181 -    let txt = Str.string_after command (pos + 1) in
  12.182 -    PDB.write_memory ctx addr (int_list_of_string txt len)
  12.183 -  in
  12.184 -  Scanf.sscanf command "X%lx,%d" write_mem;
  12.185 -  "OK"
  12.186 -
  12.187 -
  12.188 -
  12.189 -(**
  12.190 -   Last Signal Command
  12.191 - *)
  12.192 -let gdb_last_signal =
  12.193 -  "S00"
  12.194 -
  12.195 -
  12.196 -
  12.197 -
  12.198 -(**
  12.199 -   Process PDB extensions to the GDB serial protocol.
  12.200 -   Changes the mutable context state.
  12.201 - *)
  12.202 -let pdb_extensions command sock =
  12.203 -  let process_extension key value =
  12.204 -    (* since this command can change the context, 
  12.205 -       we need to grab it again each time *)
  12.206 -    let ctx = PDB.find_context sock in
  12.207 -    match key with
  12.208 -    | "status" ->
  12.209 -	PDB.debug_contexts ();
  12.210 -	(* print_endline ("debugger status");
  12.211 -	   debugger_status () 
  12.212 -	*)
  12.213 -    | "context" ->
  12.214 -        PDB.add_context sock (List.hd value) 
  12.215 -                             (int_list_of_string_list (List.tl value))
  12.216 -    | _ -> failwith (Printf.sprintf "unknown pdb extension command [%s:%s]" 
  12.217 -		                    key (List.hd value))
  12.218 -  in
  12.219 -  try
  12.220 -    Util.little_parser process_extension 
  12.221 -                       (String.sub command 1 ((String.length command) - 1));
  12.222 -    "OK"
  12.223 -  with
  12.224 -  | Unknown_context s -> 
  12.225 -      print_endline (Printf.sprintf "unknown context [%s]" s);
  12.226 -      "E01"
  12.227 -  | Unknown_domain -> "E01"
  12.228 -  | Failure s -> "E01"
  12.229 -
  12.230 -
  12.231 -(**
  12.232 -   Insert Breakpoint or Watchpoint Packet
  12.233 - *)
  12.234 -
  12.235 -let bwc_watch_write  = 102                              (* from pdb_module.h *)
  12.236 -let bwc_watch_read   = 103
  12.237 -let bwc_watch_access = 104
  12.238 -
  12.239 -let gdb_insert_bwcpoint ctx command =
  12.240 -  let insert cmd addr length =
  12.241 -    try
  12.242 -      match cmd with
  12.243 -      | 0 -> PDB.insert_memory_breakpoint ctx addr length; "OK"
  12.244 -      | 2 -> PDB.insert_watchpoint ctx bwc_watch_write  addr length; "OK"
  12.245 -      | 3 -> PDB.insert_watchpoint ctx bwc_watch_read   addr length; "OK"
  12.246 -      | 4 -> PDB.insert_watchpoint ctx bwc_watch_access addr length; "OK"
  12.247 -      | _ -> ""
  12.248 -    with
  12.249 -      Failure s -> "E03"
  12.250 -  in
  12.251 -  Scanf.sscanf command "Z%d,%lx,%x" insert
  12.252 -
  12.253 -(**
  12.254 -   Remove Breakpoint or Watchpoint Packet
  12.255 - *)
  12.256 -let gdb_remove_bwcpoint ctx command =
  12.257 -  let insert cmd addr length =
  12.258 -    try
  12.259 -      match cmd with
  12.260 -      | 0 -> PDB.remove_memory_breakpoint ctx addr length; "OK"
  12.261 -      | 2 -> PDB.remove_watchpoint ctx bwc_watch_write  addr length; "OK"
  12.262 -      | 3 -> PDB.remove_watchpoint ctx bwc_watch_read   addr length; "OK"
  12.263 -      | 4 -> PDB.remove_watchpoint ctx bwc_watch_access addr length; "OK"
  12.264 -      | _ -> ""
  12.265 -    with
  12.266 -      Failure s -> "E04"
  12.267 -  in
  12.268 -  Scanf.sscanf command "z%d,%lx,%d" insert
  12.269 -
  12.270 -(**
  12.271 -   Do Work!
  12.272 -
  12.273 -   @param command  char list
  12.274 - *)
  12.275 -
  12.276 -let process_command command sock =
  12.277 -  let ctx = PDB.find_context sock in
  12.278 -  try
  12.279 -    match command.[0] with
  12.280 -    | 'c' -> gdb_continue ctx
  12.281 -    | 'D' -> gdb_detach ctx
  12.282 -    | 'g' -> gdb_read_registers ctx
  12.283 -    | 'H' -> gdb_set_thread command
  12.284 -    | 'k' -> gdb_kill ()
  12.285 -    | 'm' -> gdb_read_memory ctx command
  12.286 -    | 'M' -> gdb_write_memory ctx command
  12.287 -    | 'p' -> gdb_read_register ctx command
  12.288 -    | 'P' -> gdb_write_register ctx command
  12.289 -    | 'q' -> gdb_query command
  12.290 -    | 's' -> gdb_step ctx
  12.291 -    | 'x' -> pdb_extensions command sock
  12.292 -    | 'X' -> gdb_write_memory_binary ctx command
  12.293 -    | '?' -> gdb_last_signal
  12.294 -    | 'z' -> gdb_remove_bwcpoint ctx command
  12.295 -    | 'Z' -> gdb_insert_bwcpoint ctx command
  12.296 -    | _ -> 
  12.297 -	print_endline (Printf.sprintf "unknown gdb command [%s]" command);
  12.298 -	""
  12.299 -  with
  12.300 -    Unimplemented s ->
  12.301 -      print_endline (Printf.sprintf "loser. unimplemented command [%s][%s]" 
  12.302 -		                    command s);
  12.303 -      "E03"
  12.304 -
  12.305 -(**
  12.306 -   process_xen_domain
  12.307 -
  12.308 -   This is called whenever a domain debug assist responds to a
  12.309 -   pdb packet.
  12.310 -*)
  12.311 -
  12.312 -let process_xen_domain fd =
  12.313 -  let channel = Evtchn.read fd in
  12.314 -  let ctx = find_context fd in
  12.315 -  
  12.316 -  let (dom, pid, str) =
  12.317 -  begin
  12.318 -    match ctx with
  12.319 -      | Xen_domain d -> Xen_domain.process_response (Xen_domain.get_ring d)
  12.320 -      | _ -> failwith ("process_xen_domain called without Xen_domain context")
  12.321 -  end 
  12.322 -  in
  12.323 -  let sock = PDB.find_process dom pid in
  12.324 -  print_endline (Printf.sprintf "(linux) dom:%d pid:%d  %s  %s" 
  12.325 -		   dom pid str (Util.get_connection_info sock));
  12.326 -  Util.send_reply sock str;
  12.327 -  Evtchn.unmask fd channel                                (* allow next virq *)
  12.328 -  
  12.329 -
  12.330 -(**
  12.331 -   process_xen_virq
  12.332 -
  12.333 -   This is called each time a virq_pdb is sent from xen to dom 0.
  12.334 -   It is sent by Xen when a domain hits a breakpoint. 
  12.335 -
  12.336 -   Think of this as the continuation function for a "c" or "s" command
  12.337 -   issued to a domain.
  12.338 -*)
  12.339 -
  12.340 -external query_domain_stop : unit -> (int * int) list = "query_domain_stop"
  12.341 -(* returns a list of paused domains : () -> (domain, vcpu) list *)
  12.342 -
  12.343 -let process_xen_virq fd =
  12.344 -  let channel = Evtchn.read fd in
  12.345 -  let find_pair (dom, vcpu) =
  12.346 -    print_endline (Printf.sprintf "checking %d.%d" dom vcpu);
  12.347 -    try
  12.348 -      let sock = PDB.find_domain dom vcpu in
  12.349 -      true
  12.350 -    with
  12.351 -      Unknown_domain -> false
  12.352 -  in
  12.353 -  let dom_list = query_domain_stop () in
  12.354 -  let (dom, vcpu) = List.find find_pair dom_list in
  12.355 -  let vec = 3 in
  12.356 -  let sock = PDB.find_domain dom vcpu in
  12.357 -  print_endline (Printf.sprintf "handle bkpt dom:%d vcpu:%d vec:%d  %s" 
  12.358 -		   dom vcpu vec (Util.get_connection_info sock));
  12.359 -  Util.send_reply sock "S05";
  12.360 -  Evtchn.unmask fd channel                                (* allow next virq *)
  12.361 -  
  12.362 -
  12.363 -(**
  12.364 -   process_xen_xcs
  12.365 -
  12.366 -   This is called each time the software assist residing in a backend 
  12.367 -   domain starts up.  The control message includes the address of a 
  12.368 -   shared ring page and our end of an event channel (which indicates
  12.369 -   when data is available on the ring).
  12.370 -*)
  12.371 -
  12.372 -let process_xen_xcs xcs_fd =
  12.373 -  let (local_evtchn_fd, evtchn, dom, ring) = Xcs.read xcs_fd in
  12.374 -  add_xen_domain_context local_evtchn_fd dom evtchn ring;
  12.375 -  local_evtchn_fd
    13.1 --- a/tools/debugger/pdb/evtchn.ml	Fri Sep 29 11:11:49 2006 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,40 +0,0 @@
    13.4 -(** evtchn.ml
    13.5 - *
    13.6 - *  event channel interface
    13.7 - *
    13.8 - *  @author copyright (c) 2005 alex ho
    13.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   13.10 - *  @version 1
   13.11 - *)
   13.12 -
   13.13 -let dev_name = "/dev/xen/evtchn"                          (* EVTCHN_DEV_NAME *)
   13.14 -let dev_major = 10                                       (* EVTCHN_DEV_MAJOR *)
   13.15 -let dev_minor = 201                                      (* EVTCHN_DEV_MINOR *)
   13.16 -
   13.17 -let virq_pdb = 6                                      (* as defined VIRQ_PDB *)
   13.18 -
   13.19 -external bind_virq : int -> int = "evtchn_bind_virq"
   13.20 -external bind_interdomain : int -> int * int = "evtchn_bind_interdomain"
   13.21 -external bind : Unix.file_descr -> int -> unit = "evtchn_bind"
   13.22 -external unbind : Unix.file_descr -> int -> unit = "evtchn_unbind"
   13.23 -external ec_open : string -> int -> int -> Unix.file_descr = "evtchn_open"
   13.24 -external read : Unix.file_descr -> int = "evtchn_read"
   13.25 -external ec_close : Unix.file_descr -> unit = "evtchn_close"
   13.26 -external unmask : Unix.file_descr -> int -> unit = "evtchn_unmask"
   13.27 -
   13.28 -let _setup () =
   13.29 -  let fd = ec_open dev_name dev_major dev_minor in
   13.30 -  fd
   13.31 -
   13.32 -let _bind fd port =
   13.33 -  bind fd port
   13.34 -
   13.35 -let setup () =
   13.36 -  let port = bind_virq virq_pdb in
   13.37 -  let fd = _setup() in
   13.38 -  _bind fd port;
   13.39 -  fd
   13.40 -
   13.41 -let teardown fd =
   13.42 -  unbind fd virq_pdb;
   13.43 -  ec_close fd
    14.1 --- a/tools/debugger/pdb/evtchn.mli	Fri Sep 29 11:11:49 2006 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,19 +0,0 @@
    14.4 -(** evtchn.mli
    14.5 - *
    14.6 - *  event channel interface
    14.7 - *
    14.8 - *  @author copyright (c) 2005 alex ho
    14.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   14.10 - *  @version 1
   14.11 - *)
   14.12 -
   14.13 -val _setup : unit -> Unix.file_descr
   14.14 -val _bind : Unix.file_descr -> int -> unit
   14.15 -
   14.16 -val bind_interdomain : int -> int * int
   14.17 -
   14.18 -
   14.19 -val setup : unit -> Unix.file_descr
   14.20 -val read : Unix.file_descr -> int
   14.21 -val teardown : Unix.file_descr -> unit
   14.22 -val unmask : Unix.file_descr -> int -> unit
    15.1 --- a/tools/debugger/pdb/linux-2.6-module/Makefile	Fri Sep 29 11:11:49 2006 +0100
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,21 +0,0 @@
    15.4 -XEN_ROOT   = ../../../..
    15.5 -LINUX_DIR  = linux-2.6.12-xenU
    15.6 -KDIR       = $(XEN_ROOT)/$(LINUX_DIR)
    15.7 -
    15.8 -obj-m    += pdb.o
    15.9 -pdb-objs += module.o
   15.10 -pdb-objs += debug.o
   15.11 -
   15.12 -CFLAGS += -g
   15.13 -CFLAGS += -Wall
   15.14 -CFLAGS += -Werror
   15.15 -
   15.16 -.PHONY: module 
   15.17 -module : 
   15.18 -#	make KBUILD_VERBOSE=1 ARCH=xen -C $(KDIR) M=$(PWD) modules
   15.19 -	make                  ARCH=xen -C $(KDIR) M=$(PWD) modules
   15.20 -
   15.21 -.PHONY: clean 
   15.22 -clean :
   15.23 -	make -C $(KDIR) M=$(PWD) clean
   15.24 -
    16.1 --- a/tools/debugger/pdb/linux-2.6-module/debug.c	Fri Sep 29 11:11:49 2006 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,851 +0,0 @@
    16.4 -/*
    16.5 - * debug.c
    16.6 - * pdb debug functionality for processes.
    16.7 - */
    16.8 -
    16.9 -#include <linux/module.h>
   16.10 -#include <linux/mm.h>
   16.11 -#include <linux/sched.h>
   16.12 -#include <asm-i386/kdebug.h>
   16.13 -#include <asm-i386/mach-xen/asm/processor.h>
   16.14 -#include <asm-i386/mach-xen/asm/ptrace.h>
   16.15 -#include <asm-i386/mach-xen/asm/tlbflush.h>
   16.16 -#include <xen/interface/xen.h>
   16.17 -#include "pdb_module.h"
   16.18 -#include "pdb_debug.h"
   16.19 -
   16.20 -
   16.21 -static int pdb_debug_fn (struct pt_regs *regs, long error_code,
   16.22 -                         unsigned int condition);
   16.23 -static int pdb_int3_fn (struct pt_regs *regs, long error_code);
   16.24 -static int pdb_page_fault_fn (struct pt_regs *regs, long error_code,
   16.25 -                              unsigned int condition);
   16.26 -
   16.27 -/***********************************************************************/
   16.28 -
   16.29 -typedef struct bwcpoint                           /* break/watch/catch point */
   16.30 -{
   16.31 -    struct list_head list;
   16.32 -    unsigned long address;
   16.33 -    int length;
   16.34 -
   16.35 -    uint8_t  type;                                                     /* BWC_??? */
   16.36 -    uint8_t  mode;                   /* for BWC_PAGE, the current protection mode */
   16.37 -    uint32_t process;
   16.38 -    uint8_t  error;                /* error occured when enabling: don't disable. */
   16.39 -
   16.40 -    /* original values */
   16.41 -    uint8_t    orig_bkpt;                               /* single byte breakpoint */
   16.42 -    pte_t orig_pte;
   16.43 -
   16.44 -    struct list_head watchpt_read_list;     /* read watchpoints on this page */
   16.45 -    struct list_head watchpt_write_list;                            /* write */
   16.46 -    struct list_head watchpt_access_list;                          /* access */
   16.47 -    struct list_head watchpt_disabled_list;                      /* disabled */
   16.48 -
   16.49 -    struct bwcpoint *parent;             /* watchpoint: bwc_watch (the page) */
   16.50 -    struct bwcpoint *watchpoint;      /* bwc_watch_step: original watchpoint */
   16.51 -} bwcpoint_t, *bwcpoint_p;
   16.52 -
   16.53 -static struct list_head bwcpoint_list = LIST_HEAD_INIT(bwcpoint_list);
   16.54 -
   16.55 -#define _pdb_bwcpoint_alloc(_var) \
   16.56 -{ \
   16.57 -    if ( (_var = kmalloc(sizeof(bwcpoint_t), GFP_KERNEL)) == NULL ) \
   16.58 -        printk("error: unable to allocate memory %d\n", __LINE__); \
   16.59 -    else { \
   16.60 -        memset(_var, 0, sizeof(bwcpoint_t)); \
   16.61 -        INIT_LIST_HEAD(&_var->watchpt_read_list); \
   16.62 -        INIT_LIST_HEAD(&_var->watchpt_write_list); \
   16.63 -        INIT_LIST_HEAD(&_var->watchpt_access_list); \
   16.64 -        INIT_LIST_HEAD(&_var->watchpt_disabled_list); \
   16.65 -    } \
   16.66 -}
   16.67 -
   16.68 -/***********************************************************************/
   16.69 -
   16.70 -static void _pdb_bwc_print_list (struct list_head *, char *, int);
   16.71 -
   16.72 -static void
   16.73 -_pdb_bwc_print (bwcpoint_p bwc, char *label, int level)
   16.74 -{
   16.75 -    printk("%s%03d 0x%08lx:0x%02x %c\n", label, bwc->type,
   16.76 -           bwc->address, bwc->length, bwc->error ? 'e' : '-');
   16.77 -
   16.78 -    if ( !list_empty(&bwc->watchpt_read_list) )
   16.79 -        _pdb_bwc_print_list(&bwc->watchpt_read_list, "r", level);
   16.80 -    if ( !list_empty(&bwc->watchpt_write_list) )
   16.81 -        _pdb_bwc_print_list(&bwc->watchpt_write_list, "w", level);
   16.82 -    if ( !list_empty(&bwc->watchpt_access_list) )
   16.83 -        _pdb_bwc_print_list(&bwc->watchpt_access_list, "a", level);
   16.84 -    if ( !list_empty(&bwc->watchpt_disabled_list) )
   16.85 -        _pdb_bwc_print_list(&bwc->watchpt_disabled_list, "d", level);
   16.86 -}
   16.87 -
   16.88 -static void
   16.89 -_pdb_bwc_print_list (struct list_head *bwc_list, char *label, int level)
   16.90 -{
   16.91 -    struct list_head *ptr;
   16.92 -    int counter = 0;
   16.93 -
   16.94 -    list_for_each(ptr, bwc_list)
   16.95 -    {
   16.96 -        bwcpoint_p bwc = list_entry(ptr, bwcpoint_t, list);
   16.97 -        printk("  %s[%02d]%s ", level > 0 ? "  " : "", counter++,
   16.98 -                                level > 0 ? "" : "  ");
   16.99 -        _pdb_bwc_print(bwc, label, level+1);
  16.100 -    }
  16.101 -
  16.102 -    if (counter == 0)
  16.103 -    {
  16.104 -        printk("  empty list\n");
  16.105 -    }
  16.106 -}
  16.107 -
  16.108 -void
  16.109 -pdb_bwc_print_list (void)
  16.110 -{
  16.111 -    _pdb_bwc_print_list(&bwcpoint_list, " ", 0);
  16.112 -}
  16.113 -
  16.114 -bwcpoint_p
  16.115 -pdb_search_watchpoint (uint32_t process, unsigned long address)
  16.116 -{
  16.117 -    bwcpoint_p bwc_watch = (bwcpoint_p) 0;
  16.118 -    bwcpoint_p bwc_entry = (bwcpoint_p) 0;
  16.119 -    struct list_head *ptr;
  16.120 -
  16.121 -    list_for_each(ptr, &bwcpoint_list)                /* find bwc page entry */
  16.122 -    {
  16.123 -        bwc_watch = list_entry(ptr, bwcpoint_t, list);
  16.124 -        if (bwc_watch->address == (address & PAGE_MASK)) break;
  16.125 -    }
  16.126 -
  16.127 -    if ( !bwc_watch )
  16.128 -    {
  16.129 -        return (bwcpoint_p) 0;
  16.130 -    }
  16.131 -
  16.132 -#define __pdb_search_watchpoint_list(__list) \
  16.133 -    list_for_each(ptr, (__list))  \
  16.134 -    { \
  16.135 -        bwc_entry = list_entry(ptr, bwcpoint_t, list); \
  16.136 -        if ( bwc_entry->process == process &&          \
  16.137 -             bwc_entry->address <= address &&          \
  16.138 -             bwc_entry->address + bwc_entry->length > address ) \
  16.139 -            return bwc_entry; \
  16.140 -    }
  16.141 -
  16.142 -    __pdb_search_watchpoint_list(&bwc_watch->watchpt_read_list);
  16.143 -    __pdb_search_watchpoint_list(&bwc_watch->watchpt_write_list);
  16.144 -    __pdb_search_watchpoint_list(&bwc_watch->watchpt_access_list);
  16.145 -
  16.146 -#undef __pdb_search_watchpoint_list
  16.147 -
  16.148 -    return (bwcpoint_p) 0;
  16.149 -}
  16.150 -
  16.151 -/*************************************************************/
  16.152 -
  16.153 -int
  16.154 -pdb_suspend (struct task_struct *target)
  16.155 -{
  16.156 -    uint32_t rc = 0;
  16.157 -
  16.158 -    force_sig(SIGSTOP, target);                    /* force_sig_specific ??? */
  16.159 -
  16.160 -    return rc;
  16.161 -}
  16.162 -
  16.163 -int
  16.164 -pdb_resume (struct task_struct *target)
  16.165 -{
  16.166 -    int rc = 0;
  16.167 -
  16.168 -    wake_up_process(target);
  16.169 -
  16.170 -    return rc;
  16.171 -}
  16.172 -
  16.173 -/*
  16.174 - * from linux-2.6.11/arch/i386/kernel/ptrace.c::getreg()
  16.175 - */
  16.176 -static unsigned long
  16.177 -_pdb_get_register (struct task_struct *target, int reg)
  16.178 -{
  16.179 -    unsigned long result = ~0UL;
  16.180 -    unsigned long offset;
  16.181 -    unsigned char *stack = 0L;
  16.182 -
  16.183 -    switch (reg)
  16.184 -    {
  16.185 -    case LINUX_FS:
  16.186 -        result = target->thread.fs;
  16.187 -        break;
  16.188 -    case LINUX_GS:
  16.189 -        result = target->thread.gs;
  16.190 -        break;
  16.191 -    case LINUX_DS:
  16.192 -    case LINUX_ES:
  16.193 -    case LINUX_SS:
  16.194 -    case LINUX_CS:
  16.195 -        result = 0xffff;
  16.196 -        /* fall through */
  16.197 -    default:
  16.198 -        if (reg > LINUX_GS)
  16.199 -            reg -= 2;
  16.200 -
  16.201 -        offset = reg * sizeof(long);
  16.202 -        offset -= sizeof(struct pt_regs);
  16.203 -        stack = (unsigned char *)target->thread.esp0;
  16.204 -        stack += offset;
  16.205 -        result &= *((int *)stack);
  16.206 -    }
  16.207 -
  16.208 -    return result;
  16.209 -}
  16.210 -
  16.211 -/*
  16.212 - * from linux-2.6.11/arch/i386/kernel/ptrace.c::putreg()
  16.213 - */
  16.214 -static void
  16.215 -_pdb_set_register (struct task_struct *target, int reg, unsigned long val)
  16.216 -{
  16.217 -    unsigned long offset;
  16.218 -    unsigned char *stack;
  16.219 -    unsigned long value = val;
  16.220 -
  16.221 -    switch (reg)
  16.222 -    {
  16.223 -    case LINUX_FS:
  16.224 -        target->thread.fs = value;
  16.225 -        return;
  16.226 -    case LINUX_GS:
  16.227 -        target->thread.gs = value;
  16.228 -        return;
  16.229 -    case LINUX_DS:
  16.230 -    case LINUX_ES:
  16.231 -        value &= 0xffff;
  16.232 -        break;
  16.233 -    case LINUX_SS:
  16.234 -    case LINUX_CS:
  16.235 -        value &= 0xffff;
  16.236 -        break;
  16.237 -    case LINUX_EFL:
  16.238 -        break;
  16.239 -    }
  16.240 -
  16.241 -    if (reg > LINUX_GS)
  16.242 -        reg -= 2;
  16.243 -    offset = reg * sizeof(long);
  16.244 -    offset -= sizeof(struct pt_regs);
  16.245 -    stack = (unsigned char *)target->thread.esp0;
  16.246 -    stack += offset;
  16.247 -    *(unsigned long *) stack = value;
  16.248 -
  16.249 -    return;
  16.250 -}
  16.251 -
  16.252 -int
  16.253 -pdb_read_register (struct task_struct *target, pdb_op_rd_reg_p op)
  16.254 -{
  16.255 -    int rc = 0;
  16.256 -
  16.257 -    switch (op->reg)
  16.258 -    {
  16.259 -    case  0: op->value = _pdb_get_register(target, LINUX_EAX); break;
  16.260 -    case  1: op->value = _pdb_get_register(target, LINUX_ECX); break;
  16.261 -    case  2: op->value = _pdb_get_register(target, LINUX_EDX); break;
  16.262 -    case  3: op->value = _pdb_get_register(target, LINUX_EBX); break;
  16.263 -    case  4: op->value = _pdb_get_register(target, LINUX_ESP); break;
  16.264 -    case  5: op->value = _pdb_get_register(target, LINUX_EBP); break;
  16.265 -    case  6: op->value = _pdb_get_register(target, LINUX_ESI); break;
  16.266 -    case  7: op->value = _pdb_get_register(target, LINUX_EDI); break;
  16.267 -    case  8: op->value = _pdb_get_register(target, LINUX_EIP); break;
  16.268 -    case  9: op->value = _pdb_get_register(target, LINUX_EFL); break;
  16.269 -
  16.270 -    case 10: op->value = _pdb_get_register(target, LINUX_CS); break;
  16.271 -    case 11: op->value = _pdb_get_register(target, LINUX_SS); break;
  16.272 -    case 12: op->value = _pdb_get_register(target, LINUX_DS); break;
  16.273 -    case 13: op->value = _pdb_get_register(target, LINUX_ES); break;
  16.274 -    case 14: op->value = _pdb_get_register(target, LINUX_FS); break;
  16.275 -    case 15: op->value = _pdb_get_register(target, LINUX_GS); break;
  16.276 -    }
  16.277 -
  16.278 -    return rc;
  16.279 -}
  16.280 -
  16.281 -int
  16.282 -pdb_read_registers (struct task_struct *target, pdb_op_rd_regs_p op)
  16.283 -{
  16.284 -    int rc = 0;
  16.285 -
  16.286 -    op->reg[ 0] = _pdb_get_register(target, LINUX_EAX);
  16.287 -    op->reg[ 1] = _pdb_get_register(target, LINUX_ECX);
  16.288 -    op->reg[ 2] = _pdb_get_register(target, LINUX_EDX);
  16.289 -    op->reg[ 3] = _pdb_get_register(target, LINUX_EBX);
  16.290 -    op->reg[ 4] = _pdb_get_register(target, LINUX_ESP);
  16.291 -    op->reg[ 5] = _pdb_get_register(target, LINUX_EBP);
  16.292 -    op->reg[ 6] = _pdb_get_register(target, LINUX_ESI);
  16.293 -    op->reg[ 7] = _pdb_get_register(target, LINUX_EDI);
  16.294 -    op->reg[ 8] = _pdb_get_register(target, LINUX_EIP);
  16.295 -    op->reg[ 9] = _pdb_get_register(target, LINUX_EFL);
  16.296 -
  16.297 -    op->reg[10] = _pdb_get_register(target, LINUX_CS);
  16.298 -    op->reg[11] = _pdb_get_register(target, LINUX_SS);
  16.299 -    op->reg[12] = _pdb_get_register(target, LINUX_DS);
  16.300 -    op->reg[13] = _pdb_get_register(target, LINUX_ES);
  16.301 -    op->reg[14] = _pdb_get_register(target, LINUX_FS);
  16.302 -    op->reg[15] = _pdb_get_register(target, LINUX_GS);
  16.303 -
  16.304 -    return rc;
  16.305 -}
  16.306 -
  16.307 -int
  16.308 -pdb_write_register (struct task_struct *target, pdb_op_wr_reg_p op)
  16.309 -{
  16.310 -    int rc = 0;
  16.311 -
  16.312 -    _pdb_set_register(target, op->reg, op->value);
  16.313 -
  16.314 -    return rc;
  16.315 -}
  16.316 -
  16.317 -int
  16.318 -pdb_access_memory (struct task_struct *target, unsigned long address, 
  16.319 -                   void *buffer, int length, int write)
  16.320 -{
  16.321 -    int rc = 0;
  16.322 -
  16.323 -    access_process_vm(target, address, buffer, length, write);
  16.324 -
  16.325 -    return rc;
  16.326 -}
  16.327 -
  16.328 -int
  16.329 -pdb_continue (struct task_struct *target)
  16.330 -{
  16.331 -    int rc = 0;
  16.332 -    unsigned long eflags;
  16.333 -
  16.334 -    eflags = _pdb_get_register(target, LINUX_EFL);
  16.335 -    eflags &= ~X86_EFLAGS_TF;
  16.336 -    _pdb_set_register(target, LINUX_EFL, eflags);
  16.337 -
  16.338 -    wake_up_process(target);
  16.339 -
  16.340 -    return rc;
  16.341 -}
  16.342 -
  16.343 -int
  16.344 -pdb_step (struct task_struct *target)
  16.345 -{
  16.346 -    int rc = 0;
  16.347 -    unsigned long eflags;
  16.348 -    bwcpoint_p bkpt;
  16.349 -    
  16.350 -    eflags = _pdb_get_register(target, LINUX_EFL);
  16.351 -    eflags |= X86_EFLAGS_TF;
  16.352 -    _pdb_set_register(target, LINUX_EFL, eflags);
  16.353 -
  16.354 -    _pdb_bwcpoint_alloc(bkpt);
  16.355 -    if ( bkpt == NULL )  return -1;
  16.356 -
  16.357 -    bkpt->process = target->pid;
  16.358 -    bkpt->address = 0;
  16.359 -    bkpt->type    = BWC_DEBUG;
  16.360 -    
  16.361 -    list_add_tail(&bkpt->list, &bwcpoint_list);
  16.362 -
  16.363 -    wake_up_process(target);
  16.364 -
  16.365 -    return rc;
  16.366 -}
  16.367 -
  16.368 -int
  16.369 -pdb_insert_memory_breakpoint (struct task_struct *target, 
  16.370 -                              unsigned long address, uint32_t length)
  16.371 -{
  16.372 -    int rc = 0;
  16.373 -    bwcpoint_p bkpt;
  16.374 -    uint8_t breakpoint_opcode = 0xcc;
  16.375 -
  16.376 -    printk("insert breakpoint %d:%lx len: %d\n", target->pid, address, length);
  16.377 -
  16.378 -    if ( length != 1 )
  16.379 -    {
  16.380 -        printk("error: breakpoint length should be 1\n");
  16.381 -        return -1;
  16.382 -    }
  16.383 -
  16.384 -    _pdb_bwcpoint_alloc(bkpt);
  16.385 -    if ( bkpt == NULL ) return -1;
  16.386 -
  16.387 -    bkpt->process = target->pid;
  16.388 -    bkpt->address = address;
  16.389 -    bkpt->type    = BWC_INT3;
  16.390 -
  16.391 -    pdb_access_memory(target, address, &bkpt->orig_bkpt, 1, PDB_MEM_READ);
  16.392 -    pdb_access_memory(target, address, &breakpoint_opcode, 1, PDB_MEM_WRITE);
  16.393 -    
  16.394 -    list_add_tail(&bkpt->list, &bwcpoint_list);
  16.395 -
  16.396 -    printk("breakpoint_set %d:%lx  OLD: 0x%x\n",
  16.397 -           target->pid, address, bkpt->orig_bkpt);
  16.398 -    pdb_bwc_print_list();
  16.399 -
  16.400 -    return rc;
  16.401 -}
  16.402 -
  16.403 -int
  16.404 -pdb_remove_memory_breakpoint (struct task_struct *target,
  16.405 -                              unsigned long address, uint32_t length)
  16.406 -{
  16.407 -    int rc = 0;
  16.408 -    bwcpoint_p bkpt = NULL;
  16.409 -
  16.410 -    printk ("remove breakpoint %d:%lx\n", target->pid, address);
  16.411 -
  16.412 -    struct list_head *entry;
  16.413 -    list_for_each(entry, &bwcpoint_list)
  16.414 -    {
  16.415 -        bkpt = list_entry(entry, bwcpoint_t, list);
  16.416 -        if ( target->pid == bkpt->process && 
  16.417 -             address == bkpt->address     &&
  16.418 -             bkpt->type == BWC_INT3 )
  16.419 -            break;
  16.420 -    }
  16.421 -    
  16.422 -    if (entry == &bwcpoint_list)
  16.423 -    {
  16.424 -        printk ("error: no breakpoint found\n");
  16.425 -        return -1;
  16.426 -    }
  16.427 -
  16.428 -    pdb_access_memory(target, address, &bkpt->orig_bkpt, 1, PDB_MEM_WRITE);
  16.429 -
  16.430 -    list_del(&bkpt->list);
  16.431 -    kfree(bkpt);
  16.432 -
  16.433 -    pdb_bwc_print_list();
  16.434 -
  16.435 -    return rc;
  16.436 -}
  16.437 -
  16.438 -#define PDB_PTE_UPDATE   1
  16.439 -#define PDB_PTE_RESTORE  2
  16.440 -
  16.441 -int
  16.442 -pdb_change_pte (struct task_struct *target, bwcpoint_p bwc, int mode)
  16.443 -{
  16.444 -    int rc = 0;
  16.445 -    pgd_t *pgd;
  16.446 -    pud_t *pud;
  16.447 -    pmd_t *pmd;
  16.448 -    pte_t *ptep;
  16.449 -
  16.450 -    pgd = pgd_offset(target->mm, bwc->address);
  16.451 -    if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))  return -1;
  16.452 -
  16.453 -    pud = pud_offset(pgd, bwc->address);
  16.454 -    if (pud_none(*pud) || unlikely(pud_bad(*pud))) return -2;
  16.455 -
  16.456 -    pmd = pmd_offset(pud, bwc->address);
  16.457 -    if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) return -3;
  16.458 -
  16.459 -    ptep = pte_offset_map(pmd, bwc->address);
  16.460 -    if (!ptep)  return -4;
  16.461 -
  16.462 -    switch ( mode )
  16.463 -    {
  16.464 -    case PDB_PTE_UPDATE:      /* added or removed a watchpoint.  update pte. */
  16.465 -    {
  16.466 -        pte_t new_pte;
  16.467 -
  16.468 -        if ( pte_val(bwc->parent->orig_pte) == 0 )    /* new watchpoint page */
  16.469 -        {
  16.470 -            bwc->parent->orig_pte = *ptep;
  16.471 -        }
  16.472 -
  16.473 -        new_pte = bwc->parent->orig_pte;
  16.474 -
  16.475 -        if ( !list_empty(&bwc->parent->watchpt_read_list)  || 
  16.476 -             !list_empty(&bwc->parent->watchpt_access_list) )
  16.477 -        {
  16.478 -            new_pte = pte_rdprotect(new_pte);
  16.479 -        }
  16.480 -
  16.481 -        if ( !list_empty(&bwc->parent->watchpt_write_list) ||
  16.482 -             !list_empty(&bwc->parent->watchpt_access_list) )
  16.483 -        {
  16.484 -            new_pte = pte_wrprotect(new_pte);
  16.485 -        }
  16.486 -        
  16.487 -        if ( pte_val(new_pte) != pte_val(*ptep) )
  16.488 -        {
  16.489 -            *ptep = new_pte;
  16.490 -            flush_tlb_mm(target->mm);
  16.491 -        }
  16.492 -        break;
  16.493 -    }
  16.494 -    case PDB_PTE_RESTORE :   /* suspend watchpoint by restoring original pte */
  16.495 -    {
  16.496 -        *ptep = bwc->parent->orig_pte;
  16.497 -        flush_tlb_mm(target->mm);
  16.498 -        break;
  16.499 -    }
  16.500 -    default :
  16.501 -    {
  16.502 -        printk("(linux) unknown mode %d %d\n", mode, __LINE__);
  16.503 -        break;
  16.504 -    }
  16.505 -    }
  16.506 -
  16.507 -    pte_unmap(ptep);                /* can i flush the tlb before pte_unmap? */
  16.508 -
  16.509 -    return rc;
  16.510 -}
  16.511 -
  16.512 -int
  16.513 -pdb_insert_watchpoint (struct task_struct *target, pdb_op_watchpt_p watchpt)
  16.514 -{
  16.515 -    int rc = 0;
  16.516 -
  16.517 -    bwcpoint_p bwc_watch;
  16.518 -    bwcpoint_p bwc_entry;
  16.519 -    struct list_head *ptr;
  16.520 -    unsigned long page = watchpt->address & PAGE_MASK;
  16.521 -    struct list_head *watchpoint_list;
  16.522 -    
  16.523 -    printk("insert watchpoint: %d %x %x\n", 
  16.524 -           watchpt->type, watchpt->address, watchpt->length);
  16.525 -
  16.526 -    list_for_each(ptr, &bwcpoint_list) /* find existing bwc page entry */
  16.527 -    {
  16.528 -        bwc_watch = list_entry(ptr, bwcpoint_t, list);
  16.529 -
  16.530 -        if (bwc_watch->address == page)  goto got_bwc_watch;
  16.531 -    }
  16.532 -
  16.533 -    _pdb_bwcpoint_alloc(bwc_watch);                  /* create new bwc:watch */
  16.534 -    if ( bwc_watch == NULL ) return -1;
  16.535 -
  16.536 -    bwc_watch->type    = BWC_WATCH;
  16.537 -    bwc_watch->process = target->pid;
  16.538 -    bwc_watch->address = page;
  16.539 -
  16.540 -    list_add_tail(&bwc_watch->list, &bwcpoint_list);
  16.541 -
  16.542 - got_bwc_watch:
  16.543 -
  16.544 -    switch (watchpt->type)
  16.545 -    {
  16.546 -    case BWC_WATCH_READ:
  16.547 -        watchpoint_list = &bwc_watch->watchpt_read_list; break;
  16.548 -    case BWC_WATCH_WRITE: 
  16.549 -        watchpoint_list = &bwc_watch->watchpt_write_list; break;
  16.550 -    case BWC_WATCH_ACCESS:
  16.551 -        watchpoint_list = &bwc_watch->watchpt_access_list; break;
  16.552 -    default:
  16.553 -        printk("unknown type %d\n", watchpt->type); return -2;
  16.554 -    }
  16.555 -
  16.556 -    _pdb_bwcpoint_alloc(bwc_entry);                  /* create new bwc:entry */
  16.557 -    if ( bwc_entry == NULL ) return -1;
  16.558 -
  16.559 -    bwc_entry->process = target->pid;
  16.560 -    bwc_entry->address = watchpt->address;
  16.561 -    bwc_entry->length  = watchpt->length;
  16.562 -    bwc_entry->type    = watchpt->type;
  16.563 -    bwc_entry->parent  = bwc_watch;
  16.564 -
  16.565 -    list_add_tail(&bwc_entry->list, watchpoint_list);
  16.566 -    pdb_change_pte(target, bwc_entry, PDB_PTE_UPDATE);
  16.567 -
  16.568 -    pdb_bwc_print_list();
  16.569 -
  16.570 -    return rc;
  16.571 -}
  16.572 -
  16.573 -int 
  16.574 -pdb_remove_watchpoint (struct task_struct *target, pdb_op_watchpt_p watchpt)
  16.575 -{
  16.576 -    int rc = 0;
  16.577 -    bwcpoint_p bwc_watch = (bwcpoint_p) NULL;
  16.578 -    bwcpoint_p bwc_entry = (bwcpoint_p) NULL;
  16.579 -    unsigned long page = watchpt->address & PAGE_MASK;
  16.580 -    struct list_head *ptr;
  16.581 -    struct list_head *watchpoint_list;
  16.582 -
  16.583 -    printk("remove watchpoint: %d %x %x\n", 
  16.584 -           watchpt->type, watchpt->address, watchpt->length);
  16.585 -
  16.586 -    list_for_each(ptr, &bwcpoint_list)                /* find bwc page entry */
  16.587 -    {
  16.588 -        bwc_watch = list_entry(ptr, bwcpoint_t, list);
  16.589 -        if (bwc_watch->address == page) break;
  16.590 -    }
  16.591 -
  16.592 -    if ( !bwc_watch )
  16.593 -    {
  16.594 -        printk("(linux) delete watchpoint: can't find bwc page 0x%08x\n",
  16.595 -               watchpt->address);
  16.596 -        return -1;
  16.597 -    }
  16.598 -
  16.599 -    switch (watchpt->type)
  16.600 -    {
  16.601 -    case BWC_WATCH_READ:
  16.602 -        watchpoint_list = &bwc_watch->watchpt_read_list; break;
  16.603 -    case BWC_WATCH_WRITE:
  16.604 -        watchpoint_list = &bwc_watch->watchpt_write_list; break;
  16.605 -    case BWC_WATCH_ACCESS:
  16.606 -        watchpoint_list = &bwc_watch->watchpt_access_list; break;
  16.607 -    default:
  16.608 -        printk("unknown type %d\n", watchpt->type); return -2;
  16.609 -    }
  16.610 -
  16.611 -    list_for_each(ptr, watchpoint_list)                   /* find watchpoint */
  16.612 -    {
  16.613 -        bwc_entry = list_entry(ptr, bwcpoint_t, list);
  16.614 -        if ( bwc_entry->address == watchpt->address &&
  16.615 -             bwc_entry->length  == watchpt->length ) break;
  16.616 -    }
  16.617 -
  16.618 -    if ( !bwc_entry )                           /* or ptr == watchpoint_list */
  16.619 -    {
  16.620 -        printk("(linux) delete watchpoint: can't find watchpoint 0x%08x\n",
  16.621 -               watchpt->address);
  16.622 -        return -1;
  16.623 -    }
  16.624 -    
  16.625 -    list_del(&bwc_entry->list);
  16.626 -    pdb_change_pte(target, bwc_entry, PDB_PTE_UPDATE);
  16.627 -    kfree(bwc_entry);
  16.628 -
  16.629 -
  16.630 -    if ( list_empty(&bwc_watch->watchpt_read_list)  &&
  16.631 -         list_empty(&bwc_watch->watchpt_write_list) &&
  16.632 -         list_empty(&bwc_watch->watchpt_access_list) )
  16.633 -    {
  16.634 -        list_del(&bwc_watch->list);
  16.635 -        kfree(bwc_watch);
  16.636 -    }
  16.637 -
  16.638 -    pdb_bwc_print_list();
  16.639 -
  16.640 -    return rc;
  16.641 -}
  16.642 -
  16.643 -
  16.644 -/***************************************************************/
  16.645 -
  16.646 -int
  16.647 -pdb_exceptions_notify (struct notifier_block *self, unsigned long val,
  16.648 -                       void *data)
  16.649 -{
  16.650 -    struct die_args *args = (struct die_args *)data;
  16.651 -
  16.652 -	switch (val) 
  16.653 -    {
  16.654 -	case DIE_DEBUG:
  16.655 -		if ( pdb_debug_fn(args->regs, args->trapnr, args->err) )
  16.656 -			return NOTIFY_STOP;
  16.657 -		break;
  16.658 -    case DIE_TRAP:
  16.659 -		if ( args->trapnr == 3 && pdb_int3_fn(args->regs, args->err) )
  16.660 -			return NOTIFY_STOP;
  16.661 -        break;
  16.662 -	case DIE_INT3:          /* without kprobes, we should never see DIE_INT3 */
  16.663 -		if ( pdb_int3_fn(args->regs, args->err) )
  16.664 -			return NOTIFY_STOP;
  16.665 -		break;
  16.666 -	case DIE_PAGE_FAULT:
  16.667 -		if ( pdb_page_fault_fn(args->regs, args->trapnr, args->err) )
  16.668 -			return NOTIFY_STOP;
  16.669 -		break;
  16.670 -	case DIE_GPF:
  16.671 -        printk("---------------GPF\n");
  16.672 -        break;
  16.673 -	default:
  16.674 -		break;
  16.675 -	}
  16.676 -
  16.677 -	return NOTIFY_DONE;
  16.678 -}
  16.679 -
  16.680 -
  16.681 -static int
  16.682 -pdb_debug_fn (struct pt_regs *regs, long error_code, 
  16.683 -                   unsigned int condition)
  16.684 -{
  16.685 -    pdb_response_t resp;
  16.686 -    bwcpoint_p bkpt = NULL;
  16.687 -    struct list_head *entry;
  16.688 -
  16.689 -    printk("pdb_debug_fn\n");
  16.690 -
  16.691 -    list_for_each(entry, &bwcpoint_list)
  16.692 -    {
  16.693 -        bkpt = list_entry(entry, bwcpoint_t, list);
  16.694 -        if ( current->pid == bkpt->process && 
  16.695 -             (bkpt->type == BWC_DEBUG ||                      /* single step */
  16.696 -              bkpt->type == BWC_WATCH_STEP))  /* single step over watchpoint */
  16.697 -            break;
  16.698 -    }
  16.699 -    
  16.700 -    if (entry == &bwcpoint_list)
  16.701 -    {
  16.702 -        printk("not my debug  0x%x 0x%lx\n", current->pid, regs->eip);
  16.703 -        return 0;
  16.704 -    }
  16.705 -
  16.706 -    pdb_suspend(current);
  16.707 -
  16.708 -    printk("(pdb) %s  pid: %d, eip: 0x%08lx\n", 
  16.709 -           bkpt->type == BWC_DEBUG ? "debug" : "watch-step",
  16.710 -           current->pid, regs->eip);
  16.711 -
  16.712 -    regs->eflags &= ~X86_EFLAGS_TF;
  16.713 -	set_tsk_thread_flag(current, TIF_SINGLESTEP);
  16.714 -
  16.715 -    switch (bkpt->type)
  16.716 -    {
  16.717 -    case BWC_DEBUG:
  16.718 -        resp.operation = PDB_OPCODE_STEP;
  16.719 -        break;
  16.720 -    case BWC_WATCH_STEP:
  16.721 -    {
  16.722 -        struct list_head *watchpoint_list;
  16.723 -        bwcpoint_p watch_page = bkpt->watchpoint->parent;
  16.724 -
  16.725 -        switch (bkpt->watchpoint->type)
  16.726 -        {
  16.727 -        case BWC_WATCH_READ:
  16.728 -            watchpoint_list = &watch_page->watchpt_read_list; break;
  16.729 -        case BWC_WATCH_WRITE: 
  16.730 -            watchpoint_list = &watch_page->watchpt_write_list; break;
  16.731 -        case BWC_WATCH_ACCESS:
  16.732 -            watchpoint_list = &watch_page->watchpt_access_list; break;
  16.733 -        default:
  16.734 -            printk("unknown type %d\n", bkpt->watchpoint->type); return 0;
  16.735 -        }
  16.736 -
  16.737 -        resp.operation = PDB_OPCODE_WATCHPOINT;
  16.738 -        list_del_init(&bkpt->watchpoint->list);
  16.739 -        list_add_tail(&bkpt->watchpoint->list, watchpoint_list);
  16.740 -        pdb_change_pte(current, bkpt->watchpoint, PDB_PTE_UPDATE);
  16.741 -        pdb_bwc_print_list();
  16.742 -        break;
  16.743 -    }
  16.744 -    default:
  16.745 -        printk("unknown breakpoint type %d %d\n", __LINE__, bkpt->type);
  16.746 -        return 0;
  16.747 -    }
  16.748 -
  16.749 -    resp.process   = current->pid;
  16.750 -    resp.status    = PDB_RESPONSE_OKAY;
  16.751 -
  16.752 -    pdb_send_response(&resp);
  16.753 -
  16.754 -    list_del(&bkpt->list);
  16.755 -    kfree(bkpt);
  16.756 -
  16.757 -    return 1;
  16.758 -}
  16.759 -
  16.760 -
  16.761 -static int
  16.762 -pdb_int3_fn (struct pt_regs *regs, long error_code)
  16.763 -{
  16.764 -    pdb_response_t resp;
  16.765 -    bwcpoint_p bkpt = NULL;
  16.766 -    unsigned long address = regs->eip - 1;
  16.767 -
  16.768 -    struct list_head *entry;
  16.769 -    list_for_each(entry, &bwcpoint_list)
  16.770 -    {
  16.771 -        bkpt = list_entry(entry, bwcpoint_t, list);
  16.772 -        if ( current->pid == bkpt->process && 
  16.773 -             address == bkpt->address      &&
  16.774 -             bkpt->type == BWC_INT3 )
  16.775 -            break;
  16.776 -    }
  16.777 -    
  16.778 -    if (entry == &bwcpoint_list)
  16.779 -    {
  16.780 -        printk("not my int3 bkpt  0x%x 0x%lx\n", current->pid, address);
  16.781 -        return 0;
  16.782 -    }
  16.783 -
  16.784 -    printk("(pdb) int3  pid: %d, eip: 0x%08lx\n", current->pid, address);
  16.785 -
  16.786 -    pdb_suspend(current);
  16.787 -
  16.788 -    resp.operation = PDB_OPCODE_CONTINUE;
  16.789 -    resp.process   = current->pid;
  16.790 -    resp.status    = PDB_RESPONSE_OKAY;
  16.791 -
  16.792 -    pdb_send_response(&resp);
  16.793 -
  16.794 -    return 1;
  16.795 -}
  16.796 -
  16.797 -static int
  16.798 -pdb_page_fault_fn (struct pt_regs *regs, long error_code, 
  16.799 -                   unsigned int condition)
  16.800 -{
  16.801 -    unsigned long cr2;
  16.802 -    unsigned long cr3;
  16.803 -    bwcpoint_p bwc;
  16.804 -    bwcpoint_p watchpt;
  16.805 -    bwcpoint_p bkpt;
  16.806 -
  16.807 -    __asm__ __volatile__ ("movl %%cr3,%0" : "=r" (cr3) : );
  16.808 -    __asm__ __volatile__ ("movl %%cr2,%0" : "=r" (cr2) : );
  16.809 -
  16.810 -    bwc = pdb_search_watchpoint(current->pid, cr2);
  16.811 -    if ( !bwc )
  16.812 -    {
  16.813 -        return 0;                                                /* not mine */
  16.814 -    }
  16.815 -
  16.816 -    printk("page_fault cr2:%08lx err:%lx eip:%08lx\n", 
  16.817 -           cr2, error_code, regs->eip);
  16.818 -
  16.819 -    /* disable the watchpoint */
  16.820 -    watchpt = bwc->watchpoint;
  16.821 -    list_del_init(&bwc->list);
  16.822 -    list_add_tail(&bwc->list, &bwc->parent->watchpt_disabled_list);
  16.823 -    pdb_change_pte(current, bwc, PDB_PTE_RESTORE);
  16.824 -
  16.825 -    /* single step the faulting instruction */
  16.826 -    regs->eflags |= X86_EFLAGS_TF;
  16.827 -
  16.828 -    /* create a bwcpoint entry so we know what to do once we regain control */
  16.829 -    _pdb_bwcpoint_alloc(bkpt);
  16.830 -    if ( bkpt == NULL )  return -1;
  16.831 -
  16.832 -    bkpt->process    = current->pid;
  16.833 -    bkpt->address    = 0;
  16.834 -    bkpt->type       = BWC_WATCH_STEP;
  16.835 -    bkpt->watchpoint = bwc;
  16.836 -
  16.837 -    /* add to head so we see it first the next time we break */
  16.838 -    list_add(&bkpt->list, &bwcpoint_list);                
  16.839 -
  16.840 -    pdb_bwc_print_list();
  16.841 -    return 1;
  16.842 -}
  16.843 -
  16.844 -
  16.845 -/*
  16.846 - * Local variables:
  16.847 - * mode: C
  16.848 - * c-set-style: "BSD"
  16.849 - * c-basic-offset: 4
  16.850 - * tab-width: 4
  16.851 - * indent-tabs-mode: nil
  16.852 - * End:
  16.853 - */
  16.854 -
    17.1 --- a/tools/debugger/pdb/linux-2.6-module/module.c	Fri Sep 29 11:11:49 2006 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,337 +0,0 @@
    17.4 -
    17.5 -/*
    17.6 - * module.c
    17.7 - *
    17.8 - * Handles initial registration with pdb when the pdb module starts up
    17.9 - * and cleanup when the module goes away (sortof :)
   17.10 - * Also receives each request from pdb in domain 0 and dispatches to the
   17.11 - * appropriate debugger function.
   17.12 - */
   17.13 -
   17.14 -#include <linux/module.h>
   17.15 -#include <linux/interrupt.h>
   17.16 -
   17.17 -#include <asm-i386/kdebug.h>
   17.18 -
   17.19 -#include <xen/evtchn.h>
   17.20 -#include <xen/ctrl_if.h>
   17.21 -#include <xen/hypervisor.h>
   17.22 -#include <xen/interface/io/domain_controller.h>
   17.23 -#include <xen/interface/xen.h>
   17.24 -
   17.25 -#include <xen/interface/io/ring.h>
   17.26 -
   17.27 -#include "pdb_module.h"
   17.28 -#include "pdb_debug.h"
   17.29 -
   17.30 -#define PDB_RING_SIZE __RING_SIZE((pdb_sring_t *)0, PAGE_SIZE)
   17.31 -
   17.32 -static pdb_back_ring_t pdb_ring;
   17.33 -static unsigned int    pdb_evtchn;
   17.34 -static unsigned int    pdb_irq;
   17.35 -static unsigned int    pdb_domain;
   17.36 -
   17.37 -/* work queue */
   17.38 -static void pdb_work_handler(void *unused);
   17.39 -static DECLARE_WORK(pdb_deferred_work, pdb_work_handler, NULL);
   17.40 -
   17.41 -/*
   17.42 - * send response to a pdb request
   17.43 - */
   17.44 -void
   17.45 -pdb_send_response (pdb_response_t *response)
   17.46 -{
   17.47 -    pdb_response_t *resp;
   17.48 -
   17.49 -    resp = RING_GET_RESPONSE(&pdb_ring, pdb_ring.rsp_prod_pvt);
   17.50 -
   17.51 -    memcpy(resp, response, sizeof(pdb_response_t));
   17.52 -    resp->domain = pdb_domain;
   17.53 -    
   17.54 -    wmb();                 /* Ensure other side can see the response fields. */
   17.55 -    pdb_ring.rsp_prod_pvt++;
   17.56 -    RING_PUSH_RESPONSES(&pdb_ring);
   17.57 -    notify_via_evtchn(pdb_evtchn);
   17.58 -    return;
   17.59 -}
   17.60 -
   17.61 -/*
   17.62 - * handle a debug command from the front end
   17.63 - */
   17.64 -static void
   17.65 -pdb_process_request (pdb_request_t *request)
   17.66 -{
   17.67 -    pdb_response_t resp;
   17.68 -    struct task_struct *target;
   17.69 -
   17.70 -    read_lock(&tasklist_lock);
   17.71 -    target = find_task_by_pid(request->process);
   17.72 -    if (target)
   17.73 -        get_task_struct(target);
   17.74 -    read_unlock(&tasklist_lock);
   17.75 -
   17.76 -    resp.operation = request->operation;
   17.77 -    resp.process   = request->process;
   17.78 -
   17.79 -    if (!target)
   17.80 -    {
   17.81 -        printk ("(linux) target not found 0x%x\n", request->process);
   17.82 -        resp.status = PDB_RESPONSE_ERROR;
   17.83 -        goto response;
   17.84 -    }
   17.85 -
   17.86 -    switch (request->operation)
   17.87 -    {
   17.88 -    case PDB_OPCODE_PAUSE :
   17.89 -        pdb_suspend(target);
   17.90 -        resp.status = PDB_RESPONSE_OKAY;
   17.91 -        break;
   17.92 -    case PDB_OPCODE_ATTACH :
   17.93 -        pdb_suspend(target);
   17.94 -        pdb_domain = request->u.attach.domain;
   17.95 -        printk("(linux) attach  dom:0x%x pid:0x%x\n",
   17.96 -               pdb_domain, request->process);
   17.97 -        resp.status = PDB_RESPONSE_OKAY;
   17.98 -        break;
   17.99 -    case PDB_OPCODE_DETACH :
  17.100 -        pdb_resume(target);
  17.101 -        printk("(linux) detach 0x%x\n", request->process);
  17.102 -        resp.status = PDB_RESPONSE_OKAY;
  17.103 -        break;
  17.104 -    case PDB_OPCODE_RD_REG :
  17.105 -        resp.u.rd_reg.reg = request->u.rd_reg.reg;
  17.106 -        pdb_read_register(target, &resp.u.rd_reg);
  17.107 -        resp.status = PDB_RESPONSE_OKAY;
  17.108 -        break;
  17.109 -    case PDB_OPCODE_RD_REGS :
  17.110 -        pdb_read_registers(target, &resp.u.rd_regs);
  17.111 -        resp.status = PDB_RESPONSE_OKAY;
  17.112 -        break;
  17.113 -    case PDB_OPCODE_WR_REG :
  17.114 -        pdb_write_register(target, &request->u.wr_reg);
  17.115 -        resp.status = PDB_RESPONSE_OKAY;
  17.116 -        break;
  17.117 -    case PDB_OPCODE_RD_MEM :
  17.118 -        pdb_access_memory(target, request->u.rd_mem.address,
  17.119 -                          &resp.u.rd_mem.data, request->u.rd_mem.length, 
  17.120 -                          PDB_MEM_READ);
  17.121 -        resp.u.rd_mem.address = request->u.rd_mem.address;
  17.122 -        resp.u.rd_mem.length  = request->u.rd_mem.length;
  17.123 -        resp.status = PDB_RESPONSE_OKAY;
  17.124 -        break;
  17.125 -    case PDB_OPCODE_WR_MEM :
  17.126 -        pdb_access_memory(target, request->u.wr_mem.address,
  17.127 -                         &request->u.wr_mem.data, request->u.wr_mem.length, 
  17.128 -                          PDB_MEM_WRITE);
  17.129 -        resp.status = PDB_RESPONSE_OKAY;
  17.130 -        break;
  17.131 -    case PDB_OPCODE_CONTINUE :
  17.132 -        pdb_continue(target);
  17.133 -        goto no_response;
  17.134 -        break;
  17.135 -    case PDB_OPCODE_STEP :
  17.136 -        pdb_step(target);
  17.137 -        resp.status = PDB_RESPONSE_OKAY;
  17.138 -        goto no_response;
  17.139 -        break;
  17.140 -    case PDB_OPCODE_SET_BKPT :
  17.141 -        pdb_insert_memory_breakpoint(target, request->u.bkpt.address,
  17.142 -                                     request->u.bkpt.length);
  17.143 -        resp.status = PDB_RESPONSE_OKAY;
  17.144 -        break;
  17.145 -    case PDB_OPCODE_CLR_BKPT :
  17.146 -        pdb_remove_memory_breakpoint(target, request->u.bkpt.address,
  17.147 -                                     request->u.bkpt.length);
  17.148 -        resp.status = PDB_RESPONSE_OKAY;
  17.149 -        break;
  17.150 -    case PDB_OPCODE_SET_WATCHPT :
  17.151 -        pdb_insert_watchpoint(target, &request->u.watchpt);
  17.152 -        resp.status = PDB_RESPONSE_OKAY;
  17.153 -        break;
  17.154 -    case PDB_OPCODE_CLR_WATCHPT :
  17.155 -        pdb_remove_watchpoint(target, &request->u.watchpt);
  17.156 -        resp.status = PDB_RESPONSE_OKAY;
  17.157 -        break;
  17.158 -    default:
  17.159 -        printk("(pdb) unknown request operation %d\n", request->operation);
  17.160 -        resp.status = PDB_RESPONSE_ERROR;
  17.161 -    }
  17.162 -
  17.163 - response:        
  17.164 -    pdb_send_response (&resp);
  17.165 -
  17.166 - no_response:
  17.167 -    return;
  17.168 -}
  17.169 -
  17.170 -/*
  17.171 - * work queue
  17.172 - */
  17.173 -static void
  17.174 -pdb_work_handler (void *unused)
  17.175 -{
  17.176 -    pdb_request_t *req;
  17.177 -    RING_IDX i, rp;
  17.178 -
  17.179 -    rp = pdb_ring.sring->req_prod;
  17.180 -    rmb();
  17.181 -
  17.182 -    for ( i = pdb_ring.req_cons; 
  17.183 -          (i != rp) && !RING_REQUEST_CONS_OVERFLOW(&pdb_ring, i);
  17.184 -          i++ )
  17.185 -    {
  17.186 -        req = RING_GET_REQUEST(&pdb_ring, i);
  17.187 -        pdb_process_request(req);
  17.188 -
  17.189 -    }
  17.190 -    pdb_ring.req_cons = i;
  17.191 -}
  17.192 -
  17.193 -/*
  17.194 - * receive a pdb request
  17.195 - */
  17.196 -static irqreturn_t
  17.197 -pdb_interrupt (int irq, void *dev_id, struct pt_regs *ptregs)
  17.198 -{
  17.199 -    schedule_work(&pdb_deferred_work);
  17.200 -
  17.201 -    return IRQ_HANDLED;
  17.202 -}
  17.203 -
  17.204 -static void
  17.205 -pdb_send_connection_status(int status, unsigned long ring)
  17.206 -{
  17.207 -    ctrl_msg_t cmsg = 
  17.208 -    {
  17.209 -        .type = CMSG_DEBUG,
  17.210 -        .subtype = CMSG_DEBUG_CONNECTION_STATUS,
  17.211 -        .length  = sizeof(pdb_connection_t),
  17.212 -    };
  17.213 -    pdb_connection_t *conn = (pdb_connection_t *)cmsg.msg;
  17.214 -
  17.215 -    conn->status = status;
  17.216 -    conn->ring = ring;
  17.217 -    conn->evtchn = 0;
  17.218 -
  17.219 -    ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
  17.220 -}
  17.221 -
  17.222 -
  17.223 -/*
  17.224 - * this is called each time a message is received on the control channel
  17.225 - */
  17.226 -static void
  17.227 -pdb_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
  17.228 -{
  17.229 -    switch (msg->subtype)
  17.230 -    {
  17.231 -    case CMSG_DEBUG_CONNECTION_STATUS:
  17.232 -        /* initialize event channel created by the pdb server */
  17.233 -
  17.234 -        pdb_evtchn = ((pdb_connection_p) msg->msg)->evtchn;
  17.235 -        pdb_irq = bind_evtchn_to_irq(pdb_evtchn);
  17.236 -
  17.237 -        if ( request_irq(pdb_irq, pdb_interrupt, 
  17.238 -                         SA_SAMPLE_RANDOM, "pdb", NULL) )
  17.239 -        {
  17.240 -            printk("(pdb) request irq failed: %d %d\n", pdb_evtchn, pdb_irq);
  17.241 -        }
  17.242 -        break;
  17.243 -
  17.244 -    default:
  17.245 -        printk ("(pdb) unknown xcs control message: %d\n", msg->subtype);
  17.246 -        break;
  17.247 -    }
  17.248 -
  17.249 -    return;
  17.250 -}
  17.251 -
  17.252 -
  17.253 -/********************************************************************/
  17.254 -
  17.255 -static struct notifier_block pdb_exceptions_nb =
  17.256 -{
  17.257 -    .notifier_call = pdb_exceptions_notify,
  17.258 -    .priority = 0x1                                          /* low priority */
  17.259 -};
  17.260 -
  17.261 -
  17.262 -static int __init 
  17.263 -pdb_initialize (void)
  17.264 -{
  17.265 -    int err;
  17.266 -    pdb_sring_t *sring;
  17.267 -
  17.268 -    printk("----\npdb initialize   %s %s\n", __DATE__, __TIME__);
  17.269 -
  17.270 -    /*
  17.271 -    if ( xen_start_info.flags & SIF_INITDOMAIN )
  17.272 -        return 1;
  17.273 -    */
  17.274 -
  17.275 -    pdb_evtchn = 0;
  17.276 -    pdb_irq    = 0;
  17.277 -    pdb_domain = 0;
  17.278 -
  17.279 -    (void)ctrl_if_register_receiver(CMSG_DEBUG, pdb_ctrlif_rx,
  17.280 -                                    CALLBACK_IN_BLOCKING_CONTEXT);
  17.281 -
  17.282 -    /* rings */
  17.283 -    sring = (pdb_sring_t *)__get_free_page(GFP_KERNEL);
  17.284 -    SHARED_RING_INIT(sring);
  17.285 -    BACK_RING_INIT(&pdb_ring, sring, PAGE_SIZE);
  17.286 - 
  17.287 -    /* notify pdb in dom 0 */
  17.288 -    pdb_send_connection_status(PDB_CONNECTION_STATUS_UP, 
  17.289 -                               virt_to_machine(pdb_ring.sring) >> PAGE_SHIFT);
  17.290 -
  17.291 -    /* handler for int1 & int3 */
  17.292 -    err = register_die_notifier(&pdb_exceptions_nb);
  17.293 -
  17.294 -    return err;
  17.295 -}
  17.296 -
  17.297 -static void __exit
  17.298 -pdb_terminate(void)
  17.299 -{
  17.300 -    int err = 0;
  17.301 -
  17.302 -    printk("pdb cleanup\n");
  17.303 -
  17.304 -    (void)ctrl_if_unregister_receiver(CMSG_DEBUG, pdb_ctrlif_rx);
  17.305 -
  17.306 -    if (pdb_irq)
  17.307 -    {
  17.308 -        free_irq(pdb_irq, NULL);
  17.309 -        pdb_irq = 0;
  17.310 -    }
  17.311 -
  17.312 -    if (pdb_evtchn)
  17.313 -    {
  17.314 -        unbind_evtchn_from_irq(pdb_evtchn); 
  17.315 -        pdb_evtchn = 0;
  17.316 -    }
  17.317 -
  17.318 -    pdb_send_connection_status(PDB_CONNECTION_STATUS_DOWN, 0);
  17.319 -
  17.320 -    /* handler for int1 & int3 */
  17.321 -    err = unregister_die_notifier(&pdb_exceptions_nb);
  17.322 -
  17.323 -	return;
  17.324 -}
  17.325 -
  17.326 -
  17.327 -module_init(pdb_initialize);
  17.328 -module_exit(pdb_terminate);
  17.329 -
  17.330 -
  17.331 -/*
  17.332 - * Local variables:
  17.333 - * mode: C
  17.334 - * c-set-style: "BSD"
  17.335 - * c-basic-offset: 4
  17.336 - * tab-width: 4
  17.337 - * indent-tabs-mode: nil
  17.338 - * End:
  17.339 - */
  17.340 -
    18.1 --- a/tools/debugger/pdb/linux-2.6-module/pdb_debug.h	Fri Sep 29 11:11:49 2006 +0100
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,47 +0,0 @@
    18.4 -
    18.5 -#ifndef __PDB_DEBUG_H_
    18.6 -#define __PDB_DEBUG_H_
    18.7 -
    18.8 -/* debugger.c */
    18.9 -void pdb_initialize_bwcpoint (void);
   18.10 -int pdb_suspend (struct task_struct *target);
   18.11 -int pdb_resume (struct task_struct *target);
   18.12 -int pdb_read_register (struct task_struct *target, pdb_op_rd_reg_p op);
   18.13 -int pdb_read_registers (struct task_struct *target, pdb_op_rd_regs_p op);
   18.14 -int pdb_write_register (struct task_struct *target, pdb_op_wr_reg_p op);
   18.15 -int pdb_read_memory (struct task_struct *target, pdb_op_rd_mem_req_p req, 
   18.16 -                     pdb_op_rd_mem_resp_p resp);
   18.17 -int pdb_write_memory (struct task_struct *target, pdb_op_wr_mem_p op);
   18.18 -int pdb_access_memory (struct task_struct *target, unsigned long address, 
   18.19 -                       void *buffer, int length, int write);
   18.20 -int pdb_continue (struct task_struct *target);
   18.21 -int pdb_step (struct task_struct *target);
   18.22 -
   18.23 -int pdb_insert_memory_breakpoint (struct task_struct *target, 
   18.24 -                                  unsigned long address, uint32_t length);
   18.25 -int pdb_remove_memory_breakpoint (struct task_struct *target,
   18.26 -                                  unsigned long address, uint32_t length);
   18.27 -int pdb_insert_watchpoint (struct task_struct *target,
   18.28 -                           pdb_op_watchpt_p watchpt);
   18.29 -int pdb_remove_watchpoint (struct task_struct *target,
   18.30 -                           pdb_op_watchpt_p watchpt);
   18.31 -
   18.32 -int pdb_exceptions_notify (struct notifier_block *self, unsigned long val,
   18.33 -                           void *data);
   18.34 -
   18.35 -/* module.c */
   18.36 -void pdb_send_response (pdb_response_t *response);
   18.37 -
   18.38 -#endif
   18.39 -
   18.40 -
   18.41 -/*
   18.42 - * Local variables:
   18.43 - * mode: C
   18.44 - * c-set-style: "BSD"
   18.45 - * c-basic-offset: 4
   18.46 - * tab-width: 4
   18.47 - * indent-tabs-mode: nil
   18.48 - * End:
   18.49 - */
   18.50 -
    19.1 --- a/tools/debugger/pdb/linux-2.6-module/pdb_module.h	Fri Sep 29 11:11:49 2006 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,142 +0,0 @@
    19.4 -
    19.5 -#ifndef __PDB_MODULE_H_
    19.6 -#define __PDB_MODULE_H_
    19.7 -
    19.8 -#include "../pdb_caml_xen.h"
    19.9 -
   19.10 -#define PDB_OPCODE_PAUSE  1
   19.11 -
   19.12 -#define PDB_OPCODE_ATTACH 2
   19.13 -typedef struct pdb_op_attach
   19.14 -{
   19.15 -    uint32_t  domain;
   19.16 -} pdb_op_attach_t, *pdb_op_attach_p;
   19.17 -
   19.18 -#define PDB_OPCODE_DETACH 3
   19.19 -
   19.20 -#define PDB_OPCODE_RD_REG 4
   19.21 -typedef struct pdb_op_rd_reg
   19.22 -{
   19.23 -    uint32_t reg;
   19.24 -    uint32_t value;
   19.25 -} pdb_op_rd_reg_t, *pdb_op_rd_reg_p;
   19.26 -
   19.27 -#define PDB_OPCODE_RD_REGS 5
   19.28 -typedef struct pdb_op_rd_regs
   19.29 -{
   19.30 -    uint32_t reg[GDB_REGISTER_FRAME_SIZE];
   19.31 -} pdb_op_rd_regs_t, *pdb_op_rd_regs_p;
   19.32 -
   19.33 -#define PDB_OPCODE_WR_REG 6
   19.34 -typedef struct pdb_op_wr_reg
   19.35 -{
   19.36 -    uint32_t reg;
   19.37 -    uint32_t value;
   19.38 -} pdb_op_wr_reg_t, *pdb_op_wr_reg_p;
   19.39 -
   19.40 -#define PDB_OPCODE_RD_MEM 7
   19.41 -typedef struct pdb_op_rd_mem_req
   19.42 -{
   19.43 -    uint32_t address;
   19.44 -    uint32_t length;
   19.45 -} pdb_op_rd_mem_req_t, *pdb_op_rd_mem_req_p;
   19.46 -
   19.47 -typedef struct pdb_op_rd_mem_resp
   19.48 -{
   19.49 -    uint32_t address;
   19.50 -    uint32_t length;
   19.51 -    uint8_t  data[1024];
   19.52 -} pdb_op_rd_mem_resp_t, *pdb_op_rd_mem_resp_p;
   19.53 -
   19.54 -#define PDB_OPCODE_WR_MEM 8
   19.55 -typedef struct pdb_op_wr_mem
   19.56 -{
   19.57 -    uint32_t address;
   19.58 -    uint32_t length;
   19.59 -    uint8_t  data[1024];                                             /* arbitrary */
   19.60 -} pdb_op_wr_mem_t, *pdb_op_wr_mem_p;
   19.61 -
   19.62 -#define PDB_OPCODE_CONTINUE 9
   19.63 -#define PDB_OPCODE_STEP     10
   19.64 -
   19.65 -#define PDB_OPCODE_SET_BKPT 11
   19.66 -#define PDB_OPCODE_CLR_BKPT 12
   19.67 -typedef struct pdb_op_bkpt
   19.68 -{
   19.69 -    uint32_t address;
   19.70 -    uint32_t length;
   19.71 -} pdb_op_bkpt_t, *pdb_op_bkpt_p;
   19.72 -
   19.73 -#define PDB_OPCODE_SET_WATCHPT 13
   19.74 -#define PDB_OPCODE_CLR_WATCHPT 14
   19.75 -#define PDB_OPCODE_WATCHPOINT  15
   19.76 -typedef struct pdb_op_watchpt
   19.77 -{
   19.78 -#define BWC_DEBUG 1
   19.79 -#define BWC_INT3  3
   19.80 -#define BWC_WATCH        100                         /* pdb: watchpoint page */
   19.81 -#define BWC_WATCH_STEP   101                  /* pdb: watchpoint single step */
   19.82 -#define BWC_WATCH_WRITE  102
   19.83 -#define BWC_WATCH_READ   103
   19.84 -#define BWC_WATCH_ACCESS 104
   19.85 -    uint32_t type;
   19.86 -    uint32_t address;
   19.87 -    uint32_t length;
   19.88 -} pdb_op_watchpt_t, *pdb_op_watchpt_p;
   19.89 -
   19.90 -
   19.91 -typedef struct 
   19.92 -{
   19.93 -    uint8_t   operation;       /* PDB_OPCODE_???      */
   19.94 -    uint32_t  process;
   19.95 -    union
   19.96 -    {
   19.97 -        pdb_op_attach_t     attach;
   19.98 -        pdb_op_rd_reg_t     rd_reg;
   19.99 -        pdb_op_wr_reg_t     wr_reg;
  19.100 -        pdb_op_rd_mem_req_t rd_mem;
  19.101 -        pdb_op_wr_mem_t     wr_mem;
  19.102 -        pdb_op_bkpt_t       bkpt;
  19.103 -        pdb_op_watchpt_t    watchpt;
  19.104 -    } u;
  19.105 -} pdb_request_t, *pdb_request_p;
  19.106 -
  19.107 - 
  19.108 -
  19.109 -#define PDB_RESPONSE_OKAY   0
  19.110 -#define PDB_RESPONSE_ERROR -1
  19.111 -
  19.112 -typedef struct {
  19.113 -    uint8_t  operation;       /* copied from request */
  19.114 -    uint32_t domain;          
  19.115 -    uint32_t process;
  19.116 -    int16_t  status;          /* PDB_RESPONSE_???    */
  19.117 -    union
  19.118 -    {
  19.119 -        pdb_op_rd_reg_t      rd_reg;
  19.120 -        pdb_op_rd_regs_t     rd_regs;
  19.121 -        pdb_op_rd_mem_resp_t rd_mem;
  19.122 -    } u;
  19.123 -} pdb_response_t, *pdb_response_p;
  19.124 -
  19.125 -
  19.126 -DEFINE_RING_TYPES(pdb, pdb_request_t, pdb_response_t);
  19.127 -
  19.128 -
  19.129 -/* from access_process_vm */
  19.130 -#define PDB_MEM_READ  0
  19.131 -#define PDB_MEM_WRITE 1
  19.132 -
  19.133 -#endif
  19.134 -
  19.135 -
  19.136 -/*
  19.137 - * Local variables:
  19.138 - * mode: C
  19.139 - * c-set-style: "BSD"
  19.140 - * c-basic-offset: 4
  19.141 - * tab-width: 4
  19.142 - * indent-tabs-mode: nil
  19.143 - * End:
  19.144 - */
  19.145 -
    20.1 --- a/tools/debugger/pdb/linux-2.6-patches/Makefile	Fri Sep 29 11:11:49 2006 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,11 +0,0 @@
    20.4 -XEN_ROOT   = ../../../..
    20.5 -LINUX_DIR  = linux-2.6.12-xenU
    20.6 -KDIR       = $(XEN_ROOT)/$(LINUX_DIR)
    20.7 -PATCH_DIR  = $(CURDIR)
    20.8 -
    20.9 -.PHONY: patches 
   20.10 -patches : patches-done
   20.11 -
   20.12 -patches-done :
   20.13 -	( for i in *.patch ; do ( cd $(KDIR) ; patch -p1 < $(PATCH_DIR)/$$i || exit 1 ) ; done )
   20.14 -	touch $@
    21.1 --- a/tools/debugger/pdb/linux-2.6-patches/i386_ksyms.patch	Fri Sep 29 11:11:49 2006 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,19 +0,0 @@
    21.4 -diff -u linux-2.6.12/arch/xen/i386/kernel/i386_ksyms.c linux-2.6.12-pdb/arch/xen/i386/kernel/i386_ksyms.c
    21.5 ---- linux-2.6.12/arch/xen/i386/kernel/i386_ksyms.c	2005-07-31 22:36:50.000000000 +0100
    21.6 -+++ linux-2.6.12-pdb/arch/xen/i386/kernel/i386_ksyms.c	2005-08-01 10:57:31.000000000 +0100
    21.7 -@@ -151,6 +151,7 @@
    21.8 - /* TLB flushing */
    21.9 - EXPORT_SYMBOL(flush_tlb_page);
   21.10 - #endif
   21.11 -+EXPORT_SYMBOL(flush_tlb_mm);
   21.12 - 
   21.13 - #ifdef CONFIG_X86_IO_APIC
   21.14 - EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
   21.15 -@@ -172,6 +173,7 @@
   21.16 - EXPORT_SYMBOL_GPL(unset_nmi_callback);
   21.17 - 
   21.18 - EXPORT_SYMBOL(register_die_notifier);
   21.19 -+EXPORT_SYMBOL(unregister_die_notifier);
   21.20 - #ifdef CONFIG_HAVE_DEC_LOCK
   21.21 - EXPORT_SYMBOL(_atomic_dec_and_lock);
   21.22 - #endif
    22.1 --- a/tools/debugger/pdb/linux-2.6-patches/kdebug.patch	Fri Sep 29 11:11:49 2006 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,11 +0,0 @@
    22.4 -diff -u linux-2.6.12/include/asm-i386/kdebug.h linux-2.6.12-pdb/include/asm-i386/kdebug.h
    22.5 ---- linux-2.6.12/include/asm-i386/kdebug.h	2005-06-17 20:48:29.000000000 +0100
    22.6 -+++ linux-2.6.12-pdb/include/asm-i386/kdebug.h	2005-08-01 11:11:53.000000000 +0100
    22.7 -@@ -21,6 +21,7 @@
    22.8 -    If you really want to do it first unregister - then synchronize_kernel - then free.
    22.9 -   */
   22.10 - int register_die_notifier(struct notifier_block *nb);
   22.11 -+int unregister_die_notifier(struct notifier_block *nb);
   22.12 - extern struct notifier_block *i386die_chain;
   22.13 - 
   22.14 - 
    23.1 --- a/tools/debugger/pdb/linux-2.6-patches/makefile.patch	Fri Sep 29 11:11:49 2006 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,12 +0,0 @@
    23.4 -diff -Naur linux-2.6.12/Makefile linux-2.6.12-pdb/Makefile
    23.5 ---- linux-2.6.12/Makefile	2005-08-01 01:21:21.000000000 +0100
    23.6 -+++ linux-2.6.12-pdb/Makefile	2005-08-01 10:28:10.000000000 +0100
    23.7 -@@ -508,7 +508,7 @@
    23.8 - ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
    23.9 - CFLAGS		+= -Os
   23.10 - else
   23.11 --CFLAGS		+= -O2
   23.12 -+CFLAGS		+= -O
   23.13 - endif
   23.14 - 
   23.15 - #Add align options if CONFIG_CC_* is not equal to 0
    24.1 --- a/tools/debugger/pdb/linux-2.6-patches/ptrace.patch	Fri Sep 29 11:11:49 2006 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,11 +0,0 @@
    24.4 -diff -u linux-2.6.12/kernel/ptrace.c linux-2.6.12-pdb/kernel/ptrace.c
    24.5 ---- linux-2.6.12/kernel/ptrace.c       2005-06-17 20:48:29.000000000 +0100
    24.6 -+++ linux-2.6.12-pdb/kernel/ptrace.c   2005-07-22 13:23:16.000000000 +0100
    24.7 -@@ -239,6 +239,7 @@
    24.8 - 
    24.9 -        return buf - old_buf;
   24.10 - }
   24.11 -+EXPORT_SYMBOL(access_process_vm);
   24.12 - 
   24.13 - int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len)
   24.14 - {
    25.1 --- a/tools/debugger/pdb/linux-2.6-patches/traps.patch	Fri Sep 29 11:11:49 2006 +0100
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,20 +0,0 @@
    25.4 -diff -u linux-2.6.12/arch/xen/i386/kernel/traps.c linux-2.6.12-pdb/arch/xen/i386/kernel/traps.c
    25.5 ---- linux-2.6.12/arch/xen/i386/kernel/traps.c	2005-07-31 22:47:00.000000000 +0100
    25.6 -+++ linux-2.6.12-pdb/arch/xen/i386/kernel/traps.c	2005-07-31 22:47:32.000000000 +0100
    25.7 -@@ -102,6 +102,16 @@
    25.8 - 	return err;
    25.9 - }
   25.10 - 
   25.11 -+int unregister_die_notifier(struct notifier_block *nb)
   25.12 -+{
   25.13 -+	int err = 0;
   25.14 -+	unsigned long flags;
   25.15 -+	spin_lock_irqsave(&die_notifier_lock, flags);
   25.16 -+	err = notifier_chain_unregister(&i386die_chain, nb);
   25.17 -+	spin_unlock_irqrestore(&die_notifier_lock, flags);
   25.18 -+	return err;
   25.19 -+}
   25.20 -+
   25.21 - static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
   25.22 - {
   25.23 - 	return	p > (void *)tinfo &&
    26.1 --- a/tools/debugger/pdb/pdb_caml_domain.c	Fri Sep 29 11:11:49 2006 +0100
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,527 +0,0 @@
    26.4 -/*
    26.5 - * pdb_caml_xc.c
    26.6 - *
    26.7 - * http://www.cl.cam.ac.uk/netos/pdb
    26.8 - *
    26.9 - * PDB's OCaml interface library for debugging domains
   26.10 - */
   26.11 -
   26.12 -#include <xenctrl.h>
   26.13 -#include <xendebug.h>
   26.14 -#include <errno.h>
   26.15 -#include <stdio.h>
   26.16 -#include <stdlib.h>
   26.17 -#include <string.h>
   26.18 -#include <sys/mman.h>
   26.19 -#include <caml/alloc.h>
   26.20 -#include <caml/fail.h>
   26.21 -#include <caml/memory.h>
   26.22 -#include <caml/mlvalues.h>
   26.23 -
   26.24 -#include "pdb_caml_xen.h"
   26.25 -
   26.26 -typedef struct
   26.27 -{
   26.28 -    int domain;
   26.29 -    int vcpu;
   26.30 -} context_t;
   26.31 -
   26.32 -#define decode_context(_ctx, _ocaml)   \
   26.33 -{  \
   26.34 -    (_ctx)->domain = Int_val(Field((_ocaml),0));  \
   26.35 -    (_ctx)->vcpu = Int_val(Field((_ocaml),1));  \
   26.36 -}
   26.37 -
   26.38 -#define encode_context(_ctx, _ocaml)  \
   26.39 -{  \
   26.40 -    (_ocaml) = caml_alloc_tuple(2);  \
   26.41 -    Store_field((_ocaml), 0, Val_int((_ctx)->domain));  \
   26.42 -    Store_field((_ocaml), 1, Val_int((_ctx)->vcpu));  \
   26.43 -}
   26.44 -
   26.45 -
   26.46 -/****************************************************************************/
   26.47 -
   26.48 -/*
   26.49 - * dom_read_register : context_t -> int -> int32
   26.50 - */
   26.51 -value
   26.52 -dom_read_register (value context, value reg)
   26.53 -{
   26.54 -    CAMLparam2(context, reg);
   26.55 -    CAMLlocal1(result);
   26.56 -
   26.57 -    int my_reg = Int_val(reg);
   26.58 -    cpu_user_regs_t *regs;
   26.59 -    context_t ctx;
   26.60 -
   26.61 -    decode_context(&ctx, context);
   26.62 -
   26.63 -    if ( xendebug_read_registers(xc_handle, ctx.domain, ctx.vcpu, &regs) )
   26.64 -    {
   26.65 -        printf("(pdb) read registers error!\n");  fflush(stdout);
   26.66 -        failwith("read registers error");
   26.67 -    }
   26.68 -
   26.69 -    dump_regs(regs);
   26.70 -
   26.71 -    result = caml_alloc_tuple(16);
   26.72 -
   26.73 -    switch (my_reg)
   26.74 -    {
   26.75 -    case GDB_EAX: result = caml_copy_int32(regs->eax); break;
   26.76 -    case GDB_ECX: result = caml_copy_int32(regs->ecx); break;
   26.77 -    case GDB_EDX: result = caml_copy_int32(regs->edx); break;
   26.78 -    case GDB_EBX: result = caml_copy_int32(regs->ebx); break;
   26.79 -    case GDB_ESP: result = caml_copy_int32(regs->esp); break;
   26.80 -    case GDB_EBP: result = caml_copy_int32(regs->ebp); break;
   26.81 -    case GDB_ESI: result = caml_copy_int32(regs->esi); break;
   26.82 -    case GDB_EDI: result = caml_copy_int32(regs->edi); break;
   26.83 -    case GDB_EIP: result = caml_copy_int32(regs->eip); break;
   26.84 -    case GDB_EFL: result = caml_copy_int32(regs->eflags); break;
   26.85 -    case GDB_CS:  result = caml_copy_int32(regs->cs);  break;
   26.86 -    case GDB_SS: result = caml_copy_int32(regs->ss); break;
   26.87 -    case GDB_DS: result = caml_copy_int32(regs->ds); break;
   26.88 -    case GDB_ES: result = caml_copy_int32(regs->es); break;
   26.89 -    case GDB_FS: result = caml_copy_int32(regs->fs); break;
   26.90 -    case GDB_GS: result = caml_copy_int32(regs->gs); break;
   26.91 -    }
   26.92 -
   26.93 -    CAMLreturn(result);
   26.94 -}
   26.95 -
   26.96 -/*
   26.97 - * dom_read_registers : context_t -> int32
   26.98 - */
   26.99 -value
  26.100 -dom_read_registers (value context)
  26.101 -{
  26.102 -    CAMLparam1(context);
  26.103 -    CAMLlocal1(result);
  26.104 -
  26.105 -    cpu_user_regs_t *regs;
  26.106 -    context_t ctx;
  26.107 -
  26.108 -    decode_context(&ctx, context);
  26.109 -
  26.110 -    if ( xendebug_read_registers(xc_handle, ctx.domain, ctx.vcpu, &regs) )
  26.111 -    {
  26.112 -        printf("(pdb) read registers error!\n");  fflush(stdout);
  26.113 -        failwith("read registers error");
  26.114 -    }
  26.115 -
  26.116 -    dump_regs(regs);
  26.117 -
  26.118 -    result = caml_alloc_tuple(16);
  26.119 -
  26.120 -    Store_field(result,  0, caml_copy_int32(regs->eax));
  26.121 -    Store_field(result,  1, caml_copy_int32(regs->ecx));
  26.122 -    Store_field(result,  2, caml_copy_int32(regs->edx));
  26.123 -    Store_field(result,  3, caml_copy_int32(regs->ebx));
  26.124 -    Store_field(result,  4, caml_copy_int32(regs->esp));
  26.125 -    Store_field(result,  5, caml_copy_int32(regs->ebp));
  26.126 -    Store_field(result,  6, caml_copy_int32(regs->esi));
  26.127 -    Store_field(result,  7, caml_copy_int32(regs->edi));
  26.128 -    Store_field(result,  8, caml_copy_int32(regs->eip));
  26.129 -    Store_field(result,  9, caml_copy_int32(regs->eflags));
  26.130 -    Store_field(result, 10, caml_copy_int32(regs->cs));                /* 16 */
  26.131 -    Store_field(result, 11, caml_copy_int32(regs->ss));                /* 16 */
  26.132 -    Store_field(result, 12, caml_copy_int32(regs->ds));                /* 16 */
  26.133 -    Store_field(result, 13, caml_copy_int32(regs->es));                /* 16 */
  26.134 -    Store_field(result, 14, caml_copy_int32(regs->fs));                /* 16 */
  26.135 -    Store_field(result, 15, caml_copy_int32(regs->gs));                /* 16 */
  26.136 -
  26.137 -    CAMLreturn(result);
  26.138 -}
  26.139 -
  26.140 -
  26.141 -/*
  26.142 - * dom_write_register : context_t -> register -> int32 -> unit
  26.143 - */
  26.144 -value
  26.145 -dom_write_register (value context, value reg, value newval)
  26.146 -{
  26.147 -    CAMLparam3(context, reg, newval);
  26.148 -
  26.149 -    int my_reg = Int_val(reg);
  26.150 -    int val = Int32_val(newval);
  26.151 -
  26.152 -    context_t ctx;
  26.153 -    cpu_user_regs_t *regs;
  26.154 -
  26.155 -    printf("(pdb) write register\n");
  26.156 -
  26.157 -    decode_context(&ctx, context);
  26.158 -
  26.159 -    if ( xendebug_read_registers(xc_handle, ctx.domain, ctx.vcpu, &regs) )
  26.160 -    {
  26.161 -        printf("(pdb) write register (get) error!\n");  fflush(stdout);
  26.162 -        failwith("write register error");
  26.163 -    }
  26.164 -
  26.165 -    switch (my_reg)
  26.166 -    {
  26.167 -    case GDB_EAX: regs->eax = val; break;
  26.168 -    case GDB_ECX: regs->ecx = val; break;
  26.169 -    case GDB_EDX: regs->edx = val; break;
  26.170 -    case GDB_EBX: regs->ebx = val; break;
  26.171 -
  26.172 -    case GDB_ESP: regs->esp = val; break;
  26.173 -    case GDB_EBP: regs->ebp = val; break;
  26.174 -    case GDB_ESI: regs->esi = val; break;
  26.175 -    case GDB_EDI: regs->edi = val; break;
  26.176 - 
  26.177 -    case GDB_EIP: regs->eip = val; break;
  26.178 -    case GDB_EFL: regs->eflags = val; break;
  26.179 -
  26.180 -    case GDB_CS:  regs->cs  = val; break;
  26.181 -    case GDB_SS:  regs->ss  = val; break;
  26.182 -    case GDB_DS:  regs->ds  = val; break;
  26.183 -    case GDB_ES:  regs->es  = val; break;
  26.184 -    case GDB_FS:  regs->fs  = val; break;
  26.185 -    case GDB_GS:  regs->gs  = val; break;
  26.186 -    }
  26.187 -
  26.188 -    if ( xendebug_write_registers(xc_handle, ctx.domain, ctx.vcpu, regs) )
  26.189 -    {
  26.190 -        printf("(pdb) write register (set) error!\n");  fflush(stdout);
  26.191 -        failwith("write register error");
  26.192 -    }
  26.193 -
  26.194 -    CAMLreturn(Val_unit);
  26.195 -}
  26.196 -
  26.197 -/*
  26.198 - * dom_read_memory : context_t -> int32 -> int -> int
  26.199 - */
  26.200 -value
  26.201 -dom_read_memory (value context, value address, value length)
  26.202 -{
  26.203 -    CAMLparam3(context, address, length);
  26.204 -    CAMLlocal2(result, temp);
  26.205 -
  26.206 -    context_t ctx;
  26.207 -    int loop;
  26.208 -    char *buffer;
  26.209 -    unsigned long my_address = Int32_val(address);
  26.210 -    uint32_t my_length = Int_val(length);
  26.211 -
  26.212 -    printf ("(pdb) read memory\n");
  26.213 -
  26.214 -    decode_context(&ctx, context);
  26.215 -
  26.216 -    buffer = malloc(my_length);
  26.217 -    if ( buffer == NULL )
  26.218 -    {
  26.219 -        printf("(pdb) read memory: malloc failed.\n");  fflush(stdout);
  26.220 -        failwith("read memory error");
  26.221 -    }
  26.222 -
  26.223 -    if ( xendebug_read_memory(xc_handle, ctx.domain, ctx.vcpu, 
  26.224 -                              my_address, my_length, buffer) )
  26.225 -    {
  26.226 -        printf("(pdb) read memory error!\n");  fflush(stdout);
  26.227 -        failwith("read memory error");
  26.228 -    }
  26.229 -
  26.230 -    result = caml_alloc(2,0);
  26.231 -    if ( my_length > 0 )                                              /* car */
  26.232 -    {
  26.233 -        Store_field(result, 0, Val_int(buffer[my_length - 1] & 0xff));
  26.234 -    }
  26.235 -    else
  26.236 -
  26.237 -    {
  26.238 -        Store_field(result, 0, Val_int(0));                    
  26.239 -    }
  26.240 -    Store_field(result, 1, Val_int(0));                               /* cdr */
  26.241 -
  26.242 -    for (loop = 1; loop < my_length; loop++)
  26.243 -    {
  26.244 -        temp = result;
  26.245 -        result = caml_alloc(2,0);
  26.246 -        Store_field(result, 0, Val_int(buffer[my_length - loop - 1] & 0xff));
  26.247 -        Store_field(result, 1, temp);
  26.248 -    }
  26.249 -
  26.250 -    CAMLreturn(result);
  26.251 -}
  26.252 -
  26.253 -/*
  26.254 - * dom_write_memory : context_t -> int32 -> int list -> unit
  26.255 - */
  26.256 -value
  26.257 -dom_write_memory (value context, value address, value val_list)
  26.258 -{
  26.259 -    CAMLparam3(context, address, val_list);
  26.260 -    CAMLlocal1(node);
  26.261 -
  26.262 -    context_t ctx;
  26.263 -
  26.264 -    char buffer[4096];  /* a big buffer */
  26.265 -    unsigned long  my_address;
  26.266 -    uint32_t length = 0;
  26.267 -
  26.268 -    printf ("(pdb) write memory\n");
  26.269 -
  26.270 -    decode_context(&ctx, context);
  26.271 -
  26.272 -    node = val_list;
  26.273 -    if ( Int_val(node) == 0 )       /* gdb functionalty test uses empty list */
  26.274 -    {
  26.275 -        CAMLreturn(Val_unit);
  26.276 -    }
  26.277 -
  26.278 -    while ( Int_val(Field(node,1)) != 0 )
  26.279 -    {
  26.280 -        buffer[length++] = Int_val(Field(node, 0));
  26.281 -        node = Field(node,1);
  26.282 -    }
  26.283 -    buffer[length++] = Int_val(Field(node, 0));
  26.284 -
  26.285 -    my_address = (unsigned long) Int32_val(address);
  26.286 -
  26.287 -    if ( xendebug_write_memory(xc_handle, ctx.domain, ctx.vcpu,
  26.288 -                               my_address, length, buffer) )
  26.289 -    {
  26.290 -        printf("(pdb) write memory error!\n");  fflush(stdout);
  26.291 -        failwith("write memory error");
  26.292 -    }
  26.293 -
  26.294 -    CAMLreturn(Val_unit);
  26.295 -}
  26.296 -
  26.297 -/*
  26.298 - * dom_continue_target : context_t -> unit
  26.299 - */
  26.300 -value
  26.301 -dom_continue_target (value context)
  26.302 -{
  26.303 -    CAMLparam1(context);
  26.304 -
  26.305 -    context_t ctx;
  26.306 -
  26.307 -    decode_context(&ctx, context);
  26.308 -
  26.309 -    if ( xendebug_continue(xc_handle, ctx.domain, ctx.vcpu) )
  26.310 -    {
  26.311 -        printf("(pdb) continue\n");  fflush(stdout);
  26.312 -        failwith("continue");
  26.313 -    }
  26.314 -
  26.315 -    CAMLreturn(Val_unit);
  26.316 -}
  26.317 -
  26.318 -/*
  26.319 - * dom_step_target : context_t -> unit
  26.320 - */
  26.321 -value
  26.322 -dom_step_target (value context)
  26.323 -{
  26.324 -    CAMLparam1(context);
  26.325 -
  26.326 -    context_t ctx;
  26.327 -
  26.328 -    decode_context(&ctx, context);
  26.329 -
  26.330 -    if ( xendebug_step(xc_handle, ctx.domain, ctx.vcpu) )
  26.331 -    {
  26.332 -        printf("(pdb) step\n");  fflush(stdout);
  26.333 -        failwith("step");
  26.334 -    }
  26.335 -
  26.336 -    CAMLreturn(Val_unit);
  26.337 -}
  26.338 -
  26.339 -
  26.340 -
  26.341 -/*
  26.342 - * dom_insert_memory_breakpoint : context_t -> int32 -> int list -> unit
  26.343 - */
  26.344 -value
  26.345 -dom_insert_memory_breakpoint (value context, value address, value length)
  26.346 -{
  26.347 -    CAMLparam3(context, address, length);
  26.348 -
  26.349 -    context_t ctx;
  26.350 -    unsigned long my_address = (unsigned long) Int32_val(address);
  26.351 -    int my_length = Int_val(length);
  26.352 -
  26.353 -    decode_context(&ctx, context);
  26.354 -
  26.355 -    printf ("(pdb) insert memory breakpoint 0x%lx %d\n",
  26.356 -            my_address, my_length);
  26.357 -
  26.358 -    if ( xendebug_insert_memory_breakpoint(xc_handle, ctx.domain, ctx.vcpu,
  26.359 -                                           my_address, my_length) )
  26.360 -    {
  26.361 -        printf("(pdb) error: insert memory breakpoint\n");  fflush(stdout);
  26.362 -        failwith("insert memory breakpoint");
  26.363 -    }
  26.364 -
  26.365 -
  26.366 -    CAMLreturn(Val_unit);
  26.367 -}
  26.368 -
  26.369 -/*
  26.370 - * dom_remove_memory_breakpoint : context_t -> int32 -> int list -> unit
  26.371 - */
  26.372 -value
  26.373 -dom_remove_memory_breakpoint (value context, value address, value length)
  26.374 -{
  26.375 -    CAMLparam3(context, address, length);
  26.376 -
  26.377 -    context_t ctx;
  26.378 -
  26.379 -    unsigned long my_address = (unsigned long) Int32_val(address);
  26.380 -    int my_length = Int_val(length);
  26.381 -
  26.382 -    printf ("(pdb) remove memory breakpoint 0x%lx %d\n",
  26.383 -            my_address, my_length);
  26.384 -
  26.385 -    decode_context(&ctx, context);
  26.386 -
  26.387 -    if ( xendebug_remove_memory_breakpoint(xc_handle, 
  26.388 -                                           ctx.domain, ctx.vcpu,
  26.389 -                                           my_address, my_length) )
  26.390 -    {
  26.391 -        printf("(pdb) error: remove memory breakpoint\n");  fflush(stdout);
  26.392 -        failwith("remove memory breakpoint");
  26.393 -    }
  26.394 -
  26.395 -    CAMLreturn(Val_unit);
  26.396 -}
  26.397 -
  26.398 -/*
  26.399 - * dom_attach_debugger : int -> int -> unit
  26.400 - */
  26.401 -value
  26.402 -dom_attach_debugger (value domain, value vcpu)
  26.403 -{
  26.404 -    CAMLparam2(domain, vcpu);
  26.405 -
  26.406 -    int my_domain = Int_val(domain);
  26.407 -    int my_vcpu = Int_val(vcpu);
  26.408 -
  26.409 -    printf ("(pdb) attach domain [%d.%d]\n", my_domain, my_vcpu);
  26.410 -
  26.411 -    if ( xendebug_attach(xc_handle, my_domain, my_vcpu) )
  26.412 -    {
  26.413 -        printf("(pdb) attach error!\n");  fflush(stdout);
  26.414 -        failwith("attach error");
  26.415 -    }
  26.416 -
  26.417 -    CAMLreturn(Val_unit);
  26.418 -}
  26.419 -
  26.420 -
  26.421 -/*
  26.422 - * dom_detach_debugger : int -> int -> unit
  26.423 - */
  26.424 -value
  26.425 -dom_detach_debugger (value domain, value vcpu)
  26.426 -{
  26.427 -    CAMLparam2(domain, vcpu);
  26.428 -
  26.429 -    int my_domain = Int_val(domain);
  26.430 -    int my_vcpu = Int_val(vcpu);
  26.431 -
  26.432 -    printf ("(pdb) detach domain [%d.%d]\n", my_domain, my_vcpu);
  26.433 -
  26.434 -    if ( xendebug_detach(xc_handle, my_domain, my_vcpu) )
  26.435 -    {
  26.436 -        printf("(pdb) detach error!\n");  fflush(stdout);
  26.437 -        failwith("detach error");
  26.438 -    }
  26.439 -
  26.440 -    CAMLreturn(Val_unit);
  26.441 -}
  26.442 -
  26.443 -
  26.444 -/*
  26.445 - * dom_pause_target : int -> unit
  26.446 - */
  26.447 -value
  26.448 -dom_pause_target (value domid)
  26.449 -{
  26.450 -    CAMLparam1(domid);
  26.451 -
  26.452 -    int my_domid = Int_val(domid);
  26.453 -
  26.454 -    printf ("(pdb) pause target %d\n", my_domid);
  26.455 -
  26.456 -    xc_domain_pause(xc_handle, my_domid);
  26.457 -
  26.458 -    CAMLreturn(Val_unit);
  26.459 -}
  26.460 -
  26.461 -/****************************************************************************/
  26.462 -/****************************************************************************/
  26.463 -
  26.464 -/*
  26.465 - * query_domain_stop : unit -> (int * int) list
  26.466 - */
  26.467 -value
  26.468 -query_domain_stop (value unit)
  26.469 -{
  26.470 -    CAMLparam1(unit);
  26.471 -    CAMLlocal3(result, temp, node);
  26.472 -
  26.473 -    int max_domains = 20;
  26.474 -    int dom_list[max_domains];
  26.475 -    int loop, count;
  26.476 -
  26.477 -    count = xendebug_query_domain_stop(xc_handle, dom_list, max_domains);
  26.478 -    if ( count < 0 )
  26.479 -    {
  26.480 -        printf("(pdb) query domain stop!\n");  fflush(stdout);
  26.481 -        failwith("query domain stop");
  26.482 -    }
  26.483 -
  26.484 -    printf ("QDS [%d]: \n", count);
  26.485 -    for (loop = 0; loop < count; loop ++)
  26.486 -        printf (" %d", dom_list[loop]);
  26.487 -    printf ("\n");
  26.488 -
  26.489 -    result = caml_alloc(2,0);
  26.490 -    if ( count > 0 )                                                  /* car */
  26.491 -    {
  26.492 -        node = caml_alloc(2,0);
  26.493 -        Store_field(node, 0, Val_int(dom_list[0]));             /* domain id */
  26.494 -        Store_field(node, 1, Val_int(0));                            /* vcpu */
  26.495 -        Store_field(result, 0, node);
  26.496 -    }
  26.497 -    else
  26.498 -    {
  26.499 -        Store_field(result, 0, Val_int(0));                    
  26.500 -    }
  26.501 -    Store_field(result, 1, Val_int(0));                               /* cdr */
  26.502 -
  26.503 -    for ( loop = 1; loop < count; loop++ )
  26.504 -    {
  26.505 -        temp = result;
  26.506 -        result = caml_alloc(2,0);
  26.507 -        node = caml_alloc(2,0);
  26.508 -        Store_field(node, 0, Val_int(dom_list[loop]));          /* domain id */
  26.509 -        Store_field(node, 1, Val_int(0));                            /* vcpu */
  26.510 -        Store_field(result, 0, node);
  26.511 -        Store_field(result, 1, temp);
  26.512 -    }
  26.513 -
  26.514 -    CAMLreturn(result);
  26.515 -}
  26.516 -
  26.517 -/****************************************************************************/
  26.518 -
  26.519 -
  26.520 -
  26.521 -/*
  26.522 - * Local variables:
  26.523 - * mode: C
  26.524 - * c-set-style: "BSD"
  26.525 - * c-basic-offset: 4
  26.526 - * tab-width: 4
  26.527 - * indent-tabs-mode: nil
  26.528 - * End:
  26.529 - */
  26.530 -
    27.1 --- a/tools/debugger/pdb/pdb_caml_evtchn.c	Fri Sep 29 11:11:49 2006 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,186 +0,0 @@
    27.4 -/*
    27.5 - * pdb_caml_evtchn.c
    27.6 - *
    27.7 - * http://www.cl.cam.ac.uk/netos/pdb
    27.8 - *
    27.9 - * PDB's OCaml interface library for event channels
   27.10 - */
   27.11 -
   27.12 -#include <xenctrl.h>
   27.13 -#include <stdio.h>
   27.14 -#include <stdlib.h>
   27.15 -#include <string.h>
   27.16 -
   27.17 -#include <caml/alloc.h>
   27.18 -#include <caml/fail.h>
   27.19 -#include <caml/memory.h>
   27.20 -#include <caml/mlvalues.h>
   27.21 -
   27.22 -
   27.23 -#include <errno.h>
   27.24 -#include <sys/ioctl.h>
   27.25 -#include <sys/stat.h>
   27.26 -#include <fcntl.h>
   27.27 -#include <unistd.h>
   27.28 -
   27.29 -int xen_evtchn_bind (int evtchn_fd, int idx);
   27.30 -int xen_evtchn_unbind (int evtchn_fd, int idx);
   27.31 -
   27.32 -int
   27.33 -__evtchn_open (char *filename, int major, int minor)
   27.34 -{
   27.35 -    int   evtchn_fd;
   27.36 -    struct stat st;
   27.37 -    
   27.38 -    /* Make sure any existing device file links to correct device. */
   27.39 -    if ( (lstat(filename, &st) != 0) ||
   27.40 -         !S_ISCHR(st.st_mode) ||
   27.41 -         (st.st_rdev != makedev(major, minor)) )
   27.42 -    {
   27.43 -        (void)unlink(filename);
   27.44 -    }
   27.45 -
   27.46 - reopen:
   27.47 -    evtchn_fd = open(filename, O_RDWR); 
   27.48 -    if ( evtchn_fd == -1 )
   27.49 -    {
   27.50 -        if ( (errno == ENOENT) &&
   27.51 -             ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
   27.52 -             (mknod(filename, S_IFCHR|0600, makedev(major,minor)) == 0) )
   27.53 -        {
   27.54 -            goto reopen;
   27.55 -        }
   27.56 -        return -errno;
   27.57 -    }
   27.58 -
   27.59 -    return evtchn_fd;
   27.60 -}
   27.61 -
   27.62 -/*
   27.63 - * evtchn_open : string -> int -> int -> Unix.file_descr
   27.64 - *
   27.65 - * OCaml's Unix library doesn't have mknod, so it makes more sense just write
   27.66 - * this in C.  This code is from Keir/Andy.
   27.67 - */
   27.68 -value
   27.69 -evtchn_open (value filename, value major, value minor)
   27.70 -{
   27.71 -    CAMLparam3(filename, major, minor);
   27.72 -
   27.73 -    char *myfilename = String_val(filename);
   27.74 -    int   mymajor = Int_val(major);
   27.75 -    int   myminor = Int_val(minor);
   27.76 -    int   evtchn_fd;
   27.77 -
   27.78 -    evtchn_fd = __evtchn_open(myfilename, mymajor, myminor);
   27.79 -
   27.80 -    CAMLreturn(Val_int(evtchn_fd));
   27.81 -}
   27.82 -
   27.83 -/*
   27.84 - * evtchn_bind : Unix.file_descr -> int -> unit
   27.85 - */
   27.86 -value
   27.87 -evtchn_bind (value fd, value idx)
   27.88 -{
   27.89 -    CAMLparam2(fd, idx);
   27.90 -
   27.91 -    int myfd = Int_val(fd);
   27.92 -    int myidx = Int_val(idx);
   27.93 -
   27.94 -    if ( xen_evtchn_bind(myfd, myidx) < 0 )
   27.95 -    {
   27.96 -        printf("(pdb) evtchn_bind error!\n");  fflush(stdout);
   27.97 -        failwith("evtchn_bind error");
   27.98 -    }
   27.99 -
  27.100 -    CAMLreturn(Val_unit);
  27.101 -}
  27.102 -
  27.103 -/*
  27.104 - * evtchn_unbind : Unix.file_descr -> int -> unit
  27.105 - */
  27.106 -value
  27.107 -evtchn_unbind (value fd, value idx)
  27.108 -{
  27.109 -    CAMLparam2(fd, idx);
  27.110 -
  27.111 -    int myfd = Int_val(fd);
  27.112 -    int myidx = Int_val(idx);
  27.113 -
  27.114 -    if ( xen_evtchn_unbind(myfd, myidx) < 0 )
  27.115 -    {
  27.116 -        printf("(pdb) evtchn_unbind error!\n");  fflush(stdout);
  27.117 -        failwith("evtchn_unbind error");
  27.118 -    }
  27.119 -
  27.120 -    CAMLreturn(Val_unit);
  27.121 -}
  27.122 -
  27.123 -/*
  27.124 - * evtchn_read : Unix.file_descr -> int
  27.125 - */
  27.126 -value
  27.127 -evtchn_read (value fd)
  27.128 -{
  27.129 -    CAMLparam1(fd);
  27.130 -
  27.131 -    uint16_t v;
  27.132 -    int bytes;
  27.133 -    int rc = -1;
  27.134 -    int myfd = Int_val(fd);
  27.135 -
  27.136 -    while ( (bytes = read(myfd, &v, sizeof(v))) == -1 )
  27.137 -    {
  27.138 -        if ( errno == EINTR )  continue;
  27.139 -        rc = -errno;
  27.140 -        goto exit;
  27.141 -    }
  27.142 -    
  27.143 -    if ( bytes == sizeof(v) )
  27.144 -        rc = v;
  27.145 -    
  27.146 - exit:
  27.147 -    CAMLreturn(Val_int(rc));
  27.148 -}
  27.149 -
  27.150 -
  27.151 -/*
  27.152 - * evtchn_close : Unix.file_descr -> unit
  27.153 - */
  27.154 -value
  27.155 -evtchn_close (value fd)
  27.156 -{
  27.157 -    CAMLparam1(fd);
  27.158 -    int myfd = Int_val(fd);
  27.159 -
  27.160 -    (void)close(myfd);
  27.161 -
  27.162 -    CAMLreturn(Val_unit);
  27.163 -}
  27.164 -
  27.165 -/*
  27.166 - * evtchn_unmask : Unix.file_descr -> int -> unit
  27.167 - */
  27.168 -value
  27.169 -evtchn_unmask (value fd, value idx)
  27.170 -{
  27.171 -    CAMLparam1(fd);
  27.172 -
  27.173 -    int myfd = Int_val(fd);
  27.174 -    uint16_t myidx = Int_val(idx);
  27.175 -
  27.176 -    (void)write(myfd, &myidx, sizeof(myidx));
  27.177 -
  27.178 -    CAMLreturn(Val_unit);
  27.179 -}
  27.180 -
  27.181 -/*
  27.182 - * Local variables:
  27.183 - * mode: C
  27.184 - * c-set-style: "BSD"
  27.185 - * c-basic-offset: 4
  27.186 - * tab-width: 4
  27.187 - * indent-tabs-mode: nil
  27.188 - * End:
  27.189 - */
    28.1 --- a/tools/debugger/pdb/pdb_caml_process.c	Fri Sep 29 11:11:49 2006 +0100
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,587 +0,0 @@
    28.4 -/*
    28.5 - * pdb_caml_process.c
    28.6 - *
    28.7 - * http://www.cl.cam.ac.uk/netos/pdb
    28.8 - *
    28.9 - * PDB's OCaml interface library for debugging processes
   28.10 - */
   28.11 -
   28.12 -#include <errno.h>
   28.13 -#include <stdio.h>
   28.14 -#include <stdlib.h>
   28.15 -#include <string.h>
   28.16 -#include <caml/alloc.h>
   28.17 -#include <caml/fail.h>
   28.18 -#include <caml/memory.h>
   28.19 -#include <caml/mlvalues.h>
   28.20 -
   28.21 -#include <xenctrl.h>
   28.22 -#include <xen/xen.h>
   28.23 -#include <xen/io/domain_controller.h>
   28.24 -#include "pdb_module.h"
   28.25 -#include "pdb_caml_xen.h"
   28.26 -
   28.27 -typedef struct
   28.28 -{
   28.29 -    int domain;
   28.30 -    int process;
   28.31 -    int evtchn;
   28.32 -    pdb_front_ring_t *ring;
   28.33 -} context_t;
   28.34 -
   28.35 -#define decode_context(_ctx, _ocaml)   \
   28.36 -{  \
   28.37 -    (_ctx)->domain  = Int_val(Field((_ocaml),0));  \
   28.38 -    (_ctx)->process = Int_val(Field((_ocaml),1));  \
   28.39 -    (_ctx)->evtchn  = Int_val(Field((_ocaml),2));  \
   28.40 -    (_ctx)->ring    =  (pdb_front_ring_t *)Int32_val(Field((_ocaml),3));  \
   28.41 -}
   28.42 -
   28.43 -#define encode_context(_ctx, _ocaml)  \
   28.44 -{  \
   28.45 -    (_ocaml) = caml_alloc_tuple(2);  \
   28.46 -    Store_field((_ocaml), 0, Val_int((_ctx)->domain));  \
   28.47 -    Store_field((_ocaml), 1, Val_int((_ctx)->process));  \
   28.48 -}
   28.49 -
   28.50 -/*
   28.51 - * send a request to a pdb domain backend.
   28.52 - *
   28.53 - * puts the request on a ring and kicks the backend using an event channel.
   28.54 - */
   28.55 -static void
   28.56 -send_request (pdb_front_ring_t *pdb_ring, int evtchn, pdb_request_t *request)
   28.57 -{
   28.58 -    pdb_request_t    *req;
   28.59 -
   28.60 -    req = RING_GET_REQUEST(pdb_ring, pdb_ring->req_prod_pvt);
   28.61 -
   28.62 -    memcpy(req, request, sizeof(pdb_request_t));
   28.63 -
   28.64 -    pdb_ring->req_prod_pvt++;
   28.65 -
   28.66 -    RING_PUSH_REQUESTS(pdb_ring);
   28.67 -    xc_evtchn_send(xc_handle, evtchn);
   28.68 -}
   28.69 -
   28.70 -/*
   28.71 - * process_handle_response : int32 -> int * int * string
   28.72 - *
   28.73 - * A backend domain has notified pdb (via an event channel)
   28.74 - * that a command has finished.
   28.75 - * We read the result from the channel and formulate a response
   28.76 - * as a single string.  Also return the domain and process.
   28.77 - */
   28.78 -
   28.79 -static inline unsigned int
   28.80 -_flip (unsigned int orig)
   28.81 -{
   28.82 -    return (((orig << 24) & 0xff000000) | ((orig <<  8) & 0x00ff0000) |
   28.83 -            ((orig >>  8) & 0x0000ff00) | ((orig >> 24) & 0x000000ff));
   28.84 -}
   28.85 -
   28.86 -value
   28.87 -process_handle_response (value ring)
   28.88 -{
   28.89 -    CAMLparam1(ring);
   28.90 -    CAMLlocal2(result, str);
   28.91 -
   28.92 -    RING_IDX rp;
   28.93 -    pdb_response_p resp;
   28.94 -    pdb_front_ring_t *my_ring = (pdb_front_ring_t *)Int32_val(ring);
   28.95 -    char msg[2048];
   28.96 -    int msglen;
   28.97 -
   28.98 -    memset(msg, 0, sizeof(msg));
   28.99 -
  28.100 -    rp = my_ring->sring->rsp_prod;
  28.101 -    rmb();                     /* Ensure we see queued responses up to 'rp'. */
  28.102 -
  28.103 -    /* default response is OK unless the command has something 
  28.104 -       more interesting to say */
  28.105 -    sprintf(msg, "OK");
  28.106 -
  28.107 -    if (my_ring->rsp_cons != rp)
  28.108 -    {
  28.109 -        resp = RING_GET_RESPONSE(my_ring, my_ring->rsp_cons);
  28.110 -
  28.111 -        switch (resp->operation)
  28.112 -        {
  28.113 -        case PDB_OPCODE_PAUSE :
  28.114 -        case PDB_OPCODE_ATTACH :
  28.115 -        case PDB_OPCODE_DETACH :
  28.116 -            break;
  28.117 -            
  28.118 -        case PDB_OPCODE_RD_REG :
  28.119 -        {
  28.120 -            sprintf(&msg[0], "%08x", _flip(resp->u.rd_reg.value));
  28.121 -            break;
  28.122 -        }
  28.123 -
  28.124 -        case PDB_OPCODE_RD_REGS :
  28.125 -        {
  28.126 -            int loop;
  28.127 -            pdb_op_rd_regs_p regs = &resp->u.rd_regs;
  28.128 -            
  28.129 -            for (loop = 0; loop < GDB_REGISTER_FRAME_SIZE * 8; loop += 8)
  28.130 -            {
  28.131 -                sprintf(&msg[loop], "%08x", _flip(regs->reg[loop >> 3]));
  28.132 -            }
  28.133 -                
  28.134 -            break;
  28.135 -        }
  28.136 -        case PDB_OPCODE_WR_REG :
  28.137 -        {
  28.138 -            /* should check the return status */
  28.139 -            break;
  28.140 -        }
  28.141 -
  28.142 -        case PDB_OPCODE_RD_MEM :
  28.143 -        {
  28.144 -            int loop;
  28.145 -            pdb_op_rd_mem_resp_p mem = &resp->u.rd_mem;
  28.146 -
  28.147 -            for (loop = 0; loop < mem->length; loop ++)
  28.148 -            {
  28.149 -                sprintf(&msg[loop * 2], "%02x", mem->data[loop]);
  28.150 -            }
  28.151 -            break;
  28.152 -        }
  28.153 -        case PDB_OPCODE_WR_MEM :
  28.154 -        {
  28.155 -            /* should check the return status */
  28.156 -            break;
  28.157 -        }
  28.158 -
  28.159 -        /* this is equivalent to process_xen_virq */
  28.160 -        case PDB_OPCODE_CONTINUE :
  28.161 -        {
  28.162 -            sprintf(msg, "S05");
  28.163 -            break;
  28.164 -        }
  28.165 -        case PDB_OPCODE_STEP :
  28.166 -        {
  28.167 -            sprintf(msg, "S05");
  28.168 -            break;
  28.169 -        }
  28.170 -
  28.171 -        case PDB_OPCODE_SET_BKPT :
  28.172 -        case PDB_OPCODE_CLR_BKPT :
  28.173 -        case PDB_OPCODE_SET_WATCHPT :
  28.174 -        case PDB_OPCODE_CLR_WATCHPT :
  28.175 -        {
  28.176 -            break;
  28.177 -        }
  28.178 -
  28.179 -        case PDB_OPCODE_WATCHPOINT :
  28.180 -        {
  28.181 -            sprintf(msg, "S05");
  28.182 -            break;
  28.183 -        }
  28.184 -
  28.185 -        default :
  28.186 -            printf("(linux) UNKNOWN MESSAGE TYPE IN RESPONSE %d\n",
  28.187 -                   resp->operation);
  28.188 -            break;
  28.189 -        }
  28.190 -
  28.191 -        my_ring->rsp_cons++;
  28.192 -    }
  28.193 -
  28.194 -    msglen = strlen(msg);
  28.195 -    result = caml_alloc(3,0);
  28.196 -    str = alloc_string(msglen);
  28.197 -    memmove(&Byte(str,0), msg, msglen);
  28.198 -
  28.199 -    Store_field(result, 0, Val_int(resp->domain));
  28.200 -    Store_field(result, 1, Val_int(resp->process));
  28.201 -    Store_field(result, 2, str);
  28.202 -
  28.203 -    CAMLreturn(result);
  28.204 -}
  28.205 -
  28.206 -/*
  28.207 - * proc_attach_debugger : context_t -> unit
  28.208 - */
  28.209 -value
  28.210 -proc_attach_debugger (value context)
  28.211 -{
  28.212 -    CAMLparam1(context);
  28.213 -    context_t ctx;
  28.214 -    pdb_request_t req;
  28.215 -
  28.216 -    decode_context(&ctx, context);
  28.217 -
  28.218 -    req.operation = PDB_OPCODE_ATTACH;
  28.219 -    req.u.attach.domain  = ctx.domain;
  28.220 -    req.process = ctx.process;
  28.221 -
  28.222 -    send_request (ctx.ring, ctx.evtchn, &req);
  28.223 -
  28.224 -    CAMLreturn(Val_unit);
  28.225 -}
  28.226 -
  28.227 -
  28.228 -/*
  28.229 - * proc_detach_debugger : context_t -> unit
  28.230 - */
  28.231 -value
  28.232 -proc_detach_debugger (value context)
  28.233 -{
  28.234 -    CAMLparam1(context);
  28.235 -    context_t ctx;
  28.236 -    pdb_request_t req;
  28.237 -
  28.238 -    decode_context(&ctx, context);
  28.239 -
  28.240 -    printf("(pdb) detach process [%d.%d] %d %p\n", ctx.domain, ctx.process,
  28.241 -           ctx.evtchn, ctx.ring);
  28.242 -    fflush(stdout);
  28.243 -
  28.244 -    req.operation = PDB_OPCODE_DETACH;
  28.245 -    req.process = ctx.process;
  28.246 -
  28.247 -    send_request (ctx.ring, ctx.evtchn, &req);
  28.248 -
  28.249 -    CAMLreturn(Val_unit);
  28.250 -}
  28.251 -
  28.252 -
  28.253 -/*
  28.254 - * proc_pause_target : int -> unit
  28.255 - */
  28.256 -value
  28.257 -proc_pause_target (value context)
  28.258 -{
  28.259 -    CAMLparam1(context);
  28.260 -    context_t ctx;
  28.261 -    pdb_request_t req;
  28.262 -
  28.263 -    decode_context(&ctx, context);
  28.264 -
  28.265 -    printf("(pdb) pause target %d %d\n", ctx.domain, ctx.process);
  28.266 -    fflush(stdout);
  28.267 -
  28.268 -    req.operation = PDB_OPCODE_PAUSE;
  28.269 -    req.process = ctx.process;
  28.270 -
  28.271 -    send_request (ctx.ring, ctx.evtchn, &req);
  28.272 -
  28.273 -    CAMLreturn(Val_unit);
  28.274 -}
  28.275 -
  28.276 -
  28.277 -/*
  28.278 - * proc_read_register : context_t -> int -> unit
  28.279 - */
  28.280 -value
  28.281 -proc_read_register (value context, value reg)
  28.282 -{
  28.283 -    CAMLparam1(context);
  28.284 -
  28.285 -    pdb_request_t req;
  28.286 -    context_t ctx;
  28.287 -    int my_reg = Int_val(reg);
  28.288 -
  28.289 -    decode_context(&ctx, context);
  28.290 -
  28.291 -    req.operation = PDB_OPCODE_RD_REG;
  28.292 -    req.process = ctx.process;
  28.293 -    req.u.rd_reg.reg = my_reg;
  28.294 -    req.u.rd_reg.value = 0;
  28.295 -
  28.296 -    send_request (ctx.ring, ctx.evtchn, &req);
  28.297 -
  28.298 -    CAMLreturn(Val_unit);
  28.299 -}
  28.300 -
  28.301 -
  28.302 -
  28.303 -/*
  28.304 - * proc_read_registers : context_t -> unit
  28.305 - */
  28.306 -value
  28.307 -proc_read_registers (value context)
  28.308 -{
  28.309 -    CAMLparam1(context);
  28.310 -
  28.311 -    pdb_request_t req;
  28.312 -    context_t ctx;
  28.313 -
  28.314 -    decode_context(&ctx, context);
  28.315 -
  28.316 -    req.operation = PDB_OPCODE_RD_REGS;
  28.317 -    req.process = ctx.process;
  28.318 -
  28.319 -    send_request (ctx.ring, ctx.evtchn, &req);
  28.320 -
  28.321 -    CAMLreturn(Val_unit);
  28.322 -}
  28.323 -
  28.324 -
  28.325 -/*
  28.326 - * proc_write_register : context_t -> register -> int32 -> unit
  28.327 - */
  28.328 -value
  28.329 -proc_write_register (value context, value reg, value newval)
  28.330 -{
  28.331 -    CAMLparam3(context, reg, newval);
  28.332 -
  28.333 -    int my_reg = Int_val(reg);
  28.334 -    unsigned long my_newval = Int32_val(newval);
  28.335 -
  28.336 -    context_t ctx;
  28.337 -    pdb_request_t req;
  28.338 -
  28.339 -    decode_context(&ctx, context);
  28.340 -
  28.341 -    req.operation = PDB_OPCODE_WR_REG;
  28.342 -    req.process = ctx.process;
  28.343 -    req.u.wr_reg.value = my_newval;
  28.344 -
  28.345 -    switch (my_reg)
  28.346 -    {
  28.347 -    case GDB_EAX: req.u.wr_reg.reg = LINUX_EAX; break;
  28.348 -    case GDB_ECX: req.u.wr_reg.reg = LINUX_ECX; break;
  28.349 -    case GDB_EDX: req.u.wr_reg.reg = LINUX_EDX; break;
  28.350 -    case GDB_EBX: req.u.wr_reg.reg = LINUX_EBX; break;
  28.351 -
  28.352 -    case GDB_ESP: req.u.wr_reg.reg = LINUX_ESP; break;
  28.353 -    case GDB_EBP: req.u.wr_reg.reg = LINUX_EBP; break;
  28.354 -    case GDB_ESI: req.u.wr_reg.reg = LINUX_ESI; break;
  28.355 -    case GDB_EDI: req.u.wr_reg.reg = LINUX_EDI; break;
  28.356 -
  28.357 -    case GDB_EIP: req.u.wr_reg.reg = LINUX_EIP; break;
  28.358 -    case GDB_EFL: req.u.wr_reg.reg = LINUX_EFL; break;
  28.359 - 
  28.360 -    case GDB_CS:  req.u.wr_reg.reg = LINUX_CS; break;
  28.361 -    case GDB_SS:  req.u.wr_reg.reg = LINUX_SS; break;
  28.362 -    case GDB_DS:  req.u.wr_reg.reg = LINUX_DS; break;
  28.363 -    case GDB_ES:  req.u.wr_reg.reg = LINUX_ES; break;
  28.364 -    case GDB_FS:  req.u.wr_reg.reg = LINUX_FS; break;
  28.365 -    case GDB_GS:  req.u.wr_reg.reg = LINUX_GS; break;
  28.366 -    }
  28.367 -
  28.368 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.369 -
  28.370 -    CAMLreturn(Val_unit);
  28.371 -}
  28.372 -
  28.373 -
  28.374 -/*
  28.375 - * proc_read_memory : context_t -> int32 -> int -> unit
  28.376 - */
  28.377 -value
  28.378 -proc_read_memory (value context, value address, value length)
  28.379 -{
  28.380 -    CAMLparam3(context, address, length);
  28.381 -
  28.382 -    context_t ctx;
  28.383 -    pdb_request_t req;
  28.384 -
  28.385 -    decode_context(&ctx, context);
  28.386 -
  28.387 -    req.operation = PDB_OPCODE_RD_MEM;
  28.388 -    req.process = ctx.process;
  28.389 -    req.u.rd_mem.address = Int32_val(address);
  28.390 -    req.u.rd_mem.length  = Int_val(length);
  28.391 -
  28.392 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.393 -    
  28.394 -    CAMLreturn(Val_unit);
  28.395 -}
  28.396 -
  28.397 -
  28.398 -/*
  28.399 - * proc_write_memory : context_t -> int32 -> int list -> unit
  28.400 - */
  28.401 -value
  28.402 -proc_write_memory (value context, value address, value val_list)
  28.403 -{
  28.404 -    CAMLparam3(context, address, val_list);
  28.405 -    CAMLlocal1(node);
  28.406 -
  28.407 -    context_t ctx;
  28.408 -    pdb_request_t req;
  28.409 -    uint32_t length = 0;
  28.410 -
  28.411 -    decode_context(&ctx, context);
  28.412 -
  28.413 -    req.operation = PDB_OPCODE_WR_MEM;
  28.414 -    req.process = ctx.process;
  28.415 -
  28.416 -    node = val_list;
  28.417 -    if ( Int_val(node) == 0 )       /* gdb functionalty test uses empty list */
  28.418 -    {
  28.419 -        req.u.wr_mem.address = Int32_val(address);
  28.420 -        req.u.wr_mem.length  = 0;
  28.421 -    }
  28.422 -    else
  28.423 -    {
  28.424 -        while ( Int_val(Field(node,1)) != 0 )
  28.425 -        {
  28.426 -            req.u.wr_mem.data[length++] = Int_val(Field(node, 0));
  28.427 -            node = Field(node,1);
  28.428 -        }
  28.429 -        req.u.wr_mem.data[length++] = Int_val(Field(node, 0));
  28.430 -        
  28.431 -        req.u.wr_mem.address = Int32_val(address);
  28.432 -        req.u.wr_mem.length  = length;
  28.433 -    }
  28.434 - 
  28.435 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.436 -   
  28.437 -    CAMLreturn(Val_unit);
  28.438 -}
  28.439 -
  28.440 -
  28.441 -/*
  28.442 - * proc_continue_target : context_t -> unit
  28.443 - */
  28.444 -value
  28.445 -proc_continue_target (value context)
  28.446 -{
  28.447 -    CAMLparam1(context);
  28.448 -
  28.449 -    context_t ctx;
  28.450 -    pdb_request_t req;
  28.451 -
  28.452 -    decode_context(&ctx, context);
  28.453 -
  28.454 -    req.operation = PDB_OPCODE_CONTINUE;
  28.455 -    req.process = ctx.process;
  28.456 - 
  28.457 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.458 -
  28.459 -    CAMLreturn(Val_unit);
  28.460 -}
  28.461 -
  28.462 -/*
  28.463 - * proc_step_target : context_t -> unit
  28.464 - */
  28.465 -value
  28.466 -proc_step_target (value context)
  28.467 -{
  28.468 -    CAMLparam1(context);
  28.469 -
  28.470 -    context_t ctx;
  28.471 -    pdb_request_t req;
  28.472 -
  28.473 -    decode_context(&ctx, context);
  28.474 -
  28.475 -    req.operation = PDB_OPCODE_STEP;
  28.476 -    req.process = ctx.process;
  28.477 - 
  28.478 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.479 -
  28.480 -    CAMLreturn(Val_unit);
  28.481 -}
  28.482 -
  28.483 -
  28.484 -
  28.485 -/*
  28.486 - * proc_insert_memory_breakpoint : context_t -> int32 -> int -> unit
  28.487 - */
  28.488 -value
  28.489 -proc_insert_memory_breakpoint (value context, value address, value length)
  28.490 -{
  28.491 -    CAMLparam3(context, address, length);
  28.492 -
  28.493 -    context_t ctx;
  28.494 -    pdb_request_t req;
  28.495 -
  28.496 -    decode_context(&ctx, context);
  28.497 -
  28.498 -    req.operation = PDB_OPCODE_SET_BKPT;
  28.499 -    req.process = ctx.process;
  28.500 -    req.u.bkpt.address = (unsigned long) Int32_val(address);
  28.501 -    req.u.bkpt.length  =  Int_val(length);
  28.502 -
  28.503 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.504 -
  28.505 -    CAMLreturn(Val_unit);
  28.506 -}
  28.507 -
  28.508 -/*
  28.509 - * proc_remove_memory_breakpoint : context_t -> int32 -> int -> unit
  28.510 - */
  28.511 -value
  28.512 -proc_remove_memory_breakpoint (value context, value address, value length)
  28.513 -{
  28.514 -    CAMLparam3(context, address, length);
  28.515 -
  28.516 -    context_t ctx;
  28.517 -    pdb_request_t req;
  28.518 -
  28.519 -    decode_context(&ctx, context);
  28.520 -
  28.521 -    req.operation = PDB_OPCODE_CLR_BKPT;
  28.522 -    req.process = ctx.process;
  28.523 -    req.u.bkpt.address = (unsigned long) Int32_val(address);
  28.524 -    req.u.bkpt.length  =  Int_val(length);
  28.525 -
  28.526 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.527 -
  28.528 -    CAMLreturn(Val_unit);
  28.529 -}
  28.530 -
  28.531 -/*
  28.532 - * proc_insert_watchpoint : context_t -> bwcpoint_t -> int32 -> int -> unit
  28.533 - */
  28.534 -value
  28.535 -proc_insert_watchpoint (value context, value kind, value address, value length)
  28.536 -{
  28.537 -    CAMLparam3(context, address, length);
  28.538 -
  28.539 -    context_t ctx;
  28.540 -    pdb_request_t req;
  28.541 -
  28.542 -    decode_context(&ctx, context);
  28.543 -
  28.544 -    req.operation = PDB_OPCODE_SET_WATCHPT;
  28.545 -    req.process = ctx.process;
  28.546 -    req.u.watchpt.type    =  Int_val(kind);
  28.547 -    req.u.watchpt.address = (unsigned long) Int32_val(address);
  28.548 -    req.u.watchpt.length  =  Int_val(length);
  28.549 -
  28.550 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.551 -
  28.552 -    CAMLreturn(Val_unit);
  28.553 -}
  28.554 -
  28.555 -/*
  28.556 - * proc_remove_watchpoint : context_t -> bwcpoint_t -> int32 -> int -> unit
  28.557 - */
  28.558 -value
  28.559 -proc_remove_watchpoint (value context, value kind, value address, value length)
  28.560 -{
  28.561 -    CAMLparam3(context, address, length);
  28.562 -
  28.563 -    context_t ctx;
  28.564 -    pdb_request_t req;
  28.565 -
  28.566 -    decode_context(&ctx, context);
  28.567 -
  28.568 -    req.operation = PDB_OPCODE_CLR_WATCHPT;
  28.569 -    req.process = ctx.process;
  28.570 -    req.u.watchpt.type    =  Int_val(kind);
  28.571 -    req.u.watchpt.address = (unsigned long) Int32_val(address);
  28.572 -    req.u.watchpt.length  =  Int_val(length);
  28.573 -
  28.574 -    send_request(ctx.ring, ctx.evtchn, &req);
  28.575 -
  28.576 -    CAMLreturn(Val_unit);
  28.577 -}
  28.578 -
  28.579 -
  28.580 -/*
  28.581 - * Local variables:
  28.582 - * mode: C
  28.583 - * c-set-style: "BSD"
  28.584 - * c-basic-offset: 4
  28.585 - * tab-width: 4
  28.586 - * indent-tabs-mode: nil
  28.587 - * End:
  28.588 - */
  28.589 -
  28.590 -
    29.1 --- a/tools/debugger/pdb/pdb_caml_xc.c	Fri Sep 29 11:11:49 2006 +0100
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,170 +0,0 @@
    29.4 -/*
    29.5 - * pdb_caml_xc.c
    29.6 - *
    29.7 - * http://www.cl.cam.ac.uk/netos/pdb
    29.8 - *
    29.9 - * PDB's OCaml interface library for debugging domains
   29.10 - */
   29.11 -
   29.12 -#include <xenctrl.h>
   29.13 -#include <xendebug.h>
   29.14 -#include <errno.h>
   29.15 -#include <stdio.h>
   29.16 -#include <stdlib.h>
   29.17 -#include <string.h>
   29.18 -#include <sys/mman.h>
   29.19 -#include <caml/alloc.h>
   29.20 -#include <caml/fail.h>
   29.21 -#include <caml/memory.h>
   29.22 -#include <caml/mlvalues.h>
   29.23 -
   29.24 -#include "pdb_caml_xen.h"
   29.25 -
   29.26 -int xc_handle = -1;
   29.27 -
   29.28 -
   29.29 -/****************************************************************************/
   29.30 -
   29.31 -/*
   29.32 - * open_context : unit -> unit
   29.33 - */
   29.34 -value
   29.35 -open_context (value unit)
   29.36 -{
   29.37 -    CAMLparam1(unit);
   29.38 -
   29.39 -    xc_handle = xc_interface_open();
   29.40 -
   29.41 -    if ( xc_handle < 0 )
   29.42 -    {
   29.43 -        fprintf(stderr, "(pdb) error opening xc interface: %d (%s)\n",
   29.44 -                errno, strerror(errno));
   29.45 -    }
   29.46 -
   29.47 -    CAMLreturn(Val_unit);
   29.48 -}
   29.49 -
   29.50 -/*
   29.51 - * close_context : unit -> unit
   29.52 - */
   29.53 -value
   29.54 -close_context (value unit)
   29.55 -{
   29.56 -    CAMLparam1(unit);
   29.57 -    int rc;
   29.58 -    
   29.59 -    if ( (rc = xc_interface_close(xc_handle)) < 0 )
   29.60 -    {
   29.61 -        fprintf(stderr, "(pdb) error closing xc interface: %d (%s)\n",
   29.62 -                errno, strerror(errno));
   29.63 -    }
   29.64 -
   29.65 -    CAMLreturn(Val_unit);
   29.66 -}
   29.67 -
   29.68 -
   29.69 -/*********************************************************************/
   29.70 -
   29.71 -void
   29.72 -dump_regs (cpu_user_regs_t *regs)
   29.73 -{
   29.74 -    printf ("   eax: %x\n", regs->eax);
   29.75 -    printf ("   ecx: %x\n", regs->ecx);
   29.76 -    printf ("   edx: %x\n", regs->edx);
   29.77 -    printf ("   ebx: %x\n", regs->ebx);
   29.78 -    printf ("   esp: %x\n", regs->esp);
   29.79 -    printf ("   ebp: %x\n", regs->ebp);
   29.80 -    printf ("   esi: %x\n", regs->esi);
   29.81 -    printf ("   edi: %x\n", regs->edi);
   29.82 -    printf ("   eip: %x\n", regs->eip);
   29.83 -    printf (" flags: %x\n", regs->eflags);
   29.84 -    printf ("    cs: %x\n", regs->cs);
   29.85 -    printf ("    ss: %x\n", regs->ss);
   29.86 -    printf ("    es: %x\n", regs->es);
   29.87 -    printf ("    ds: %x\n", regs->ds);
   29.88 -    printf ("    fs: %x\n", regs->fs);
   29.89 -    printf ("    gs: %x\n", regs->gs);
   29.90 -
   29.91 -    return;
   29.92 -}
   29.93 -
   29.94 -/*
   29.95 - * debugger_status : unit -> unit
   29.96 - */
   29.97 -value
   29.98 -debugger_status (value unit)
   29.99 -{
  29.100 -    CAMLparam1(unit);
  29.101 -
  29.102 -    CAMLreturn(Val_unit);
  29.103 -}
  29.104 -
  29.105 -/****************************************************************************/
  29.106 -/****************************************************************************/
  29.107 -
  29.108 -/*
  29.109 - * evtchn_bind_virq : int -> int
  29.110 - */
  29.111 -value
  29.112 -evtchn_bind_virq (value virq)
  29.113 -{
  29.114 -    CAMLparam1(virq);
  29.115 -
  29.116 -    int port;
  29.117 -    int my_virq = Int_val(virq);
  29.118 -
  29.119 -    if ( xc_evtchn_bind_virq(xc_handle, my_virq, &port) < 0 )
  29.120 -    {
  29.121 -        printf("(pdb) evtchn_bind_virq error!\n");  fflush(stdout);
  29.122 -        failwith("evtchn_bind_virq error");
  29.123 -    }
  29.124 -
  29.125 -    CAMLreturn(Val_int(port));
  29.126 -}
  29.127 -
  29.128 -/*
  29.129 - * evtchn_bind_interdomain : int -> int * int
  29.130 - */
  29.131 -value
  29.132 -evtchn_bind_interdomain (value remote_domain)
  29.133 -{
  29.134 -    CAMLparam1(remote_domain);
  29.135 -    CAMLlocal1(result);
  29.136 -
  29.137 -    int my_remote_domain = Int_val(remote_domain);
  29.138 -    int local_domain = 0;
  29.139 -    int local_port = 0;
  29.140 -    int remote_port = 0;
  29.141 -
  29.142 -    if ( xc_evtchn_bind_interdomain(xc_handle, local_domain, my_remote_domain,
  29.143 -                                    &local_port, &remote_port) < 0 )
  29.144 -    {
  29.145 -        printf("(pdb) evtchn_bind_interdomain error!\n");  fflush(stdout);
  29.146 -        failwith("evtchn_bind_interdomain error");
  29.147 -    }
  29.148 -
  29.149 -    result = caml_alloc_tuple(2);                                   /* FIXME */
  29.150 -    Store_field(result, 0, Val_int(local_port));
  29.151 -    Store_field(result, 1, Val_int(remote_port));
  29.152 -
  29.153 -    CAMLreturn(result);
  29.154 -}
  29.155 -
  29.156 -void *
  29.157 -map_ring(uint32_t dom, unsigned long mfn )
  29.158 -{
  29.159 -    return xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
  29.160 -                                PROT_READ | PROT_WRITE, mfn);
  29.161 -}
  29.162 -
  29.163 -
  29.164 -/*
  29.165 - * Local variables:
  29.166 - * mode: C
  29.167 - * c-set-style: "BSD"
  29.168 - * c-basic-offset: 4
  29.169 - * tab-width: 4
  29.170 - * indent-tabs-mode: nil
  29.171 - * End:
  29.172 - */
  29.173 -
    30.1 --- a/tools/debugger/pdb/pdb_caml_xcs.c	Fri Sep 29 11:11:49 2006 +0100
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,307 +0,0 @@
    30.4 -/*
    30.5 - * xcs stuff
    30.6 - *
    30.7 - * http://www.cl.cam.ac.uk/netos/pdb
    30.8 - *
    30.9 - * this is responsible for establishing the initial connection
   30.10 - * between a backend domain and the pdb server.
   30.11 - *
   30.12 - * liberated from xu.c
   30.13 - *
   30.14 - */
   30.15 -
   30.16 -#include <stdio.h>
   30.17 -#include <stdlib.h>
   30.18 -#include <unistd.h>
   30.19 -#include <sys/un.h>
   30.20 -#include <sys/types.h>
   30.21 -#include <sys/socket.h>
   30.22 -#include <errno.h>
   30.23 -#include <xenctrl.h>
   30.24 -
   30.25 -#include <xen/xen.h>
   30.26 -#include <xen/io/domain_controller.h>
   30.27 -
   30.28 -#include <arpa/inet.h>
   30.29 -#include <xcs_proto.h>
   30.30 -
   30.31 -#include <caml/alloc.h>
   30.32 -#include <caml/fail.h>
   30.33 -#include <caml/memory.h>
   30.34 -#include <caml/mlvalues.h>
   30.35 -
   30.36 -static int control_fd = -1;
   30.37 -
   30.38 -#include "pdb_module.h"
   30.39 -#include "pdb_caml_xen.h"
   30.40 -
   30.41 -void *map_ring(uint32_t dom, unsigned long mfn );
   30.42 -
   30.43 -/*
   30.44 - * xcs_initialize_ring : int -> int32 -> int32
   30.45 - *
   30.46 - * initialize a communications ring
   30.47 - * (probably belongs in a different file :)
   30.48 - */
   30.49 -
   30.50 -value
   30.51 -xcs_initialize_ring (value domain, value ring)
   30.52 -{
   30.53 -    CAMLparam2(domain, ring);
   30.54 -    int my_domain = Int_val(domain);
   30.55 -    unsigned long my_ring = Int32_val(ring);
   30.56 -
   30.57 -    pdb_front_ring_t *front_ring;
   30.58 -    pdb_sring_t *sring;
   30.59 -
   30.60 -    front_ring = (pdb_front_ring_t *)malloc(sizeof(pdb_front_ring_t));
   30.61 -    if ( front_ring == NULL )
   30.62 -    {
   30.63 -        printf("(pdb) xcs initialize ring: malloc failed.\n");  fflush(stdout);
   30.64 -        failwith("xcs initialize ring: malloc");
   30.65 -    }
   30.66 -
   30.67 -    sring = map_ring(my_domain, my_ring);
   30.68 -    if ( sring == NULL )
   30.69 -    {
   30.70 -        printf("(pdb) xcs initialize ring: map ring failed.\n");fflush(stdout);
   30.71 -        failwith("xcs initialize ring: map ring");
   30.72 -    }
   30.73 -    FRONT_RING_INIT(front_ring, sring, PAGE_SIZE);
   30.74 -
   30.75 -    CAMLreturn(caml_copy_int32((unsigned long)front_ring));
   30.76 -}
   30.77 -
   30.78 -
   30.79 -/*
   30.80 - * xcs_write_message : Unix.file_descr -> xcs_message -> unit
   30.81 - *
   30.82 - * ack a packet
   30.83 - */
   30.84 -value
   30.85 -xcs_write_message (value data_fd, value msg)
   30.86 -{
   30.87 -    CAMLparam2(data_fd, msg);
   30.88 -    int my_data_fd = Int_val(data_fd);
   30.89 -    xcs_msg_t my_msg;
   30.90 -    pdb_connection_p conn;
   30.91 -
   30.92 -    my_msg.type = XCS_REQUEST;
   30.93 -    my_msg.u.control.remote_dom = Int_val(Field(msg,0));
   30.94 -    my_msg.u.control.msg.type = CMSG_DEBUG;
   30.95 -    my_msg.u.control.msg.subtype = CMSG_DEBUG_CONNECTION_STATUS;
   30.96 -    my_msg.u.control.msg.id = 0;
   30.97 -    my_msg.u.control.msg.length = sizeof(pdb_connection_t);
   30.98 -
   30.99 -    conn = (pdb_connection_p)my_msg.u.control.msg.msg;
  30.100 -
  30.101 -    conn->status = Int_val(Field(msg,1));
  30.102 -    conn->ring = Int32_val(Field(msg,2));
  30.103 -    conn->evtchn = Int_val(Field(msg,3));
  30.104 -        
  30.105 -    send(my_data_fd, &my_msg, sizeof(xcs_msg_t), 0);                  /* ack */
  30.106 -
  30.107 -    CAMLreturn(Val_unit);
  30.108 -}
  30.109 -
  30.110 -/*
  30.111 - * xcs_read_message : Unix.file_descr -> xcs_message
  30.112 - *
  30.113 - * read pending data on xcs socket.
  30.114 - */
  30.115 -
  30.116 -value
  30.117 -xcs_read_message (value data_fd)
  30.118 -{
  30.119 -    CAMLparam1(data_fd);
  30.120 -    CAMLlocal1(result);
  30.121 -    int my_data_fd = Int_val(data_fd);
  30.122 -    xcs_msg_t msg;
  30.123 -
  30.124 -    if ( read(my_data_fd, &msg, sizeof(xcs_msg_t)) < 0 )
  30.125 -    {
  30.126 -        perror("read");
  30.127 -        failwith("xcs message: read");
  30.128 -    }
  30.129 -
  30.130 -    switch (msg.type)
  30.131 -    {
  30.132 -    case XCS_REQUEST :
  30.133 -    {
  30.134 -        pdb_connection_p conn;
  30.135 -
  30.136 -        if ( msg.u.control.msg.type != CMSG_DEBUG ||
  30.137 -             msg.u.control.msg.subtype != CMSG_DEBUG_CONNECTION_STATUS )
  30.138 -        {
  30.139 -            printf("bogus message type: %d %d\n", 
  30.140 -                   msg.u.control.msg.type, msg.u.control.msg.subtype);
  30.141 -            failwith("xcs message: invalid message type");
  30.142 -        }
  30.143 -
  30.144 -        conn = (pdb_connection_p) msg.u.control.msg.msg;
  30.145 -        
  30.146 -        result = caml_alloc_tuple(4);                               /* FIXME */
  30.147 -        Store_field(result, 0, Val_int(msg.u.control.remote_dom)); /* domain */
  30.148 -        Store_field(result, 1, Val_int(conn->status));             /* status */
  30.149 -        Store_field(result, 2, caml_copy_int32(conn->ring));         /* ring */
  30.150 -        Store_field(result, 3, Val_int(0));                   /* OUT: evtchn */
  30.151 -
  30.152 -        break;
  30.153 -    }
  30.154 -    case XCS_RESPONSE :
  30.155 -    {
  30.156 -        printf("[XCS RESPONSE]  type: %d, remote_dom: %d\n", 
  30.157 -               msg.type, msg.u.control.remote_dom);
  30.158 -        printf("strange.  we never initiate messages, so what is the ");
  30.159 -        printf("domain responding to?\n");
  30.160 -        failwith ("xcs message: resonse");
  30.161 -        break;
  30.162 -    }
  30.163 -    default:
  30.164 -    {
  30.165 -        printf("[XCS IGNORE] type: %d\n", msg.type);
  30.166 -        failwith ("xcs message: unknown");
  30.167 -        break;
  30.168 -    }
  30.169 -    }
  30.170 -
  30.171 -    CAMLreturn(result);
  30.172 -}
  30.173 -
  30.174 -/*
  30.175 - * xcs_connect : string -> int -> Unix.file_descr
  30.176 - */
  30.177 -
  30.178 -value
  30.179 -xcs_connect (value path, value msg_type)
  30.180 -{
  30.181 -    CAMLparam2(path, msg_type);
  30.182 -    char *my_path = String_val(path);
  30.183 -    int my_msg_type = Int_val(msg_type);
  30.184 -    struct sockaddr_un addr;
  30.185 -    uint32_t session_id = 0;
  30.186 -    int data_fd;
  30.187 -    int ret, len;
  30.188 -    xcs_msg_t msg;
  30.189 -
  30.190 -    /* setup control channel connection to xcs */
  30.191 -
  30.192 -    control_fd = socket(AF_UNIX, SOCK_STREAM, 0);
  30.193 -    if ( control_fd < 0 )
  30.194 -    {
  30.195 -        printf("error creating xcs socket!\n");
  30.196 -        goto fail;
  30.197 -    }
  30.198 -
  30.199 -    addr.sun_family = AF_UNIX;
  30.200 -    strcpy(addr.sun_path, my_path);
  30.201 -    len = sizeof(addr.sun_family) + strlen(addr.sun_path) + 1;
  30.202 -
  30.203 -    ret = connect(control_fd, (struct sockaddr *)&addr, len);
  30.204 -    if (ret < 0) 
  30.205 -    {
  30.206 -        printf("error connecting to xcs (ctrl)! (%d)\n", errno);
  30.207 -        goto ctrl_fd_fail;
  30.208 -    }
  30.209 -            
  30.210 -    msg.type = XCS_CONNECT_CTRL;
  30.211 -    msg.u.connect.session_id = session_id;
  30.212 -    send(control_fd, &msg, sizeof(xcs_msg_t), 0);
  30.213 -    /* bug: this should have a timeout & error! */
  30.214 -    read(control_fd, &msg, sizeof(xcs_msg_t));
  30.215 -    
  30.216 -    if (msg.result != XCS_RSLT_OK)
  30.217 -    {
  30.218 -        printf("error connecting xcs control channel!\n");
  30.219 -        goto ctrl_fd_fail;
  30.220 -    }
  30.221 -    session_id = msg.u.connect.session_id;
  30.222 -
  30.223 -
  30.224 -    /* setup data channel connection to xcs */
  30.225 -    
  30.226 -    data_fd = socket(AF_UNIX, SOCK_STREAM, 0);
  30.227 -    if ( data_fd < 0 )
  30.228 -    {
  30.229 -        printf("error creating xcs data socket!\n");
  30.230 -        goto ctrl_fd_fail;
  30.231 -    }
  30.232 -    
  30.233 -    addr.sun_family = AF_UNIX;
  30.234 -    strcpy(addr.sun_path, my_path);
  30.235 -    len = sizeof(addr.sun_family) + strlen(addr.sun_path) + 1;
  30.236 -    
  30.237 -    ret = connect(data_fd, (struct sockaddr *)&addr, len);
  30.238 -    if (ret < 0) 
  30.239 -    {
  30.240 -        printf("error connecting to xcs (data)! (%d)\n", errno);
  30.241 -        goto data_fd_fail;
  30.242 -    }
  30.243 -
  30.244 -    msg.type = XCS_CONNECT_DATA;
  30.245 -    msg.u.connect.session_id = session_id;
  30.246 -    send(data_fd, &msg, sizeof(xcs_msg_t), 0);
  30.247 -    read(data_fd, &msg, sizeof(xcs_msg_t));                      /* same bug */
  30.248 -    
  30.249 -    if ( msg.result != XCS_RSLT_OK )
  30.250 -    {
  30.251 -        printf("error connecting xcs control channel!\n");
  30.252 -        goto ctrl_fd_fail;
  30.253 -    }
  30.254 -
  30.255 -
  30.256 -
  30.257 -    /* now request all messages of a particular type */
  30.258 -
  30.259 -    msg.type = XCS_MSG_BIND;
  30.260 -    msg.u.bind.port = PORT_WILDCARD;
  30.261 -    msg.u.bind.type = my_msg_type;
  30.262 -    send(control_fd, &msg, sizeof(xcs_msg_t), 0);
  30.263 -    read(control_fd, &msg, sizeof(xcs_msg_t));                /* still buggy */
  30.264 -
  30.265 -    if (msg.result != XCS_RSLT_OK) {
  30.266 -        printf ("error: MSG BIND\n");
  30.267 -	goto bind_fail;
  30.268 -    }
  30.269 -
  30.270 -    CAMLreturn(Val_int(data_fd));
  30.271 -
  30.272 -bind_fail:
  30.273 -data_fd_fail: 
  30.274 -    close(data_fd);  
  30.275 -    
  30.276 -ctrl_fd_fail:
  30.277 -    close(control_fd);
  30.278 -     
  30.279 -fail:
  30.280 -    failwith("xcs connection error");             /* should be more explicit */
  30.281 -}
  30.282 -
  30.283 -
  30.284 -/* xcs_disconnect: Unix.file_descr -> unit */
  30.285 -
  30.286 -value
  30.287 -xcs_disconnect (value data_fd)
  30.288 -{
  30.289 -    CAMLparam1(data_fd);
  30.290 -
  30.291 -    int my_data_fd = Int_val(data_fd);
  30.292 -
  30.293 -    close(my_data_fd);
  30.294 -    close(control_fd);
  30.295 -    control_fd = -1;
  30.296 -
  30.297 -    CAMLreturn(Val_unit);
  30.298 -}
  30.299 -
  30.300 -
  30.301 -/*
  30.302 - * Local variables:
  30.303 - * mode: C
  30.304 - * c-set-style: "BSD"
  30.305 - * c-basic-offset: 4
  30.306 - * tab-width: 4
  30.307 - * indent-tabs-mode: nil
  30.308 - * End:
  30.309 - */
  30.310 -
    31.1 --- a/tools/debugger/pdb/pdb_caml_xen.h	Fri Sep 29 11:11:49 2006 +0100
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,39 +0,0 @@
    31.4 -/*
    31.5 - * pdb_caml_xen.h
    31.6 - *
    31.7 - * http://www.cl.cam.ac.uk/netos/pdb
    31.8 - *
    31.9 - * generic xen definitions
   31.10 - *
   31.11 - */
   31.12 -
   31.13 -#ifndef _PDB_CAML_XEN_DEFINED_
   31.14 -#define _PDB_CAML_XEN_DEFINED_
   31.15 -
   31.16 -enum gdb_registers { /* 32 */ GDB_EAX, GDB_ECX, GDB_EDX, GDB_EBX,
   31.17 -                              GDB_ESP, GDB_EBP, GDB_ESI, GDB_EDI,
   31.18 -                              GDB_EIP, GDB_EFL, 
   31.19 -                     /* 16 */ GDB_CS,  GDB_SS,  GDB_DS,  GDB_ES,
   31.20 -                              GDB_FS,  GDB_GS };
   31.21 -#define GDB_REGISTER_FRAME_SIZE 16
   31.22 -
   31.23 -/* this order comes from linux-2.6.11/include/asm-i386/ptrace.h */
   31.24 -enum x86_registers { LINUX_EBX, LINUX_ECX, LINUX_EDX, LINUX_ESI, LINUX_EDI,
   31.25 -                     LINUX_EBP, LINUX_EAX, LINUX_DS,  LINUX_ES,  LINUX_FS,
   31.26 -                     LINUX_GS,  LINUX_ORIG_EAX, LINUX_EIP, LINUX_CS, LINUX_EFL,
   31.27 -                     LINUX_ESP, LINUX_SS };
   31.28 -#define REGISTER_FRAME_SIZE 17
   31.29 -
   31.30 -
   31.31 -/* hack: this is also included from the pdb linux module which
   31.32 -   has PAGE_SIZE defined */
   31.33 -#ifndef PAGE_SIZE
   31.34 -#define PAGE_SIZE 4096
   31.35 -#endif
   31.36 -
   31.37 -extern int xc_handle;
   31.38 -
   31.39 -void dump_regs (cpu_user_regs_t *ctx);
   31.40 -
   31.41 -#endif
   31.42 -
    32.1 --- a/tools/debugger/pdb/pdb_xen.c	Fri Sep 29 11:11:49 2006 +0100
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,75 +0,0 @@
    32.4 -/*
    32.5 - * pdb_xen.c
    32.6 - *
    32.7 - * alex ho
    32.8 - * http://www.cl.cam.ac.uk/netos/pdb
    32.9 - *
   32.10 - * PDB interface library for accessing Xen
   32.11 - */
   32.12 -
   32.13 -#include <xenctrl.h>
   32.14 -#include <stdio.h>
   32.15 -#include <stdlib.h>
   32.16 -#include <errno.h>
   32.17 -#include <string.h>
   32.18 -#include <sys/mman.h>
   32.19 -
   32.20 -int
   32.21 -pdb_open ()
   32.22 -{
   32.23 -    int xc_handle = xc_interface_open();
   32.24 -
   32.25 -    if ( xc_handle < 0 )
   32.26 -    {
   32.27 -        fprintf(stderr, "(pdb) error opening xc interface: %d (%s)\n",
   32.28 -                errno, strerror(errno));
   32.29 -    }
   32.30 -    return xc_handle;
   32.31 -}
   32.32 -
   32.33 -int 
   32.34 -pdb_close (int xc_handle)
   32.35 -{
   32.36 -    int rc;
   32.37 -
   32.38 -    
   32.39 -    if ( (rc = xc_interface_close(xc_handle)) < 0 )
   32.40 -    {
   32.41 -        fprintf(stderr, "(pdb) error closing xc interface: %d (%s)\n",
   32.42 -                errno, strerror(errno));
   32.43 -    }
   32.44 -    return rc;
   32.45 -}
   32.46 -
   32.47 -
   32.48 -#include <sys/ioctl.h>
   32.49 -#include <xen/linux/evtchn.h>
   32.50 -
   32.51 -int
   32.52 -xen_evtchn_bind (int evtchn_fd, int idx)
   32.53 -{
   32.54 -    if ( ioctl(evtchn_fd, EVTCHN_BIND, idx) != 0 )
   32.55 -        return -errno;
   32.56 -    
   32.57 -    return 0;
   32.58 -}
   32.59 -
   32.60 -int 
   32.61 -xen_evtchn_unbind (int evtchn_fd, int idx)
   32.62 -{
   32.63 -    if ( ioctl(evtchn_fd, EVTCHN_UNBIND, idx) != 0 )
   32.64 -        return -errno;
   32.65 -
   32.66 -    return 0;
   32.67 -}
   32.68 -
   32.69 -
   32.70 -/*
   32.71 - * Local variables:
   32.72 - * mode: C
   32.73 - * c-set-style: "BSD"
   32.74 - * c-basic-offset: 4
   32.75 - * tab-width: 4
   32.76 - * indent-tabs-mode: nil
   32.77 - * End:
   32.78 - */
    33.1 --- a/tools/debugger/pdb/readme	Fri Sep 29 11:11:49 2006 +0100
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,105 +0,0 @@
    33.4 -
    33.5 -PDB 0.3.3
    33.6 -http://www.cl.cam.ac.uk/netos/pdb
    33.7 -
    33.8 -Alex Ho  
    33.9 -August 2005
   33.10 -
   33.11 -
   33.12 -This is the latest incarnation of the pervasive debugger.
   33.13 -PDB is a remote stub for GDB.  Running as a user-space
   33.14 -application in domain 0, it can debug any other domain.
   33.15 -
   33.16 -
   33.17 -+------+    tcp/ip    +-------+  
   33.18 -| GDB  |--------------|  PDB  |
   33.19 -+------+              +-------+   +-------+
   33.20 -                      | Dom 0 |   | Dom U |
   33.21 -                      +-------+---+-------+
   33.22 -                      |  Xen              |
   33.23 -                      +-------------------+
   33.24 -
   33.25 -Installation
   33.26 -
   33.27 -- Install OCaml 3.08 in domain 0.
   33.28 -  http://caml.inria.fr/download.en.html  is a good place to start.
   33.29 -
   33.30 -- Build Xen with debugger support
   33.31 -  make domu_debug=y xen
   33.32 -
   33.33 -- (optional)
   33.34 -  Build the target domains with debugging symbols.
   33.35 -  make CONFIG_DEBUG_INFO=true CONFIG_FRAME_POINTER=false linux-2.6-xenU-build
   33.36 -
   33.37 -  You can also change linux-2.6.12-xenU/Makefile
   33.38 -  CONFIG_CC_OPTIMIZE_FOR_SIZE from -O2 to -O
   33.39 -
   33.40 -- Build PDB
   33.41 -  (cd tools/debugger/libxendebug; make install)
   33.42 -  (cd tools/debugger/pdb; make)
   33.43 -
   33.44 -Usage
   33.45 -
   33.46 -- PDB does not currently support SMP.  Please boot xen with "maxcpus=1"
   33.47 -
   33.48 -- Run PDB
   33.49 -  domain-0.xeno# ./pdb <port>
   33.50 -
   33.51 -- Run GDB
   33.52 -  hostname% gdb <xeno.bk>/dist/install/boot/vmlinux-syms-2.6.12-xenU
   33.53 -
   33.54 -  (gdb) target remote domain-0.xeno:<port>
   33.55 -
   33.56 -  At this point, you'll get an error message such as:
   33.57 -  Remote debugging using domain-0.xeno:5000
   33.58 -  0x00000000 in ?? ()
   33.59 -  warning: shared library handler failed to enable breakpoint
   33.60 -  Although GDB is connected to PDB, PDB doesn't know which domain
   33.61 -  you'd like to debug, so it's just feeding GDB a bunch of zeros.
   33.62 -
   33.63 -  (gdb) maint packet x context = domain <domid> <vcpu>
   33.64 -
   33.65 -  This tells PDB that we'd like to debug a particular domain & vcpu.
   33.66 -  However, since we're sending the command directly to PDB, GDB doesn't 
   33.67 -  know that we now have a proper target.  We can force GDB to invalidate
   33.68 -  its register cache.  This is optional; the next time the program
   33.69 -  stops GDB will query for the registers automatically.
   33.70 -
   33.71 -  (gdb) flushreg
   33.72 -
   33.73 -  
   33.74 -  the following gdb commands should work :)
   33.75 -
   33.76 -  break
   33.77 -  step,   stepi
   33.78 -  next,   nexti
   33.79 -  continue
   33.80 -  print
   33.81 -
   33.82 -Process
   33.83 -
   33.84 -  PDB can also debug a process running in a Linux 2.6 domain. 
   33.85 -  You will need to patch the Linux 2.6 domain U tree to export some
   33.86 -  additional symbols for the pdb module
   33.87 -
   33.88 -  % make -C linux-2.6-patches
   33.89 -
   33.90 -  After running PDB in domain 0, insert the pdb module in dom u:
   33.91 -  
   33.92 -  % insmod linux-2.6-module/pdb.ko
   33.93 -
   33.94 -  Load GDB with the appropriate symbols, and attach with
   33.95 -
   33.96 -  (gdb) maint packet x context = process <domid> <pid>
   33.97 -
   33.98 -  Read, write, and access watchpoint should also work for processes, 
   33.99 -  use the "rwatch", "watch" and "awatch" gdb commands respectively.
  33.100 -
  33.101 -  If you are having trouble with GDB 5.3 (i386-redhat-linux-gnu),
  33.102 -  try GDB 6.3 (configured with --target=i386-linux-gnu).
  33.103 -
  33.104 -  
  33.105 -To Do
  33.106 -
  33.107 -- watchpoints for domains
  33.108 -- support for SMP
    34.1 --- a/tools/debugger/pdb/server.ml	Fri Sep 29 11:11:49 2006 +0100
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,241 +0,0 @@
    34.4 -(** server.ml
    34.5 - *
    34.6 - *  PDB server main loop
    34.7 - *
    34.8 - *  @author copyright (c) 2005 alex ho
    34.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   34.10 - *  @version 1
   34.11 - *)
   34.12 -
   34.13 -open Unix
   34.14 -open Buffer
   34.15 -open Util
   34.16 -
   34.17 -(**
   34.18 - * connection_t: The state for each connection.
   34.19 - * buffer & length contains bytes that have been read from the sock
   34.20 - * but not yet parsed / processed.
   34.21 - *)
   34.22 -type connection_t =
   34.23 -{ 
   34.24 -          fd : file_descr;
   34.25 -  mutable buffer : string;
   34.26 -  mutable length : int;
   34.27 -}
   34.28 -
   34.29 -
   34.30 -(**
   34.31 - * validate_checksum:  Compute and compare the checksum of a string
   34.32 - * against the provided checksum using the gdb serial protocol algorithm.
   34.33 - *
   34.34 - *)
   34.35 -let validate_checksum command checksum =
   34.36 -  let c0 = ref 0 in
   34.37 -  for loop = 0 to (String.length command - 1) do
   34.38 -    c0 := !c0 + int_of_char(command.[loop]);
   34.39 -  done;
   34.40 -  if (String.length checksum) = 2 
   34.41 -  then
   34.42 -    let c1 = Util.int_of_hexchar(checksum.[1]) +
   34.43 -	     Util.int_of_hexchar(checksum.[0]) * 16 in
   34.44 -    (!c0 mod 256) = (c1 mod 256)
   34.45 -  else
   34.46 -    false
   34.47 -  
   34.48 -
   34.49 -(**
   34.50 - * process_input: Oh, joy!  Someone sent us a message.  Let's open the
   34.51 - * envelope and see what they have to say.
   34.52 - *
   34.53 - * This function is a paradigm of inefficiency; it performs as many 
   34.54 - * string copies as possible.
   34.55 - *)
   34.56 -let process_input conn sock = 
   34.57 -  let max_buffer_size = 1024 in
   34.58 -  let in_string = String.create max_buffer_size in
   34.59 -
   34.60 -  let length = read sock in_string 0 max_buffer_size in
   34.61 -  conn.buffer <- conn.buffer ^ (String.sub in_string 0 length);
   34.62 -  conn.length <- conn.length + length;
   34.63 -  let re = Str.regexp "[^\\$]*\\$\\([^#]*\\)#\\(..\\)" in
   34.64 -
   34.65 -  (* interrupt the target if there was a ctrl-c *)
   34.66 -  begin
   34.67 -    try
   34.68 -      let break = String.index conn.buffer '\003' + 1 in
   34.69 -      print_endline (Printf.sprintf "{{%s}}" (String.escaped conn.buffer));
   34.70 -
   34.71 -      (* discard everything seen before the ctrl-c *)
   34.72 -      conn.buffer <- String.sub conn.buffer break (conn.length - break);
   34.73 -      conn.length <- conn.length - break;
   34.74 -
   34.75 -      (* pause the target *)
   34.76 -      PDB.pause (PDB.find_context sock);
   34.77 -
   34.78 -      (* send a code back to the debugger *)
   34.79 -      Util.send_reply sock "S05"
   34.80 -
   34.81 -    with
   34.82 -      Not_found -> ()
   34.83 -  end;
   34.84 -
   34.85 -  (* with gdb this is unlikely to loop since you ack each packet *)
   34.86 -  while ( Str.string_match re conn.buffer 0 ) do
   34.87 -    let command = Str.matched_group 1 conn.buffer in
   34.88 -    let checksum = Str.matched_group 2 conn.buffer in
   34.89 -    let match_end = Str.group_end 2 in
   34.90 -
   34.91 -    begin
   34.92 -      match validate_checksum command checksum with
   34.93 -      | true -> 
   34.94 -	  begin
   34.95 -	    Util.write_character sock '+';
   34.96 -	    try
   34.97 -	      let reply = Debugger.process_command command sock in
   34.98 -	      print_endline (Printf.sprintf "[%s] %s -> \"%s\"" 
   34.99 -			       (Util.get_connection_info sock)
  34.100 -			       (String.escaped command) 
  34.101 -			       (String.escaped reply));
  34.102 -	      Util.send_reply sock reply
  34.103 -	    with
  34.104 -	      Util.No_reply ->
  34.105 -		print_endline (Printf.sprintf "[%s] %s -> null" 
  34.106 -				 (Util.get_connection_info sock)
  34.107 -				 (String.escaped command))
  34.108 -	  end
  34.109 -      | false ->
  34.110 -	  Util.write_character sock '-';
  34.111 -    end;
  34.112 -
  34.113 -    conn.buffer <- String.sub conn.buffer match_end (conn.length - match_end);
  34.114 -    conn.length <- conn.length - match_end;
  34.115 -  done;
  34.116 -  if length = 0 then raise End_of_file
  34.117 -
  34.118 -
  34.119 -
  34.120 -(** main_server_loop.
  34.121 - *
  34.122 - *  connection_hash is a hash (duh!) with one connection_t for each
  34.123 - *  open connection.
  34.124 - * 
  34.125 - *  in_list is a list of active sockets.  it also contains a number
  34.126 - *  of magic entries: 
  34.127 - *  - server_sock   for accepting new client connections (e.g. gdb)
  34.128 - *  - xen_virq_sock for Xen virq asynchronous notifications (via evtchn).
  34.129 - *                  This is used by context = domain
  34.130 - *  - xcs_sock      for xcs messages when a new backend domain registers
  34.131 - *                  This is used by context = process
  34.132 - *)
  34.133 -let main_server_loop sockaddr =
  34.134 -  let connection_hash = Hashtbl.create 10
  34.135 -  in
  34.136 -  let process_socket svr_sock sockets sock =
  34.137 -    let (new_list, closed_list) = sockets in
  34.138 -    if sock == svr_sock
  34.139 -    then
  34.140 -      begin
  34.141 -	let (new_sock, caller) = accept sock in
  34.142 -	print_endline (Printf.sprintf "[%s] new connection from %s"
  34.143 -			              (Util.get_connection_info sock)
  34.144 -			              (Util.get_connection_info new_sock));
  34.145 -	Hashtbl.add connection_hash new_sock 
  34.146 -	            {fd=new_sock; buffer=""; length = 0};
  34.147 -	PDB.add_default_context new_sock;
  34.148 -	(new_sock :: new_list, closed_list)
  34.149 -      end
  34.150 -    else
  34.151 -      begin
  34.152 -	try
  34.153 -	  match PDB.find_context sock with
  34.154 -	  | PDB.Xen_virq ->
  34.155 -	      print_endline (Printf.sprintf "[%s] Xen virq"
  34.156 -			                    (Util.get_connection_info sock));
  34.157 -	      Debugger.process_xen_virq sock;
  34.158 -	      (new_list, closed_list)
  34.159 -	  | PDB.Xen_xcs ->
  34.160 -	      print_endline (Printf.sprintf "[%s] Xen xcs"
  34.161 -			                    (Util.get_connection_info sock));
  34.162 -	      let new_xen_domain = Debugger.process_xen_xcs sock in
  34.163 -	      (new_xen_domain :: new_list, closed_list)
  34.164 -	  | PDB.Xen_domain d ->
  34.165 -	      print_endline (Printf.sprintf "[%s] Xen domain"
  34.166 -			                    (Util.get_connection_info sock));
  34.167 -	      Debugger.process_xen_domain sock;
  34.168 -	      (new_list, closed_list)
  34.169 -	  | _ ->
  34.170 -	      let conn = Hashtbl.find connection_hash sock in
  34.171 -	      process_input conn sock;
  34.172 -	      (new_list, closed_list)
  34.173 -	with
  34.174 -	| Not_found -> 
  34.175 -	    print_endline "error: (main_svr_loop) context not found";
  34.176 -	    PDB.debug_contexts ();
  34.177 -	    raise Not_found
  34.178 -	| End_of_file -> 
  34.179 -	    print_endline (Printf.sprintf "[%s] close connection from %s"
  34.180 -  			                   (Util.get_connection_info sock)
  34.181 -			                   (Util.get_connection_info sock));
  34.182 -	    PDB.delete_context sock;
  34.183 -	    Hashtbl.remove connection_hash sock;
  34.184 -	    close sock;
  34.185 -	    (new_list, sock :: closed_list)
  34.186 -      end
  34.187 -  in
  34.188 -
  34.189 -  let rec helper in_list server_sock =
  34.190 -
  34.191 -    (*    
  34.192 -     List.iter (fun x->Printf.printf " {%s}\n" 
  34.193 -                                    (Util.get_connection_info x)) in_list;   
  34.194 -     Printf.printf "\n";
  34.195 -    *)
  34.196 -
  34.197 -    let (rd_list, _, _) = select in_list [] [] (-1.0) in 
  34.198 -    let (new_list, closed_list) = List.fold_left (process_socket server_sock)
  34.199 -	                                         ([],[]) rd_list  in
  34.200 -    let merge_list = Util.list_remove (new_list @ in_list) closed_list  in
  34.201 -    helper merge_list server_sock
  34.202 -  in
  34.203 -
  34.204 -  try
  34.205 -    let server_sock = socket (domain_of_sockaddr sockaddr) SOCK_STREAM 0 in
  34.206 -    setsockopt server_sock SO_REUSEADDR true;
  34.207 -    bind server_sock sockaddr;
  34.208 -    listen server_sock 2;
  34.209 -
  34.210 -    PDB.open_debugger ();
  34.211 -    let xen_virq_sock = Evtchn.setup () in
  34.212 -    PDB.add_context xen_virq_sock "xen virq" [];
  34.213 -
  34.214 -    let xcs_sock = Xcs.setup () in
  34.215 -    PDB.add_context xcs_sock "xen xcs" [];
  34.216 -    helper [server_sock; xen_virq_sock; xcs_sock] server_sock
  34.217 -  with
  34.218 -  | Sys.Break ->
  34.219 -      print_endline "break: cleaning up";
  34.220 -      PDB.close_debugger ();
  34.221 -      Hashtbl.iter (fun sock conn -> close sock) connection_hash
  34.222 -(*  | Unix_error(e,err,param) -> 
  34.223 -      Printf.printf "unix error: [%s][%s][%s]\n" (error_message e) err param*)
  34.224 -  | Sys_error s -> Printf.printf "sys error: [%s]\n" s
  34.225 -  | Failure s -> Printf.printf "failure: [%s]\n" s
  34.226 -  | End_of_file -> Printf.printf "end of file\n"
  34.227 -
  34.228 -
  34.229 -let get_port () =
  34.230 -  if (Array.length Sys.argv) = 2 
  34.231 -  then
  34.232 -    int_of_string Sys.argv.(1)
  34.233 -  else
  34.234 -    begin
  34.235 -      print_endline (Printf.sprintf "error: %s <port>" Sys.argv.(0));
  34.236 -      exit 1
  34.237 -    end
  34.238 -
  34.239 -
  34.240 -let main =
  34.241 -  let address = inet_addr_any in
  34.242 -  let port = get_port () in
  34.243 -  main_server_loop (ADDR_INET(address, port))
  34.244 -
    35.1 --- a/tools/debugger/pdb/xcs.ml	Fri Sep 29 11:11:49 2006 +0100
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,85 +0,0 @@
    35.4 -(** xcs.ml
    35.5 - *
    35.6 - *  xen control switch interface
    35.7 - *
    35.8 - *  @author copyright (c) 2005 alex ho
    35.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   35.10 - *  @version 1
   35.11 - *)
   35.12 -
   35.13 -open Int32
   35.14 -
   35.15 -let xcs_path = "/var/lib/xen/xcs_socket"                    (* XCS_SUN_PATH *)
   35.16 -let xcs_type = 11                                             (* CMSG_DEBUG *)
   35.17 -
   35.18 -
   35.19 -type xcs_message =
   35.20 -    {
   35.21 -              domain  : int;
   35.22 -              status  : int;
   35.23 -              ring    : int32;
   35.24 -      mutable evtchn  : int;
   35.25 -    }
   35.26 -
   35.27 -external connect : string -> int -> Unix.file_descr = "xcs_connect"
   35.28 -external disconnect : Unix.file_descr -> unit = "xcs_disconnect"
   35.29 -external read_message : Unix.file_descr -> xcs_message = "xcs_read_message"
   35.30 -external write_message : Unix.file_descr -> xcs_message -> unit = 
   35.31 -                                                            "xcs_write_message"
   35.32 -external initialize_ring : int -> int32 -> int32 = "xcs_initialize_ring"
   35.33 -
   35.34 -(*
   35.35 - * initialize xcs stuff
   35.36 - *)
   35.37 -let setup () =
   35.38 -  connect xcs_path xcs_type
   35.39 -
   35.40 -
   35.41 -(*
   35.42 - * adios
   35.43 - *)
   35.44 -let teardown fd =
   35.45 -  disconnect fd
   35.46 -
   35.47 -
   35.48 -(*
   35.49 - * message from a domain backend
   35.50 - *)
   35.51 -let read socket =
   35.52 -  let xcs = read_message socket in
   35.53 -  begin
   35.54 -    match xcs.status with
   35.55 -      | 1 ->                                    (* PDB_CONNECTION_STATUS_UP *)
   35.56 -	  begin
   35.57 -	    print_endline (Printf.sprintf "  new backend domain available (%d)"
   35.58 -	                   xcs.domain);
   35.59 -	    let ring = initialize_ring xcs.domain xcs.ring in
   35.60 -
   35.61 -	    let (local_evtchn, remote_evtchn) = 
   35.62 -	      Evtchn.bind_interdomain xcs.domain in
   35.63 -
   35.64 -	    xcs.evtchn <- remote_evtchn;
   35.65 -	    write_message socket xcs;
   35.66 -
   35.67 -	    let evtchn_fd = Evtchn._setup () in
   35.68 -	    Evtchn._bind evtchn_fd local_evtchn;
   35.69 -
   35.70 -	    (evtchn_fd, local_evtchn, xcs.domain, ring)
   35.71 -	  end
   35.72 -      | 2 ->                                  (* PDB_CONNECTION_STATUS_DOWN *)
   35.73 -	  begin
   35.74 -	    (* TODO:
   35.75 -	       unmap the ring
   35.76 -	       unbind event channel  xen_evtchn_unbind
   35.77 -	       find the evtchn_fd for this domain and close it
   35.78 -	       finally, need to failwith something
   35.79 -	    *)
   35.80 -	    print_endline (Printf.sprintf "  close connection from domain %d"
   35.81 -	                   xcs.domain);
   35.82 -	    (socket, 0, 0, 0l)
   35.83 -	  end
   35.84 -      | _ ->
   35.85 -	  failwith "xcs read: unknown xcs status"
   35.86 -  end
   35.87 -    
   35.88 -
    36.1 --- a/tools/debugger/pdb/xcs.mli	Fri Sep 29 11:11:49 2006 +0100
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,13 +0,0 @@
    36.4 -(** xcs.mli
    36.5 - *
    36.6 - *  xen control switch interface
    36.7 - *
    36.8 - *  @author copyright (c) 2005 alex ho
    36.9 - *  @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
   36.10 - *  @version 1
   36.11 - *)
   36.12 -
   36.13 -
   36.14 -val setup : unit -> Unix.file_descr
   36.15 -val read : Unix.file_descr -> Unix.file_descr * int * int * int32
   36.16 -val teardown : Unix.file_descr -> unit