Archive for the ‘Uncategorized’ Category

Spam Blog Comments

October 29, 2007

Since I dont have CAPTCHA set up for leaving comments on my blog I get an enormous amount of spam. I will be setting up CAPTCHA or something similar pretty soon. But I wanted to experiment a little with the gmail spam filter.

Gmail has an awesome spam filter, and since all my blog comments are forwarded to my gmail account I wanted to see if I can train my gamil spam filter to recognize spam from useful comments.

Stay tuned.

C++ Debuging

October 15, 2007

The original pillars of frysk were enabling users to debug of large multi-threaded applications, and providing robust C++ support.

Looking at frysk today I see a beutifully designed and implemented object oriented model of the operating system, its processes and threads. This model enables clients to manipulate and examin individual threads individually, as well as the operating environment they run in. So I think that we have done an excellent job when it comes to supporting threads.

Now and as that model comes to completion and stabilizes we are free to look at higher level issues. C++ is one of those. A subgroup within the frysk group has formed that focuses on this problem. Currently the team is Stan Cox, Teresa Thomas, and my self.

Stan Cox is developing and stress testing the frysk type system. This insures that frysk correctly understands C/C++ types and can therefore understand them and print them properly. His test system automatically genereates a large number of types and type combinations and automatically tests that frysk is handling them correctly.

Teresa started off working on implementing and testing the frysk location expression evaluation system. When a debugger wants to examin variable values and change variable values it needs to understand location expressions provided by DWARF debugging informatio. Now she is woking on improving the handling of operators by the frysk type system. Forexample .(dot), -> (explicit dereferencing), *(derefrencing), [] etc.

Our goal is that C++ expression evaluation just works no buts no ifs. Stay tuned.

frysks

September 26, 2007

Having worked on frysk for so long, and on so many different aspects of it, I have developed a nice little system that keeps my productivity up.

I have a directory called frysks

in frysks there are several check outs of frysk under different names. Currently I have:

frysk
frysk.patches
frysk.testBuild
FRESH

also: frysk.DebugInfoRefactoring, frysk.mergeBranch, frysk.signalStop, frysk.lineNumberBug, frysk.searchEngine, frysk.vanila_elfutils.

The first four are the most note worthy. First is frysk this directory contains what I am currently working on. I pretty much never cvs update this tree except when I want to commit. So this directory always builds and usually has good test results except for things that I have broken.

frysk.patches I update all the time, and I mostly use it when people ask for a quick bug fix, or i have a small patch that I want to commit.

frysk.testBuild is what I use to test that the build is working and test results are okay. I never edit the files in frysk.testBuild I only cvs update.

FRESH contains a clean check out of frysk that has never been used for a build so it is identical to cvs and has no contaminating autotools files. When I am working in frysk and i want to switch contest I just :

mv frysk frysk.whatEverIwasWorkingON

and

cp -r FRESH/frysk .
cd frysk
cvs update

That way I always have a building version of frysk with clean test results that I can use. I also have eclipse projects corresponding to most directories above so I can easily switch between them.

Inlined functions

July 17, 2007

Now it is time to extend stack traces to include inlined functions.

Currently one goes to StackFactory to get a Stack trace which is a linked list of Frame objects. To handle inlined functions a new object called VirtualFrame and VirtualStackFactory will be introduced. The VirtualFrame will represent the “Frame” corresponding to the inlined function call.

VirtualStackFactory will return a linked list of Frame objects, some of which will be VirtualFrames. So when you are debugging you will be able to step in and out of the VirtualFrame, query it for its corresponding (inlined) function, query that for its parameters, their values etc.

Status:

I am currently looking into a libdwfl bug where it is mishandling scopes when dealing with inlined functions. Once that is cleared I will start creating and testing the above described structure.

Stack Traces

July 16, 2007

So I havent blogged about what I am working on for a while. Here is a quick summary and status:

I have moved from working on the frysk gui to working on frysk core. I enjoy working on the gui very much but change and learning new things is always great.

Back when I started on this assignment Frysk provided what we refer to as an abi stack back trace. Which is a stack frames, their addresses, and corresponding symbols (if they are still available in the executable). My assignment was and is using an executables debug info to enrich this model and provide more information.

