use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent in project binnavi by google.
the class CEventTableModel method getValueAt.
@Override
public Object getValueAt(final int row, final int col) {
final ITraceEvent debugEvent = getEvents().get(row);
final BreakpointAddress address = debugEvent.getOffset();
switch(col) {
case INDEX_COLUMN:
return row + 1;
case THREAD_COLUMN:
return Long.valueOf(debugEvent.getThreadId());
case MODULE_COLUMN:
return address.getModule() == null ? "-" : address.getModule().getConfiguration().getName();
case ADDRESS_COLUMN:
{
if (address.getModule() == null) {
return address.getAddress().getAddress().toHexString();
} else {
final INaviFunction function = address.getModule().isLoaded() ? address.getModule().getContent().getFunctionContainer().getFunction(address.getAddress().getAddress()) : null;
if (function == null) {
return address.getAddress().getAddress().toHexString();
} else {
return function.getName();
}
}
}
default:
throw new IllegalStateException("IE01121: Unknown column");
}
}
use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent in project binnavi by google.
the class CTraceFilterExpression method evaluate.
@Override
public boolean evaluate(final CTraceEventWrapper element) {
final ITraceEvent event = element.unwrap();
final INaviModule currentModule = event.getOffset().getModule();
String functionName = "";
String moduleName = "";
if (currentModule != null) {
final INaviFunction function = currentModule.isLoaded() ? currentModule.getContent().getFunctionContainer().getFunction(event.getOffset().getAddress().getAddress()) : null;
if (function != null) {
functionName = function.getName();
}
moduleName = currentModule.getConfiguration().getName();
}
return String.valueOf(event.getThreadId()).contains(m_text) || event.getOffset().getAddress().getAddress().toHexString().contains(m_text) || moduleName.contains(m_text) || functionName.contains(m_text);
}
use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent in project binnavi by google.
the class CEventTableMenu method addOpenFunction.
/**
* Adds a menu item to open the selected trace.
*
* @param parent Parent window of the menu.
* @param traces The selected traces.
*/
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
if (traces.size() == 1) {
final ITraceEvent trace = traces.get(0);
final INaviModule module = trace.getOffset().getModule();
if (module.isLoaded()) {
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
if (function != null) {
final IViewContainer container = graphModel.getViewContainer();
final INaviView view = container.getView(function);
if (view != null) {
add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
addSeparator();
}
}
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent in project binnavi by google.
the class PostgreSQLProviderTest method testTraceFunctionsSave1.
@Test
public void testTraceFunctionsSave1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final INaviProject project = getProvider().createProject("SOME_PROJECT");
getProvider().createTrace(project, "SOME_TRACE", "SOME_TRACE_DESCRIPTION");
project.load();
final TraceList trace = project.getContent().getTraces().get(0);
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final long tid = 0x1L;
final UnrelocatedAddress address2 = new UnrelocatedAddress(new CAddress(0x1234));
final BreakpointAddress address = new BreakpointAddress(module, address2);
final TraceEventType type = TraceEventType.ECHO_BREAKPOINT;
final List<TraceRegister> values = new ArrayList<>();
final ITraceEvent event = new TraceEvent(tid, address, type, values);
trace.addEvent(event);
trace.setDescription("burzelbarf");
PostgreSQLTraceFunctions.save((AbstractSQLProvider) getProvider(), trace);
project.close();
INaviProject project2 = null;
for (final INaviProject cProject : getProvider().loadProjects()) {
if (cProject.getConfiguration().getId() == project.getConfiguration().getId()) {
project2 = cProject;
}
}
getProvider().createTrace(project2, "SOME_TRACE_2", "SOME_TRACE_DESCRIPTION_2");
project2.load();
final TraceList trace2 = project2.getContent().getTraces().get(0);
assertEquals("burzelbarf", trace2.getDescription());
}
use of com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent in project binnavi by google.
the class CEventTableModelTest method testSimple.
/**
* General test whether the model is working as expected.
*
* @throws RecognitionException
*/
@Test
public void testSimple() throws RecognitionException {
final INaviModule mockModule = new MockModule();
final INaviModule mockModule2 = new MockModule(true);
final INaviModule mockModule3 = new MockModule();
final CEventTableModel model = new CEventTableModel();
final TraceList list = new TraceList(1, "", "", new MockSqlProvider());
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x123))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 05 }))));
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule2, new UnrelocatedAddress(new CAddress(0x124))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 06 }))));
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule3, new UnrelocatedAddress(new CAddress(0x125))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 07, 05 }))));
assertEquals(0, model.getRowCount());
model.setEventList(list);
assertEquals(3, model.getRowCount());
final IFilter<ITraceEvent> filter = new CTraceFilterCreator().createFilter("mem == 05");
model.setFilter(filter);
assertEquals(2, model.getRowCount());
assertEquals(2, model.getEvents().size());
assertEquals(0x123, model.getEvents().get(0).getOffset().getAddress().getAddress().toLong());
assertEquals(0x125, model.getEvents().get(1).getOffset().getAddress().getAddress().toLong());
model.setFilter(null);
assertEquals(3, model.getRowCount());
for (int i = 0; i < model.getRowCount(); i++) {
for (int j = 0; j < model.getColumnCount(); j++) {
model.getValueAt(i, j);
}
}
}
Aggregations