Author Topic: "continuous TRACE" ? is it possible ?  (Read 3313 times)

0 Members and 1 Guest are viewing this topic.

SOFITO_SOFT

  • Guest
"continuous TRACE" ? is it possible ?
« on: December 31, 2010, 08:19:32 AM »
Hello everybody :
Can we know which functions are executed during the execution of a Alisp  or  VLISP program  ?. I think something like a "continuous TRACE"  :-o. It really is easier because I just need to know the name of the defuns, not their parameters or returns. Is to know which parts of a very big library of functions should I include in a partial application. I have tried to do it manually, but it is very long and tedious. I estimate that there may be about 25 or 30 calls from a defuns to other defuns. Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: "continuous TRACE" ? is it possible ?
« Reply #1 on: December 31, 2010, 11:06:05 AM »
You could use code to read the LISP file and report the user defined subfunctions found - similar to how code formatting programs work.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: "continuous TRACE" ? is it possible ?
« Reply #2 on: December 31, 2010, 11:24:16 AM »
A bit of overkill but:

Code: [Select]
 

(foreach x (atoms-family 0)
           (eval (list 'trace x)))



-David
R12 Dos - A2K

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: "continuous TRACE" ? is it possible ?
« Reply #3 on: December 31, 2010, 11:50:44 AM »
Be careful what you wish for:

Code: [Select]
(defun c:GlobalTraceOn ( )
    
    (setq *subrs*
        (vl-remove-if-not
            (function (lambda (symbol) (eq 'subr (type (eval symbol)))))
            (atoms-family 0)
        )
    )
    
    (eval (cons 'trace *subrs*))
    
    (princ)    

)

(defun c:GlobalTraceOff ( )

    (if *subrs* (eval (cons 'untrace *subrs*)))
    
    ;;  sorry for the verbose output. Nomutt and qaflags have no effect        
    
    (princ)    
    
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: "continuous TRACE" ? is it possible ?
« Reply #4 on: December 31, 2010, 12:15:31 PM »
If you're consistent with your function naming you can be more discriminating:

Code: [Select]
(defun c:TraceMe ( )

    (setq *mysubrs*
        (vl-remove-if-not
            (function
                (lambda (symbol)
                    (and
                        (eq 'subr (type (eval symbol)))
                        [color=green];; I prefix my functions with an underscore[/color]
                        [color=red](wcmatch (vl-symbol-name symbol) "_*")[/color]
                    )
                )
            )
            (atoms-family 0)
        )
    )

    (if *mysubrs* (eval (cons 'trace *mysubrs*)))

    (princ)

)

(defun c:UnTraceMe ( )

    (if *mysubrs* (eval (cons 'untrace *mysubrs*)))

    ;;  sorry for the verbose output. Nomutt and qaflags has no effect

    (princ)

)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

David Bethel

  • Swamp Rat
  • Posts: 656
Re: "continuous TRACE" ? is it possible ?
« Reply #5 on: December 31, 2010, 12:50:30 PM »
I do something similar, using unique prefixes for each program:

Code: [Select]

(setq f "nw_")
      (foreach x (atoms-family 1)             
              (if (= (substr x 1 (strlen f)) (strcase f))
                  (eval (list 'trace (read x)))
                  (eval (list 'untrace (read x)))))

R12 Dos - A2K

SOFITO_SOFT

  • Guest
Re: "continuous TRACE" ? is it possible ?
« Reply #6 on: January 01, 2011, 04:07:38 AM »
You could use code to read the LISP file and report the user defined subfunctions found - similar to how code formatting programs work.
I think this is the safest option, because running the program would have to be sure that all sub-functions are called. I'm thinking I'd have to run each option with several very different examples and yet would never be sure that all subfunctions have been called. The problem is to make a syntax for analyzer to open each LSP file, read each line, parse the word that comes after each parenthesis, see if it is a vocabulary ALISP / VLISP word .... It would also have to skip the lines of comments, literal strings, etc, etc, etc, ufffff .... It's a good idea, but I see it difficult to put into practice.

I do something similar, using unique prefixes for each program:

Code: [Select]

(setq f "nw_")
      (foreach x (atoms-family 1)             
              (if (= (substr x 1 (strlen f)) (strcase f))
                  (eval (list 'trace (read x)))
                  (eval (list 'untrace (read x)))))

Using "f" like a list of prefixes and / or suffixes names of mys defuns ... and instead (substr x 1 (strlen f)) (strcase f)) for a search & comparation string function, type (wcmatch string pattern) is probably the most practical method ...Almost all of my functions are in the name one o two groups of 5 letters characteristic. I can have a little luck. :lol:
Thank you all for so many good ideas. Happy New Year to all from Madrid. :-)

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: "continuous TRACE" ? is it possible ?
« Reply #7 on: January 01, 2011, 06:08:40 AM »
pretty easy task to accomplish, mine is 135 lines of code.
ps names of all my functions start with "vk_", it helps a lot

SOFITO_SOFT

  • Guest
Re: "continuous TRACE" ? is it possible ?
« Reply #8 on: January 01, 2011, 01:51:47 PM »
Hi all:
I have approximately 14000 :kewl: lines of code  (with coments) and about 70 very deeply nested functions.
A good neat trick to establish the prefixes of the names before starting a new project.. I will consider it for the future. Thanks. ;-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: "continuous TRACE" ? is it possible ?
« Reply #9 on: January 01, 2011, 11:16:14 PM »
A good neat trick to establish the prefixes of the names before starting a new project.. < .. >

Yes, and good housekeeping for debugging.


< ... > I will consider it for the future. Thanks. ;-)

You could do it now if you have confidence in your search and replace software :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.