Each abi frame corresponds to a Subprogram; a concrete (not inlined) function call. Each Subprogram has parameters, and variables. Actually wait, a Scope has variables, and a Subprogram is a Scope. Any Scope can intern own other Scopes and so on.

So I started working on creating the data structure described above writing test cases etc and in todays frysk you have access to all this information.

Given a stopped Task (thread) a client of this api can do the following:


public void examineStack(Task task){
  Frame frame = StackFactory.createFrame(task);Subprogram subprogram = frame.getSubprogram();
  System.out.println("function name: " + subprogram.getName());

  LinkedList parameters = subprogram.getParameters();
  System.out.println("this function has " + parameters.size() + " paramters");

  Variable variable = (Variable) parameters.getFirst();
  System.out.println("The first paramters is " + variable.getVariable().getText());
  System.out.println("In the current frame it has a value of " + variable.getValue(frame));

  LinkedList variables = subprogram.getVariables();
  System.out.println("The function has " + variables.size() + " variables ");

  variable = (Variable) variables.getFirst();
  System.out.println("The first variable is " + variable.getVariable().getText());
  System.out.println("In the current frame it has the value of " + variable.getValue(frame));

}

You will notice of course that I have avoided inlined functions. The way we have chosen to handle them is very interesting imho, and is the topic of the next blog post.

Ps. formatting code in wordpress is a pain.

notify-send

June 6, 2007

First of all I would like to give a big shout out to the folks who wrote libnotify. Libnotify standarized gnome notification solution, and they did a good job of it. The popup widget allows you to add buttons, images, and they look very good.

notify-send is a command line utility that makes uses libnotify to send notifications the the user.

for example:

notify-send hi

shows this:

notify-send.png

As soon as i discouvered this I started using it to notify me when my build is finished. So:

 

make && notify-send DONE!

Then I got fancier and I added this to my .bashrc:

alias saydone='notify-send "Done! `if [ \$? = 0 ]; then echo \:\); else echo \:\(; fi`"'

no explanation nessesary of course.

so now I do;

../frysk/autogen.sh ; saydone

If the autogen returns a 0 i get a smily face, otherwise I get a frowny.

saydone.png

Now for the bash guros out there. How do i make it print the previously run command so that the notification says “../frysk/autogen.sh finished :)

Interns and Ex-terns part-2

June 1, 2007

Okay so in the previous post I said I will tell you about the CatchError. Well here is the code: CatchError.java

So lets take a closer look at the critical parts of the code.

public static String myError;

public static void main (String[] args)
{
  //some argument parsing
  //...
  Manager.host.requestCreateAttachedProc(myArgs, attachedObserver);
  Manager.eventLoop.run();
}

In the above code segment we do some argument parsing, we ask the host object to create an attached Proc and we start the event loop. The rest of the juicy details happen in attachedObserver:

static TaskObserver.Attached attachedObserver = new TaskObserver.Attached(){

  public Action updateAttached (Task task)
  {
    task.requestAddSyscallObserver(syscallObserver);
    return Action.BLOCK;
  }

  public void addFailed (Object observable, Throwable w){}
  public void addedTo (Object observable){}
  public void deletedFrom (Object observable){}
};

Very simple. When updateAttached is called we are being told the process has been created, attached, is block very early in its life time, and waiting for instructions. So we attempt to add a syscallObserver to it, and make sure to return Action.BLOCK so that the process doesnt slip through our fingers before syscallObserver is watching those naught write calls.

syscallObserver does all the heavy lifting:

static TaskObserver.Syscall syscallObserver = new TaskObserver.Syscall(){
  public Action updateSyscallEnter (Task task)
  {
    SyscallEventInfo eventInfo = task.getSyscallEventInfo();
    frysk.proc.Syscall syscall = eventInfo.getSyscall(task);

    if(syscall.getName().equals("write")){
      long address = syscall.getArguments(task, 2);
      StringBuffer x = new StringBuffer();
      task.getMemory().get(address, 200, x);
      String xString = new String(x);

      if(xString.contains(myError)){
        Frame frame = StackFactory.createFrame(task);
        System.out.println("we got it! here is a stack trace:n" +
        StackFactory.printStackTrace(frame));
      }
    }
  return Action.CONTINUE;
  }

  public Action updateSyscallExit (Task task)
  {
    return Action.CONTINUE;
  }

  public void addedTo (Object observable)
  {
    Task task = (Task) observable;
    task.requestUnblock(attachedObserver);
  }

  public void addFailed (Object observable, Throwable w){}
  public void deletedFrom (Object observable){}

};

