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

Re: SourceFile attribute



I see your problem, I would suggest following solution, it is quite easy.

1. create a SourceFileTag.java in soot/tagkit/, it can be similar as
   LineNumberTag.java
2. in soot/coffi/CFG.java, add several statements to create SourceFileTag
   for each jimple statements. Following code is how the LineNumberTag
   gets created. Of course, it needs some change for SourceFileTag:

  1595          /* covert line number table to tags attached to statements */
  1596          if (soot.Main.keepLineNumberAttribute)
  1597          {
  1598              HashMap stmtstags = new HashMap();
  1599              LinkedList startstmts = new LinkedList();
  1600
  1601              attribute_info[] attrs = codeAttribute.attributes;
  1602              for (int i=0; i<attrs.length; i++)
  1603              {
  1604                  if (attrs[i] instanceof LineNumberTable_attribute)
  1605                  {
  1606                      LineNumberTable_attribute lntattr =
  1607                          (LineNumberTable_attribute)attrs[i];
  1608                      for (int j=0; j<lntattr.line_number_table.length; j++)
  1609                      {
  1610                          Stmt start_stmt = (Stmt)instructionToFirstStmt.get(
  1611
lntattr.line_number_table[j].start_inst);
  1612
  1613                          if (start_stmt != null)
  1614                          {
  1615                              LineNumberTag lntag= new
LineNumberTag(
  1616                              lntattr.line_number_table[j].line_number);
  1617                              stmtstags.put(start_stmt, lntag);
  1618                              startstmts.add(start_stmt);
  1619                          }
  1620                      }
  1621                  }
  1622              }
  1623
  1624              /* attach line number tag to each statement. */
  1625              for (int i=0; i<startstmts.size(); i++)
  1626              {
  1627                  Stmt stmt = (Stmt)startstmts.get(i);
  1628                  Tag tag = (Tag)stmtstags.get(stmt);
  1629
  1630                  stmt.addTag(tag);
  1631
  1632                  stmt = (Stmt)units.getSuccOf(stmt);
  1633                  while (stmt != null
  1634                         && !stmtstags.containsKey(stmt))
  1635                  {
  1636                      stmt.addTag(tag);
  1637                      stmt = (Stmt)units.getSuccOf(stmt);
  1638                  }
  1639              }
  1640          }

3. I am assuming you are NOT going to output these attribute to inlined
   class files. Then most of your job is done.

You can implement this without much difficulty, we can not promise you
when it will be done if you are waiting for us.

Cheers,
===========================================================
Feng Qian                             fqian@sable.mcgill.ca