Trepanning news: command completion and expression parsing

4 views
Skip to first unread message

Rocky Bernstein

unread,
Feb 5, 2011, 5:42:00 PM2/5/11
to Ruby Debugger
This is just to keep folks posted on what's gone on in the trepanning debuggers.

Syntax highlighting of Ruby source and disassembly has largely settled down. I've put up screen shots of the listings at the end of  https://github.com/rocky/rb-trepanning/wiki/Terminal-Colors and  https://github.com/rocky/rbx-trepanning/wiki/Terminal-Colors

I'm in the middle of adding command-completion for debugger commands when Readline is used. Although there are still a number little details to work out, I'm pleased with what's there now. 

These debuggers are first ones that I've worked on where the completion mechanism is fairly clean.  Since each command is an object,  each command has a completion routine and can  customize that (over the subclass defaults) when needed.

Finally, I've decided to address head on something that has been a long-standing nagging problem: parsing location expressions. To describe how to list source code or understand where to set a breakpoint, it is desirable in debuggers to be able to parse a broad set of locations which include method locations. Here are some potential ways one might specify a method name:

dup   # just the method name inside a Module
Kernel.dup  # Module and class
Kernel::dup  # Same as above
x.dup    # instance method of a particular object
'5'.dup  # instance method of another particular object
clone # just a method name inside a class
Object.dup  # class method with class name
Object.dup()  # with parenthesis 
A::B::.c.d  # Multi-level resolution

In order to find such a method, a debugger may need to track down classes and modules and objects. Right now I've been using regular expressions and eval() to try to wrap
whatever is needed to turn the string into a method. All of this is kludgy an error prone. So what I'll be working on soon is adding a PEG parser probably using Treetop to 
parse such kinds of location expressions. The PEG parser will have semantic actions to give me the result value I need. 

Reply all
Reply to author
Forward
0 new messages