use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.
the class PostgreSQLHelpers method getViewsWithAddress.
/**
* Searches for the views with a given address.
*
* @param connection Connection to a SQL database.
* @param query SQL query to issue for the search.
* @param columnName Name of the column from which the container ID is read.
* @param finder Finder object that is used to find the view object from a view ID.
*
* @return A list of views that was found by the query.
*
* @throws CouldntLoadDataException Thrown if the search failed with an error.
*/
// TODO (timkornau): find out if there is a better way to have the sql query build in here rather
// then in the caller.
// It just seems to be wrong like this.
public static IFilledList<INaviView> getViewsWithAddress(final CConnection connection, final String query, final String columnName, final ContainerFinder finder) throws CouldntLoadDataException {
Preconditions.checkNotNull(finder, "IE00607: Finder argument can not be null");
Preconditions.checkNotNull(columnName, "IE00608: Column name argument can not be null");
Preconditions.checkNotNull(query, "IE00627: Query argument can not be null");
Preconditions.checkNotNull(connection, "IE00628: Connection argument can not be null");
final IFilledList<INaviView> views = new FilledList<INaviView>();
try (ResultSet resultSet = connection.executeQuery(query, true)) {
while (resultSet.next()) {
final int containerId = resultSet.getInt(columnName);
final int viewId = resultSet.getInt("view_id");
final INaviView view = finder.findView(containerId, viewId);
views.add(view);
}
return views;
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.
the class PostgreSQLModuleCallgraphsLoader method loadModuleCallgraphs.
/**
* Loads the call graph views of a module. Depending on the view type argument, this function can
* load the native call graph view or non-native call graph views.
*
* The arguments module, viewTagManager, and nodeTagManager must belong to the database connected
* to by the provider argument.
*
* @param provider The connection to the database.
* @param module The module whose call graph views are loaded.
* @param viewTagManager The tag manager responsible for tagging the views.
* @param nodeTagManager The tag manager responsible for tagging view nodes.
* @param viewType The type of the views to load.
*
* @return The loaded views.
*
* @throws CouldntLoadDataException Thrown if the views could not be loaded.
*/
private static IFilledList<ICallgraphView> loadModuleCallgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final ITagManager nodeTagManager, final ViewType viewType) throws CouldntLoadDataException {
PostgreSQLViewsLoader.checkArguments(provider, module, viewTagManager);
final String query = "SELECT * FROM load_module_call_graphs(?, ?)";
try {
final CConnection connection = provider.getConnection();
final PreparedStatement statement = connection.getConnection().prepareStatement(query);
statement.setInt(1, module.getConfiguration().getId());
statement.setObject(2, viewType == ViewType.Native ? "native" : "non-native", Types.OTHER);
final ResultSet resultSet = statement.executeQuery();
final Map<Integer, Set<CTag>> tags = PostgreSQLModuleViewsLoader.loadTags(connection, module, viewTagManager);
return new FilledList<ICallgraphView>(processQueryResults(resultSet, module, tags, nodeTagManager, provider, new ArrayList<CView>(), viewType, GraphType.CALLGRAPH));
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.
the class PostgreSQLModuleMixedGraphsLoader method loadMixedgraphs.
/**
* Loads the mixed-graph views of a module. These mixed graph views are necessarily non-native
* because there are no native mixed graph views.
*
* The module, the view tag manager, and the node tag manager must be stored in the database
* connected to by the provider argument.
*
* @param provider The SQL provider that provides the connection.
* @param module The module from where the views are loaded.
* @param viewTagManager View tag manager that contains all view tags of the database.
* @param nodeTagManager The tag manager responsible for tagging view nodes.
*
* @return A list of non-native mixed-graph views.
*
* @throws CouldntLoadDataException Thrown if the views could not be loaded.
*/
public static IFilledList<INaviView> loadMixedgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final CTagManager nodeTagManager) throws CouldntLoadDataException {
checkArguments(provider, module, viewTagManager);
final String query = "SELECT * FROM load_module_mixed_graph(?)";
try {
final CConnection connection = provider.getConnection();
final PreparedStatement statement = connection.getConnection().prepareStatement(query);
statement.setInt(1, module.getConfiguration().getId());
final ResultSet resultSet = statement.executeQuery();
final Map<Integer, Set<CTag>> tags = loadTags(connection, module, viewTagManager);
return new FilledList<INaviView>(processQueryResults(resultSet, module, tags, nodeTagManager, provider, new ArrayList<CView>(), ViewType.NonNative, GraphType.MIXED_GRAPH));
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.
the class CDebugBottomPanel method getPanels.
/**
* Creates the panels that are shown in the panel.
*
* @param model Provides the data needed by the components in the panel.
* @param debugPerspectiveModel Describes the debug perspective.
*
* @return The created panels.
*/
private static IFilledList<IResultsPanel> getPanels(final CGraphModel model, final CDebugPerspectiveModel debugPerspectiveModel) {
final IFilledList<IResultsPanel> debugPanels = new FilledList<IResultsPanel>();
debugPanels.add(new CCombinedMemoryPanel(model.getParent(), debugPerspectiveModel));
debugPanels.add(new CModulesPanel(debugPerspectiveModel));
debugPanels.add(new CThreadInformationPanel(debugPerspectiveModel));
debugPanels.add(new CBreakpointPanel(model.getParent(), model.getDebuggerProvider(), model.getGraph(), model.getViewContainer()));
debugPanels.add(new CTracesPanel(debugPerspectiveModel, model.getGraph(), model.getViewContainer().getTraceProvider(), model.getGraphPanel()));
debugPanels.add(new CBookmarkPanel(model.getDebuggerProvider()));
debugPanels.add(new CDebuggerHistoryPanel(debugPerspectiveModel));
return debugPanels;
}
use of com.google.security.zynamics.zylib.types.lists.IFilledList in project binnavi by google.
the class PostgreSQLProviderTest method testCModuleFunctionsgetViewsWithAddresses1.
@Test
public void testCModuleFunctionsgetViewsWithAddresses1() throws CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
List<INaviView> views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(0, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x10033DCL)));
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(1, views.size());
addresses.add(new UnrelocatedAddress(new CAddress(0x1003429)));
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, true);
assertEquals(0, views.size());
views = PostgreSQLModuleFunctions.getViewsWithAddresses((AbstractSQLProvider) getProvider(), module, addresses, false);
assertEquals(2, views.size());
}
Aggregations