debuging tools?

Discussion in 'AutoCAD' started by BOBQ, Oct 31, 2004.

  1. BOBQ

    BOBQ Guest

    Does anyone know of any debuging tools available for autolisp?
    I spend a lot of time tracking down the sources of errors.
    I know back when doing other programing (basic) there were things such as
    line number reporting of
    where an error occured, and the break function which would pause a command
    and allow you to
    view the state of certain variables.

    Or is this what Visual basic is all about?
    Thanks, Bob.
     
    BOBQ, Oct 31, 2004
    #1
  2. BOBQ

    CAB2k Guest

    Bob are you using VLIDE to edit your lisp? I suspect not.
    Enter VLIDE at the command prompt. All the debugging tools are there.
    Ugh, what version of acad are you using?
     
    CAB2k, Oct 31, 2004
    #2
  3. BOBQ

    BOBQ Guest

    I am useing 2004, why? what am I missing?
    and thanks for the tip...:)
     
    BOBQ, Oct 31, 2004
    #3
  4. BOBQ

    CAB2k Guest

    I know people still using ACAD11 & wasn't sure when VLIDE came
    into being, 14 or 2000 I think. But VLIDE is what you are looking for.
     
    CAB2k, Oct 31, 2004
    #4
  5. BOBQ

    David Bethel Guest

    I've used this for a while, Little bits from different folks, modified
    to my liking. -David

    (princ "\nLoading Debug....")
    (setvar "ERRNO" 0)
    ;;; Debug Bit Flag Values
    ;;; 0 = No Tracing & Debug Error
    ;;; 1 = nil *error* UNDO OFF
    ;;; 2 = CMDECHO On
    ;;; 4 = MACROTRACE On
    ;;; 8 = Trace Selected Functions Only
    ;;;16 = Trace All Functions
    ;;;32 = Debug Error
    ;;;64 = Show Command Names In ModeMacro & Trace Macros
    ;;;128 = MENUECHO On
    ;|(debug "nw_" 11) = *error* nil,trace all "nw_" calls, cmdecho ON|;

    (defun debug_ (l f / bugerr) ;Supply Debug Level
    (setvar "MACROTRACE" 0) ;Turn MACROTRACE Off
    (setvar "MENUECHO" 0) ;Turn MENUECHO Off
    (setvar "CMDECHO" 0) ;Turn CMDECHO Off
    (setvar "MODEMACRO" ".") ;Clear MODEMACRO
    (if (= (type vl-bt) 'SUBR)
    (eval vl-bt))
    (if (not *error*) ;Set
    (setq *error* ;Error Or
    (if olderr olderr ;Replace
    (lambda (s) ;With Old
    (and (not (zerop (getvar "ERRNO")))
    (princ (strcat "\nERRNO: " (itoa (getvar "ERRNO"))
    " - " (cdr (assoc (getvar "ERRNO") err_list)))))
    (princ (strcat "\nDebug: *** " s " *** "))
    (and (> (getvar "UNDOCTL") 7) ;End Undo
    (command "_.UNDO" "_END")) ;Group
    (prin1))))) ;Exit Clean
    (and (> l 0) (princ "\nDebug Active ")) ;Display Status
    (and (= (logand l 1) 1) ;1st Byte = nil *error*
    (setq olderr (if olderr olderr *error*) *error* nil T T)
    (command "_.UNDO" "_END"
    "_.UNDO" "_AUTO" "_OFF"))
    (and (= (logand l 2) 2) ;2nd Byte =
    (setvar "CMDECHO" 1)) ;CMDECHO On
    (and (= (logand l 4) 4) ;3rd Byte =
    (setvar "MACROTRACE" 1)) ;Trace All Diesel
    (cond ;Trace Condition
    ((= (logand l 16) 16) ;5th Byte =
    (trace @setq)
    (trace |fun)
    (foreach x (atoms-family 0) ;Trace On
    (eval (list 'trace x)))) ;All Functions

    ((= (logand l 8) 8) ;4th Byte =
    (foreach x (atoms-family 1) ;Trace On Selected
    (if (= (substr x 1 (strlen f)) (strcase f))
    (eval (list 'trace (read x)));Functions Only
    (eval (list 'untrace (read x)))))
    (trace @setq)
    (trace |fun))
    ((foreach x (atoms-family 0) ;Else Clear All
    (eval (list 'untrace x))))) ;Tracing

    (and (= (logand l 32) 32) ;6th Byte
    (setq bugerr *error*
    *error* (lambda (s) ;Errno Return
    (and (not (zerop (getvar "ERRNO")))
    (princ (strcat "\nERRNO: " (itoa (getvar "ERRNO"))
    " - " (cdr (assoc (getvar "ERRNO") err_list " ")))))
    (princ (strcat "\n*** " S " *** "))
    (setq *error* bugerr)
    (and (> (getvar "UNDOCTL") 7) ;End Undo
    (command "_.UNDO" "_END"))
    (prin1))))
    (and (= (logand l 64) 64) ;7th Byte
    (setvar "modemacro" ;Show Command Name
    (strcat "Command -> " "$(getvar,cmdnames)" " ")))
    (and (= (logand 1 128) 128) ;8th Byte
    (setvar "MENUECHO" 8)) ;Trace Menu Diesels
    (terpri) ;Force A New Line
    (setq db_stat l) ;Save Status
    (setvar "ERRNO" 0) ;Reset ERRNO
    (eval l)) ;Return Debug Level

    (defun c:debg (/ df dl dfn) ;Debug
    (and (setq df 0) ;Start At Zero
    db_stat ;Setup
    (zerop db_stat) ;Default
    (setq df 9)) ;Level
    (initget 4) ;Positive Only
    (textscr)
    (princ (strcat
    "\n Debug Bit Flag Values"
    "\n 0 = No Tracing & A Clean Error"
    "\n 1 = *error* nil"
    "\n 2 = CMDECHO On"
    "\n 4 = MACROTRACE On - MENUECHO 8 - MODEMACRO \".\""
    "\n 8 = Trace Selected Functions Only"
    "\n16 = Trace All Functions"
    "\n32 = Debug Error Replacement"
    "\n64 = Command Name In Modemacro"
    "\n128 = MENUECHO On"
    "\nCurrent Status: "
    (if db_stat (itoa db_stat) "Unknown")
    "\n"))
    (setq dl (getint (strcat "\nDebugging Level <" (itoa df)">: ")))
    (if (not dl) (setq dl df)) ;Default to df
    (if (= (logand dl 8) 8) ;4th Byte
    (progn ;For Selective
    (setq dfn (getstring "\nFunction Prefix To Trace <\"nw_\">: "))
    (if (= dfn "") (setq dfn "nw_")))) ;Tracing
    (if (zerop dl) ;For
    (progn ;Deactivating
    (debug_ 0 "") ;All
    (princ "\nDeactivating Debug...")) ;Debug
    (progn ;To Activate
    (debug_ dl dfn) ;Selected Level
    (princ (strcat "\nActivating Debug " (itoa dl) " ..."))))
    (prin1))

    ;;;+++++++++++ Break Modified From David Greay +++++++++++++++++++++++++
    (defun break (/ lisp_cmd)
    (and (not (zerop (getvar "ERRNO")))
    (princ (strcat "\nERRNO: " (itoa (getvar "ERRNO"))
    " - " (cdr (assoc (getvar "ERRNO") err_list))))
    (prin1))
    (while (not (eq (setq lisp_cmd (getstring T "\nBreak >> ")) ""))
    (cond ((getvar lisp_cmd)
    (prin1 (getvar lisp_cmd)))
    ((eq (substr lisp_cmd 1 1) "!")
    (setq lisp_cmd (substr lisp_cmd 2))
    (prin1 (eval (read lisp_cmd))))
    (t (prin1 (eval (read lisp_cmd))))))
    (setvar "ERRNO" 0)
    (princ))

    ;;;+++++++++++ Break With Message Modified From David Greay ++++++++++++
    (defun breakm (m / lisp_cmd)
    (and (not (zerop (getvar "ERRNO")))
    (princ (strcat "\nERRNO: " (itoa (getvar "ERRNO"))
    " - " (cdr (assoc (getvar "ERRNO") err_list))))
    (prin1))
    (princ "\nMessage: ")
    (cond ((= (type m) 'LIST) (prin1 m))
    (m (prin1 (eval m)))
    (T (princ "nil")))
    (while (not (eq (setq lisp_cmd (getstring T "\nBreak >> ")) ""))
    (cond ((getvar lisp_cmd)
    (prin1 (getvar lisp_cmd)))
    ((eq (substr lisp_cmd 1 1) "!")
    (setq lisp_cmd (substr lisp_cmd 2))
    (prin1 (eval (read lisp_cmd))))
    (t (prin1 (eval (read lisp_cmd))))))
    (setvar "ERRNO" 0)
    (princ))

    (and (not err_list)
    (setq err_list '(
    ( 1 . "Invalid symbol table name")
    ( 2 . "Invalid entry or selection set name")
    ( 3 . "Exceeded maximum number of selection sets")
    ( 4 . "Invalid selection set")
    ( 5 . "Improper use of of block definition")
    ( 6 . "Improper use of block definition")
    ( 7 . "Object selection: pick failed")
    ( 8 . "End of entity file")
    ( 9 . "End of block definition file")
    (10 . "Failed to find last entity")
    (11 . "Illegal attempt to delete viewport object")
    (12 . "Operation not allowed during PLINE")
    (13 . "Invalid handle")
    (14 . "handles not enabled")
    (15 . "Invalid arguments in coordinate transform request" )
    (16 . "Invalid space in coordinate transform request")
    (17 . "Invalid use of deleted entity")
    (18 . "Invalid table name")
    (19 . "Invalid table function argument")
    (20 . "Attempt to set read-only variable")
    (21 . "Zero value not allowed")
    (22 . "Value out of range")
    (23 . "Complex REGEN in progress")
    (24 . "Attempt to change entity")
    (25 . "Bad layer name")
    (26 . "Bad linetype name")
    (27 . "Bad color name")
    (28 . "Bad text style name")
    (29 . "Bad shape name")
    (30 . "Bad field for entity type")
    (31 . "Attempt to modify deleted entity")
    (32 . "Attempt to modify seqend subentity")
    (33 . "Attempt to change handle")
    (34 . "Attempt to modify viewport visibility")
    (35 . "Entity on locked layer")
    (36 . "Bad entity type")
    (37 . "Bad polyline type")
    (38 . "Incomplete complex entity in block")
    (39 . "Invalid block name field")
    (40 . "Duplicate block flag fields")
    (41 . "Duplicate block name fields")
    (42 . "Bad normal vector")
    (43 . "Missing block name")
    (44 . "Missing block flags")
    (45 . "Invalid anonymous block")
    (46 . "Invalid block definition")
    (47 . "Mandatory field missing")
    (48 . "Unrecognized extended XDATA type")
    (49 . "Improper nesting of list in XDATA")
    (50 . "Improper location of APPID field")
    (51 . "Exceeded maximum XDATA size")
    (52 . "Entity selection: null response")
    (53 . "Duplicate APPID")
    (54 . "Attempt to make or modify viewport entity")
    (55 . "Attempt to make or modify an xref, xdef, or xdep")
    (56 . "ssget filter: unexpected end of list")
    (57 . "ssget filter: missing test operand")
    (58 . "ssget filter: invalid opcode (-4) string")
    (59 . "ssget filter: improper nesting or empty conditional
    clause")
    (60 . "ssget filter: mismatched begin and end of conditional
    clause")
    (61 . "ssget filter: wrong number of arguments in conditional
    clause (for NOT or XOR)")
    (62 . "ssget filter: exceeded maximum nesting limit")
    (63 . "ssget filter: invalid group code")
    (64 . "ssget filter: invalid string test")
    (65 . "ssget filter: invalid vector test")
    (66 . "ssget filter: invalid real test")
    (67 . "ssget filter: invalid integer test")
    (68 . "Digitizer isn't a tablet")
    (69 . "Tablet is not calibrated")
    (70 . "Invalid arguments")
    (71 . "ADS error: Unable to allocate new result buffer")
    (72 . "ADS error: Null pointer detected")
    (73 . "Can't open executable file")
    (74 . "Application is already loaded")
    (75 . "Maximum number of applications already loaded")
    (76 . "Unable to execute application")
    (77 . "Incompatible version number")
    (78 . "Unable to unload nested application")
    (79 . "Application refused to unload")
    (80 . "Application is not currently loaded")
    (81 . "Not enough memory to load application")
    (82 . "ADS error: Invalid transformation matrix")
    (83 . "ADS error: Invalid symbol name")
    (84 . "ADS error: Invalid symbol value")
    (85 . "AutoLISP/ADS operation prohibited while a dialog box
    was displayed"))))

    (prin1)

    ;Tested With R12_c3 DOS, R13_c4a DOS & Windows 95
    ;"AS IS" Public Domain Software Donated By
    ;
    ;
    ; Fabricated Designs, Inc.
    ; 32 Maury Avenue
    ; Newport News, Virginia 23601-2132
    ; Ph: (757) 595-5949
    ; FAX: (757) 595-5787
    ; CIS: 73544,2655
    ; Internet: http://ourworld.compuserve.com/homepages/DavidBethel/
    ;
     
    David Bethel, Oct 31, 2004
    #5
  6. Hi,

    The VLIDE has debugging tools. They just need you to read the help files to
    find out how to use them.

    Compared with the equivalent tools in the VBAIDE they are quite primitive.

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Oct 31, 2004
    #6
  7. BOBQ

    James Allen Guest

    Hi Laurie, OT: I sure have gotten addicted to scrolling by just flicking my
    finger on this mouse wheel, and in turn get a little frustrated every time I
    get into vbaide and it won't scroll. Oh well. At least I don't get the
    same frustration in vlide. ;)
     
    James Allen, Nov 1, 2004
    #7
  8. BOBQ

    diemaker Guest

    If you have 2004, you should have Visual Lisp. Tools/Autolisp/Visual Lisp. It pays to read the help on debugging programs because VL makes debugging so easy. 1st , use the VL “consoleâ€. Run the program from there. You can access variables and type in functions to see the results Even highlight individual lines from the .lsp file and paste into the console to test just a portion. 2nd, open the watch window to display variables while the program runs. 3rd, use breakpoints to stop a program where you think there is a problem and step though it one () at a time.

    And to answer your original question… When a program crashes, when run from the console, go to pulldown View / Error Trace. Up pops a trace window. Pick #2, which is the line that crashed. RMB and pick “call point sourceâ€. Takes you to the bad line.
     
    diemaker, Nov 1, 2004
    #8
  9. Hi James,

    I've forgotten how I did it, but several years ago I set my mouse up to use
    the scroll wheel in the VBAIDE via advice I received from these NGs.

    That said, I agree that it is a pest in the normal course of events.

    I don't retract from my original statement in terms of overall useability.

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Nov 1, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.