Jump to content

debugging problem


Recommended Posts

Posted

I have two autolisp programs as follows:

 

(defun c:test1()

(setq x 0)

(setq y 0)

(alert "test1")

(load "C:\\Documents and Settings\\Administrator\\Desktop\\test2.lsp")

)

 

 

(defun fnTest2()

(setq x2 0)

(sewtq y2 0)

(alert "test2")

)

(test2)

 

Note that program test1 loads the program test2 and then test2 automatically executes the function fnTest2. This is an existing program and I can't make any changes to it.

 

I open file test1.lsp in vlide and then lad it using Tools > Load text in editor.

 

I then enable Debug > Stop once & Debug > break on error.

 

Then I type test1 at the command prompt and then I am able to debug both the program step-by-step using F8 key. The program also highlights the line containing error in program test2.

 

When I 'Rest to top level' and type test1 again at the command prompt, I am able to debug the test1 code but cursor does not stop in program Test2 and does not highlight any statement.

 

What am I doing wrong?

 

Also is there any statement equivalent to the 'stop' statement in VB, so that I cam hardcode a breakpoint in the code.

Posted

Why not like this below makes more sense you can have all sorts of problems loading a lisp from a lisp as a chain of events if you must, either load all defuns in one go via script or menu or autoload if use all the time.

 

(defun c:test1()
 (setq x 0)
 (setq y 0)
 (alert "test1")
 )


(defun fnTest2()
 (setq x2 0)
 (sewtq y2 0)
 (alert "test2")
 )

fntest1
(fntest2)

Re stop (exit)

Posted

As I already mentioned, I can't make any modification to the code. I can only debug it.

 

So the problem is how to debug the entire code.

 

Also exit exits out of function and we can't resume execution from the next statement which is what 'Stop' does.

Posted

The function test2 is not defined in this code, so trying to evaluate test2 will give an error:

_$ (test2)

; error: no function definition: TEST2

_$

Not much debugging is necessary, it seems.

If debugging something more serious you may use the "Toggle breakpoint" button in the Debug toolbar to set a breakpoint and the "Step Into" "Step Over" and "Step Out" buttons in the same toolbar to evaluate each expression after the breakpoint.

Posted

OK. It was typo and the code should read as follows:

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Test1.lsp

 

(defun c:test1()

(setq x 0)

(setq y 0)

(alert "test1")

(load "C:\\Documents and Settings\\Administrator\\Desktop\\test2.lsp")

)

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Test2.lsp

(defun fnTest2()

(setq x2 0)

(setq y2 0)

(alert "test2")

)

(fnTest2)

 

The question here is not if test2 requires debugging. The problem is you can't debug it even if you want to. Even when you set break-points, the code in Test2 executes without breaking at any of the breakpoint.

 

I need why this happens and how to overcome this.

Posted

NirantarVidyarthee,

try, debug==>Animate

the second file will be load and you will see it running

 

Henrique

Posted

Sorry, with Debug > Animate, user has no control. It does not respect any breakpoints.

Posted

For debugging, I use Animate and Break On Error

and it stops when there is error, and you can see the error...

Posted

hmsilva, thanks! It works on the sample code. Now I hope that it works on the working code which is much larger and far more complex.

 

Thanks again.

 

By the way, has anybody used View > Symbol Service ...? How's it different from using Animate and stop on error method?

Posted

You're welcome and good luck, NirantarVidyarthee

you have to have patience, while the code "more complex" is being animated

sometimes we despaired while we wait ...

 

Henrique

Posted

I found that the window containing Test2 needs to be closed otherwise statements in Test 2 are not highlighted. This seems to be the problem in many case.

Posted
The problem is you can't debug it even if you want to. Even when you set break-points, the code in Test2 executes without breaking at any of the breakpoint.

 

I need why this happens and how to overcome this.

If you open the test2.lsp in the IDE, set the breakpoint wherever you please and the evaluate (fnTest2) you can step through all the expressions.

I don't understand what else do you want.

Posted

I would also suggest using the View>Error Trace window (CTRL+SHIFT+R). It'll show you the error and using the contextual menu can highlight the offending expression in the editor.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...