Archive for July, 2007

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.


Follow

Get every new post delivered to your Inbox.