updateSyscallEnter gets called telling us that a syscall is happening, we check if it is a write, if so we retrieve its string argument, and figure out if it is trying to write the string that we are interested in. If so, we ask frysk to extract a stack trace at that point in the procs life time. One thing to point out that I guess might not be obvious is that we actually get notified while the system call is happening, and during the execution of the code inside updateSyscallEnter, the task is actually stopped during the stack call that resulted in the syscall so it is a good point to extract a stack back trace.

Another interesting part in syscallObserver is this:


public void addedTo (Object observable)
{
  Task task = (Task) observable;
  task.requestUnblock(attachedObserver);
}

If you remember earlier we told the task to stay blocked, well we have to unblock it so it can go on to exec, and make all those write calls. This is a good point to unblock it because we are now sure that the syscallObserver has been added. Also note that the api to unblock a task requires you to pass in the object that requested the block. This is to prevent any unintentional unblocking of tasks. That is to say that a task is not unblock until all parties that requested blocks have signed off.

It was pretty cool to use eclipse to do this. Code completion allowed me to focuse on frysk rather than java, and syntax errors. Also, I was able to finish coding in ~35 minutes.

Interns and Ex-terns part-1

June 1, 2007

Here at Red Hat Toronto we have a very lively internship program. Every year we hire a few interns and they stay with us for 16 months terms during which they make significant contributions to the various development projects that we have at Red Hat Toronto.

I started as an intern at Red Hat, so as an Ex-tern I was asked to give a talk on Frysk to the new interns. I though what better ways to introduce Frysk than show them some code. So, for the second half of the presentation we wrote a useful little Frysk command line utility called CatchError.

Ever had a program you are working on or using crash on you printing some random error message to the terminal ? Well I have :) When we worked together in the monitor phil and I used to get errors like this all the time:

 (Frysk:19767): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)’ failed

There was just no way to figure out what exact sequence of events resulted in this error. The tool we wrote yesterday allows you to get more information about that sort of error.

Given a string of an interesting error CatchError will monitor all the write system calls that your program makes until it tries to write the given string. At that moment CatchError pulls a stack trace and prints it to terminal. In the above example this will allow you to narrow things down to one set of GObjects out the the thousands that are swimming around. The utility ended up being around 100 lines of code, about 20 of which I wrote and the rest was eclipse generated :) .

In the next episode I will post the code and go through it. Stay tuned.

Red Hat Summit

May 10, 2007

Check out these cool videos from the Red Hat Summit:

http://www.redhat.com/promo/summit/?sc_cid=bcm_bnrhpsummit_032

My favorite quote is from the presentation Brian Stevens. He was talking about running Windows ontop of Linux using virtualization and he says “I can see the day that Linux and Open Source Software are actually gonna be used to make Windows manageable and secure”
I also particularly enjoyed this article by Shadowman reporting from the Red Hat Summit:

http://www.redhatmagazine.com/2007/05/09/ask-shadowman-ye-olde-linux-desktop/

Working on frysk I feel I can relate to it very much :)

Usability Rant #1

March 25, 2007

This is the first episode of the “Usability Rant” series, in which I complain about certain usability (or rather lack there of) features in software.

In todays episode I would like to talk about the next page button you find in websites with any sort of list. Can anyone tell me why the next button is needed ? Why cant all the items be listed on one page ? Then I dont have to torture my self trying to aim for the ‘next’ link and I can just can the entire content in one scroll. More importantly I can search using the find widget in my firefox browser (by the way; great feature!).

I understand that there might be a reason, that I am not aware of, which prevents people form listing 5000 items on one page. In that case instead of showing them in 100 item groups over 500 pages just have a link that shows the first hundred then explain to the user that there is more and that he/she can click on the show all button.

And that was our show for tonight… till next time!


Follow

Get every new post delivered to your Inbox.