jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

SLang debugger


Hi,
 
This is a tecnology preview version of SLang Debugger for Jed!
 
With this you can:
 
- Set (and remove) breakpoints.
- Temporary (one time, or N times) breakpoints.
- Next (run to next instruction, skipping function calls)
- Step (run to next instruction, following function calls).
- Finish (run until current function exits).
- "Run to cursor"
- Show slang stack.
- Show function call trace, with local variables.
 
Ok, while all the above is true, this is an experimental mode using features
of a development version of SLang. The 'call trace dump' feature needs also
a patch to SLang (more on this below).
So try this at your own risk!
 
Ok, if i have not scared you enough, this is how to use this:
 
- Get a working installation of Jed B0.99.17-84 (or near) and SLang-pre2-r7.
- Optionally patch slang with the attached patch (this adds more features to
'dump trace', but works also without).
- copy sldebug.sl (attached) to a directory on your jed library path.
- add a 'require("sldebug") to slang_mode_hook().
- Optionally give a value to custom_variables (for key configuration, see
top of sldebug.sl).
- Open the slang source files you want to debug, and be sure those have:
    _debug_info=1;
    _traceback=1;
    _boseos_info=3;
- Go to a source line, and place a breakpoint using 'F9' (with default
bindings). This works if buffer is in slang_mode.
- Do something to trigger running the statement containing the breakpoint.
- A buffer containing the source pops up, with the line to execute marked.
You can move around, see debugger help (F1), return to source view (F2),
show stack and tracback (if slang was patched) (F3), show a list of active
breakpoints (F4). 
- Next (F10), step (F11), Finish (F12), Toggle breakpoint (F9), run to
cursor (F8), Continue (F7).
 
I did this mostly as a "proof of concept", to see if it was possible to use
bos_handler to create a debugger. More interpreter help is needed to build a
real debugger, to be able to change variables in other scopes, for example
(but I don't want to allow every script to do this, only the debugger, so is
a complex thing to think about).

A lot of refinement are needed for this: custom modes for every buffer (for
example, in 'show breakpoints' buffer we need to be able to delete/disable
breakpoint, or simply go to source).

Also while stopped at debugger, I try to let user to do almost everything he
can do normally. But two things does not work: menus (for it complex
interation with it's own keymap, handled automatically by jed but not
reproducible from slang), and minibuffer requests (e.g. "Buffer tempbuf not
saved. Save it? (y/n)").

Right now Slang keeps the call stack in C local variables inside
execute_slang_fun(), this is an easy and efficient way to do things, but
sadly the only way to (portably) do a slang traceback is to exit all the
recursive execute_slang_fun() dumping the functions meanwhile. This is what
traceback happenings at error() time does. For a debugger this is
unfeasible, and futhermore SLang already has a static data containing the
call stack: Num_Args_Stack. So the idea is to move the call stack to an
external structure, so it can be walked anytime without changing execution
point.
 
My patch takes a more conservative approach: it creates a static array of
pointers to _pSLang_Function_Type, updated entering and exiting
execute_slang_fun(), but everything else remains as before. The array can be
a lot smaller than the maximum stack, and is circular, to keep always the
most recent functions instead of older (this feature should be removed if
this stack is unified with Num_Args_Stack).
This also changes do_function_traceback() to take an offset to local frame
stack (we can call it for a function that is not the current one), and a
pointer to function to use for dump.
I have also aligned the prototypes for _pSLerr_dump_msg (using during the
new traceback) and _pSLerr_traceback_msg() (used for error() traceback).
Oh, it also exports the "dump_traceback(n)" function (n is the number of
frames at top to ignore: this is used to avoid dumping status of debugger
functions).

I John likes the idea, this new array, Num_Args_Stack, and maybe
Local_Variable_Frame (index for local variables in Local_Variable_Stack) may
be unified in a structure array...

Comments welcome!

								Dino

Attachment: slang-add-dump_traceback.diff
Description: Binary data

Attachment: sldebug.sl
Description: Binary data


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]