As noted I've found that most folks debug the same way, at least by observing coders at my primary client's office. What's interesting is that as often as this exercise is performed many folks don't have dedicated functions for this important task, as few as they need to be.
So yes -- I too put in dumps and breakpoints.
In it's distilled form I have two simple functions, one called (Dump x) and the other called (Wait). Ok, there's a third called (DumpAndWait x) which is self explainatory and a convenience function 'cause I be lazy.
(Dump x) takes a sole parameter and spews formatted information about the argument -- and here's an important trait -- it then returns the argument as received, in other words it does a pass thru. If the argument passed is a quoted symbol it prints the name and then the data it hosts, otherwise just the data. Example (Dump 'x) versus (Dump x). This will allow me to do things like (setq myPi (Dump pi)), spewing info about the symbol pi, but returning it so it assigned via the setq statement to variable myPi.
(Wait) does nothing but halt program execution until the user presses [Enter].
So ... let's say I define (Dump x), (Wait) and (DumpAndWait x) in a library called debug.lsp.
A contrived little proggy:
(defun c:TEST ( / a b c d e )
(princ "Begin TEST ...\n\n")
(setq
a 1
b "2"
c ((lambda (x) (repeat 8 (setq x (append x x)))) '(1 2 3))
d (ssget "x")
)
(dump 'a)
(dump 'b)
(dump 'c)
(dump 'd)
(cond
( (eq 'pickset (type d))
(dump (setq e (ssname d 0)))
(dump (vlax-ename->vla-object e))
)
)
(princ "End TEST ...\n\n")
(princ)
)
Might spew ...
Begin TEST ...
;================================ Dump 1.0 =================================
;
; Atom Name: A
; Atom Type: INT
;
;===========================================================================
;
; 1
;
;===========================================================================
;================================ Dump 1.0 =================================
;
; Atom Name: B
; Atom Type: STR
;
;===========================================================================
;
; StrLen = 1
;
; "2"
;
;===========================================================================
;================================ Dump 1.0 =================================
;
; Atom Name: C
; Atom Type: LIST
;
;===========================================================================
;
; Length = 768
;
; (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
; 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1
; 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1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 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2
; 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
; 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
; 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1
; 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1
; 2 3)
;
;===========================================================================
;================================ Dump 1.0 =================================
;
; Atom Name: D
; Atom Type: PICKSET
;
;===========================================================================
;
; SSLength = 1
;
; <Selection set: 21>
;
;===========================================================================
;================================ Dump 1.0 =================================
;
; Atom Type: ENAME
;
;===========================================================================
;
; (
; (-1 . <Entity name: 7ef70f68>)
; (0 . "CIRCLE")
; (330 . <Entity name: 7ef70cf8>)
; (5 . "A5")
; (100 . "AcDbEntity")
; (67 . 0)
; (410 . "Model")
; (8 . "0")
; (100 . "AcDbCircle")
; (10 33.5609 4.2347 0.0)
; (40 . 1.30078)
; (210 0.0 0.0 1.0)
; )
;
;===========================================================================
;================================ Dump 1.0 =================================
;
; Atom Type: VLA-OBJECT
;
;===========================================================================
;
; IAcadCircle: AutoCAD Circle Interface
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
; Area = 5.31566
; Center = (33.5609 4.2347 0.0)
; Circumference = 8.17304
; Diameter = 2.60156
; Document (RO) = #<VLA-OBJECT IAcadDocument 0cf37924>
; Handle (RO) = "A5"
; HasExtensionDictionary (RO) = 0
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0e4c0574>
; Layer = "0"
; Linetype = "ByLayer"
; LinetypeScale = 1.0
; Lineweight = -1
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 2130120552
; ObjectName (RO) = "AcDbCircle"
; OwnerID (RO) = 2130119928
; PlotStyleName = "ByLayer"
; Radius = 1.30078
; Thickness = 0.0
; TrueColor = #<VLA-OBJECT IAcadAcCmColor 0e4c0cc0>
; Visible = -1
; Methods supported:
; ArrayPolar (3)
; ArrayRectangular (6)
; Copy ()
; Delete ()
; GetBoundingBox (2)
; GetExtensionDictionary ()
; GetXData (3)
; Highlight (1)
; IntersectWith (2)
; Mirror (2)
; Mirror3D (3)
; Move (2)
; Offset (1)
; Rotate (2)
; Rotate3D (3)
; ScaleEntity (2)
; SetXData (2)
; TransformBy (1)
; Update ()
;
;===========================================================================
End TEST ...
When I'm done debuggging the application I may decide to keep the debugging tools in place, but define (Dump x), (Wait) and (DumpAndWait x) locally so they have the same signature but do nothing --
(defun c:TEST ( / Dump Wait DumpAndWait a b c d e )
(defun Dump (x) x)
(defun Wait ( ) (princ))
(defun DumpAndWait (x) x)
(princ "Begin TEST ...\n\n")
(setq
a 1
b "2"
c ((lambda (x) (repeat 8 (setq x (append x x)))) '(1 2 3))
d (ssget "x")
)
(dump 'a)
(dump 'b)
(dump 'c)
(dump 'd)
(cond
( (eq 'pickset (type d))
(dump (setq e (ssname d 0)))
(dump (vlax-ename->vla-object e))
)
)
(princ "End TEST ...\n\n")
(princ)
)
A run will now output this --
Begin TEST ...
End TEST ...
So friends ... how might I improve upon this debuggin technique?