; --------------------------------------------------------------------------------
; @Title: Script connect to the UndoDB server
; @Description:
;  This script configures the TRACE32 to connect to the undodb server.
; @Author: KJM
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: undodb.cmm 7846 2014-11-04 12:47:54Z kjmal $

  LOCAL &spaceid

; start the undodb-server with: undodb-server --connect-port 30000

  RESet  ; Reset the debugger environment
  sYmbol.RESet ; delete any previously loaded symbols

  SYStem.CPU *
  
  ; setup the target ip address and used port number
  SYStem.PORT 192.168.188.26:30000

  
  SYStem.Option gdbEXTENDED ON   ; enable GDB extended mode
  SYStem.Option MMUSPACES ON     ; enable address extension

  SYStem.Mode Attach             ; attach to the undodb-server
  
  WinCLEAR

  
  ; Start a first process for debugging
  PRINT "Starting process hello"
  TASK.RUN /home/user/hello
  WAIT 1.s
  &spaceid=TASK.SPACEID("hello")
 
  IF &spaceid==-1
  (
      PRINT %ERROR "Process hello not started"
      ENDDO
  )


  Data.LOAD.Elf hello &spaceid:0 /NoCODE /NoClear

  ; Go to the main function of process hello
  Go main

  ; Open a List window
  WinPOS 0% 0% 49% 48%
  List.auto

  PRINT ""
  ENDDO