Difference between revisions of "Tracking Library Use"

From AtlasWiki
Jump to: navigation, search
Line 1: Line 1:
 
=== "Where is this library being used?" ===
 
=== "Where is this library being used?" ===
  
1. Find library in question.
+
Have you ever needed to know where a certain library is used?  It can be an important task to find proper use patterns or to replace calls to deprecated code. Finding references to a library can be fast, and Atlas can even show details about how callers use the library.  This tutorial will explore strategies for finding library use in ConnectBot, an open source Secure Shell client for the Android operating system.  The library we are concerned with is the <code>android.content.pm</code> package, which we find called from within the method <code>onConfigurationChanged</code> in the <code>ConsoleActivity</code> class.
  
[[File:onConfigurationChanged.png|600px]]
 
  
2. If concerned with particular methods/fields, use call-step/dataflow-step.
+
[[File:onConfigurationChanged.png|650px]]
 +
 
 +
 
 +
If you are concerned with tracking only particular methods or fields in a library, the Smart View is a good way to see all of their uses in your workspace.  Select the piece of code you wish to follow, and choose the appropriate Smart View script- dataflow for fields, and calls for methods.  For more information on how to do this, see [[Tracking Variables]].  In this tutorial, we will look at ways of finding links to larger portions of a library.
  
 
3. If concerned with entire library, put library into <b>Connection View</b> leaves pane.  We'll choose this option to display a reverse call graph of the entire package.  Enter the package into the Connection View either by dragging and dropping it into the leaves pane or by right-clicking the package and selecting <code>Atlas -&gt; Connection View -&gt; Add To Leaves</code>.
 
3. If concerned with entire library, put library into <b>Connection View</b> leaves pane.  We'll choose this option to display a reverse call graph of the entire package.  Enter the package into the Connection View either by dragging and dropping it into the leaves pane or by right-clicking the package and selecting <code>Atlas -&gt; Connection View -&gt; Add To Leaves</code>.
 +
  
 
[[File:LibraryReverseCall.png|450px]]
 
[[File:LibraryReverseCall.png|450px]]
 +
  
 
The resulting graph shows us a graph of all calls that lead to the <code>android.content.pm</code> package.  We can see that the package we're concerned with is used by three methods in two classes.   
 
The resulting graph shows us a graph of all calls that lead to the <code>android.content.pm</code> package.  We can see that the package we're concerned with is used by three methods in two classes.   
  
 
4. Either put relevant classes and methods into roots pane, or put items into omissions pane.  We will do the former.
 
4. Either put relevant classes and methods into roots pane, or put items into omissions pane.  We will do the former.
 +
  
 
[[File:LibraryAddRoots.png|450px]]
 
[[File:LibraryAddRoots.png|450px]]
 +
  
 
5. Calls now visible more explicitly
 
5. Calls now visible more explicitly
 +
  
 
[[File:LibraryFiltered.png|500px]]
 
[[File:LibraryFiltered.png|500px]]
 +
  
 
6. Double-click on other calls to examine them in the source code.  Let's look at the other method in our class that calls <code>android.content.pm</code> first.  Double-clicking the method takes us to the method declaration, or double-clicking the edge directly highlights the line where the library is called.
 
6. Double-click on other calls to examine them in the source code.  Let's look at the other method in our class that calls <code>android.content.pm</code> first.  Double-clicking the method takes us to the method declaration, or double-clicking the edge directly highlights the line where the library is called.
 +
  
 
[[File:ConfigureOrientation.png|700px]]
 
[[File:ConfigureOrientation.png|700px]]
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
[[File:FollowEdge.png|300px]]
 
[[File:FollowEdge.png|300px]]
 +
  
 
7. Next, we can see that the only other class accessing the library in question has multiple reads from one method.
 
7. Next, we can see that the only other class accessing the library in question has multiple reads from one method.
 +
  
 
[[File:TerminalViewLibraryAccess.png|500px]]
 
[[File:TerminalViewLibraryAccess.png|500px]]

Revision as of 18:22, 30 April 2015

"Where is this library being used?"

Have you ever needed to know where a certain library is used? It can be an important task to find proper use patterns or to replace calls to deprecated code. Finding references to a library can be fast, and Atlas can even show details about how callers use the library. This tutorial will explore strategies for finding library use in ConnectBot, an open source Secure Shell client for the Android operating system. The library we are concerned with is the android.content.pm package, which we find called from within the method onConfigurationChanged in the ConsoleActivity class.


OnConfigurationChanged.png


If you are concerned with tracking only particular methods or fields in a library, the Smart View is a good way to see all of their uses in your workspace. Select the piece of code you wish to follow, and choose the appropriate Smart View script- dataflow for fields, and calls for methods. For more information on how to do this, see Tracking Variables. In this tutorial, we will look at ways of finding links to larger portions of a library.

3. If concerned with entire library, put library into Connection View leaves pane. We'll choose this option to display a reverse call graph of the entire package. Enter the package into the Connection View either by dragging and dropping it into the leaves pane or by right-clicking the package and selecting Atlas -> Connection View -> Add To Leaves.


LibraryReverseCall.png


The resulting graph shows us a graph of all calls that lead to the android.content.pm package. We can see that the package we're concerned with is used by three methods in two classes.

4. Either put relevant classes and methods into roots pane, or put items into omissions pane. We will do the former.


LibraryAddRoots.png


5. Calls now visible more explicitly


LibraryFiltered.png


6. Double-click on other calls to examine them in the source code. Let's look at the other method in our class that calls android.content.pm first. Double-clicking the method takes us to the method declaration, or double-clicking the edge directly highlights the line where the library is called.


ConfigureOrientation.png        FollowEdge.png


7. Next, we can see that the only other class accessing the library in question has multiple reads from one method.


TerminalViewLibraryAccess.png