funcscan
Version 1.0.0

de.ovgu.cs.funcscan
Class Module

java.lang.Object
  extended by de.ovgu.cs.funcscan.Module

public class Module
extends Object

A container for information extracted by nm.

Version:
$Revision: 577 $
Author:
Jens Elkner

Constructor Summary
Module(String filename, String remove)
          Create a new Module.
 
Method Summary
 void add(Symbol s, String name)
          Add the given symbol to this module.
 LinkedHashMap<String,de.ovgu.cs.funcscan.Module.CP> getFunctionCallers(Collection<Module> potentialCaller, boolean cached)
          Get all modules, which call a global function of this module.
 String getFunctionDefinition(String name)
          Get the definition for the given function.
 String getName()
          Get the name of the module file.
 String getSource()
          Get the 'cc -E' pre-processed source code for this module.
 String getSrcName()
          Get the name of the source file for this module.
 Set<String> getSymbolNames(Symbol type)
          Get the names of all symbols for the given type.
 String getVarDefinition(String name)
          Get the definition for the given variable.
 LinkedHashMap<String,de.ovgu.cs.funcscan.Module.CP> getVarsCallers(Collection<Module> potentialCaller, boolean cached)
          Get all modules, which refer to a global variable of this module.
 void setFunctionDefinition(String name, String code)
          Set the definition for the given function.
 void setSource(String source)
          Add the 'cc -E' pre-processed source for this module.
 void setVarDefinition(String name, String code)
          Set the definition for the given variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Module

public Module(String filename,
              String remove)
Create a new Module.

Parameters:
filename - the name of the object file.
remove - the regex to use to construct the real source file name from the given filename. Might be null.
See Also:
String.replaceAll(String, String)
Method Detail

getName

public String getName()
Get the name of the module file.

Returns:
the modules filename

getSrcName

public String getSrcName()
Get the name of the source file for this module.

Returns:
the module's source file name

add

public void add(Symbol s,
                String name)
Add the given symbol to this module.

Parameters:
s - symbol type
name - name of the symbol

getSymbolNames

public Set<String> getSymbolNames(Symbol type)
Get the names of all symbols for the given type.

Parameters:
type - type of the symbol names to return.
Returns:
a possible empty set, but not null.

getFunctionCallers

public LinkedHashMap<String,de.ovgu.cs.funcscan.Module.CP> getFunctionCallers(Collection<Module> potentialCaller,
                                                                              boolean cached)
Get all modules, which call a global function of this module.

Parameters:
potentialCaller - a list of modules to check for calling.
cached - if true, avoid re-scanning and return the result from the last scan if there is one.
Returns:
null if the parameter is null or empty, otherwise a map with global function names of this module paired with a set of modules, which define and call this function. Since the scan is based on the object file information (undefined global symbols) only, name clashes may occur, so that a caller gets listed as well, which refers not to the function but an external variable with the same name.

getVarsCallers

public LinkedHashMap<String,de.ovgu.cs.funcscan.Module.CP> getVarsCallers(Collection<Module> potentialCaller,
                                                                          boolean cached)
Get all modules, which refer to a global variable of this module.

Parameters:
potentialCaller - a list of modules to check for references.
cached - if true, avoid re-scanning and return the result from the last scan if there is one.
Returns:
null if the parameter is null or empty, otherwise a map with global variable names of this module paired with a set of modules, which define and reference this variable. Since the scan is based on the object file information (undefined global symbols) only, name clashes may occur, so that a source files gets listed as well, which refers not to the variable but an external function with the same name.

setSource

public void setSource(String source)
Add the 'cc -E' pre-processed source for this module. End of Lines have to follow Unix SYSV conventions, i.e. must be (one linefeed == 0x0a) and nothing else.

Parameters:
source - the pre-processed source to set. Use an empty String to indicate, that source code for this module could not be found or the pre-processor was unable to handle it.
See Also:
getSrcName(), getSource()

getSource

public String getSource()
Get the 'cc -E' pre-processed source code for this module.

Returns:
null if not yet available, an empty String, if the source code could not be found or pre-processed, the source code otherwise.

setFunctionDefinition

public void setFunctionDefinition(String name,
                                  String code)
Set the definition for the given function.

Parameters:
name - name of the function
code - definition to add.
See Also:
getFunctionDefinition(String)

getFunctionDefinition

public String getFunctionDefinition(String name)
Get the definition for the given function.

Parameters:
name - name of the function
Returns:
null if not set, an empty string if it could not be extracted from source, the definition otherwise.
See Also:
setFunctionDefinition(String, String)

setVarDefinition

public void setVarDefinition(String name,
                             String code)
Set the definition for the given variable.

Parameters:
name - name of the variable
code - definition to add.
See Also:
getVarDefinition(String)

getVarDefinition

public String getVarDefinition(String name)
Get the definition for the given variable.

Parameters:
name - name of the variable
Returns:
null if not set, an empty string if it could not be extracted from source, the definition otherwise.
See Also:
setVarDefinition(String, String)

funcscan
Version 1.0.0

Created by Jens Elkner