[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to debug IDL with call_external?




Nando <f.iavarone@acsys.it> writes:
> pei zeng wrote:
> 
> > I have an IDL application which calls a FORTRAN code(quite large). When I
> > run it, it crashed the application and would not allow me to debug the
> > fortran code.
> 
> Have you tried to use a debugger?
> I work with call_external of C code and I use dbx for debugging.
> I run the dbx after IDL launching (on the process id of IDL).
> After your code has linked the shared object, set a break point on your
> external code and
> it is possible to trace the execution.

In developing XFILTER, a devious add-on to IDL, I did a lot of
debugging.  I found that using the debugger worked fine and I could
set breakpoints within my own code.  In my case I used GDB on C code
but any debugger that normally works should be okay for you.  However,
there are a few gotchas:

 * of course, you need to compile with debugging support.

 * you should be careful to debug the binary executable and not the
   script which is normally run.  Usually this means that you have to
   set a few environment variables that the script would normally set,
   and then run the debugger on $IDL_DIR/bin/bin.arch/idl where arch
   is your architecture.

 * there is a chicken/egg problem regarding loaded programs.  The
   debugger won't know about your program until the object file is
   loaded; BUT you can't load your program without first running IDL.
   Therefore you can't immediately set a breakpoint on your first run.

   Usually I get around this by having a "dummy" function which does
   nothing.  By CALL_EXTERNALing this dummy function, the object file
   is forced to be loaded.  After that you can pop back to the
   debugger and set breakpoints within your code.

Good luck,

Craig

P.S.  XFILTER is a graphics driver for Unix versions of IDL which
saves entire graphics streams for subsequent playback.  Equivalent to
David's XWINDOW but much more straightforward.  Find it here:

http://cow.physics.wisc.edu/~craigm/idl/idl.html  (look for XFWINDOW)

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------