use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class PostgreSQLTagFunctions method deleteTagSubtree.
/**
* Deletes a tag and all of its subtrees.
*
* @param provider The connection to the database.
* @param tag The root tag of the subtree to delete.
*
* @throws CouldntDeleteException Thrown if the subtree could not be deleted.
*/
public static void deleteTagSubtree(final AbstractSQLProvider provider, final ITreeNode<CTag> tag) throws CouldntDeleteException {
checkArguments(provider, tag);
Preconditions.checkNotNull(tag.getParent(), "IE00559: Can not delete the root tag");
final CConnection connection = provider.getConnection();
try {
final StringBuilder query = new StringBuilder(String.format("delete from %s where id = %d", CTableNames.TAGS_TABLE, tag.getObject().getId()));
final List<Integer> idsToDelete = new ArrayList<>();
for (final ITreeNode<CTag> child : DepthFirstSorter.getSortedList(tag)) {
idsToDelete.add(child.getObject().getId());
query.append(" or id = " + tag.getObject().getId());
}
connection.executeUpdate(query.toString(), true);
} catch (final SQLException e) {
throw new CouldntDeleteException(e);
}
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class CProjectContent method createView.
/**
* Creates a new empty view with the given name and description in the project. The new view is
* not stored in the database until INaviView::save is called.
*
* @param name The name of the new view.
* @param description The description of the new view.
*
* @return The new view that was created in the project.
*/
public INaviView createView(final String name, final String description) {
final Date date = new Date();
final CProjectViewGenerator generator = new CProjectViewGenerator(m_provider, m_project);
final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
try {
view.load();
} catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
// This can not happen; new views with ID -1 do not access the database
// when they are loaded.
CUtilityFunctions.logException(e);
}
addView(view);
return view;
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class CViewContent method createFunctionNode.
@Override
public CFunctionNode createFunctionNode(final INaviFunction function) {
Preconditions.checkNotNull(function, "IE00294: Function argument can not be null");
Preconditions.checkArgument(function.inSameDatabase(provider), "IE00295: Function and view are not in the same database");
final CFunctionNode functionNode = new CFunctionNode(-1, function, 0, 0, 0, 0, CFunctionNodeColorizer.getFunctionColor(function.getType()), false, true, null, new HashSet<CTag>(), provider);
addNode(functionNode);
updateGraphType(functionNode);
functionNode.addListener(m_internalNodeListener);
return functionNode;
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class CViewContainer method createView.
/**
* Creates a new empty view in the module.
*
* @param name The name of the new view.
* @param description The description of the new view.
*
* @return The new view.
*/
public CView createView(final String name, final String description) {
Preconditions.checkNotNull(name, "IE00164: Name argument can not be null");
Preconditions.checkNotNull(description, "IE00165: Name description can not be null");
final Date date = new Date();
final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, m_module);
final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
try {
view.load();
} catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
CUtilityFunctions.logException(e);
}
addView(view);
return view;
}
use of com.google.security.zynamics.binnavi.Tagging.CTag in project binnavi by google.
the class TraceLoggerTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
final SQLProvider mockProvider = new MockSqlProvider();
// CDatabase("", "", "", "", "", false,
final IDatabase internalDatabase = new MockDatabase();
// false);
final Database database = new Database(internalDatabase);
database.load();
final MockProject mockProject = new MockProject();
final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
m_mockDebugger = new MockDebugger(m_debugSettings);
m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
final Debugger debugger = new Debugger(m_mockDebugger);
m_logger = new TraceLogger(debugger, module);
m_projectLogger = new TraceLogger(debugger, project);
}
Aggregations