use of org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect in project tracecompass by tracecompass.
the class UstDebugInfoAnalysisModuleTest method testBinaryCallsites.
/**
* Test that the binary callsite aspect resolves correctly for some
* user-defined tracepoints in the trace.
*
* These should be available even without the binaries with debug symbols
* being present on the system.
*/
@Test
public void testBinaryCallsites() {
LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(REAL_TEST_TRACE);
/*
* Fake a "trace opened" signal, so that the relevant analyses are
* started.
*/
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
TmfSignalManager.dispatchSignal(signal);
UstDebugInfoAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, UstDebugInfoAnalysisModule.class, UstDebugInfoAnalysisModule.ID);
assertNotNull(module);
module.waitForCompletion();
/* Send a request to get the 3 events we are interested in */
List<@NonNull LttngUstEvent> events = new ArrayList<>();
TmfEventRequest request = new TmfEventRequest(LttngUstEvent.class, 31, 1, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
events.add((LttngUstEvent) event);
}
};
trace.sendRequest(request);
try {
request.waitForCompletion();
} catch (InterruptedException e) {
fail(e.getMessage());
}
/* Tests that the aspects are resolved correctly */
final UstDebugInfoBinaryAspect aspect = UstDebugInfoBinaryAspect.INSTANCE;
String actual = checkNotNull(aspect.resolve(events.get(0))).toString();
String expected = "/home/simark/src/babeltrace/tests/debug-info-data/libhello_so+0x14d4";
assertEquals(expected, actual);
LttngUstTestTraceUtils.dispose(REAL_TEST_TRACE);
}
use of org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryAspect in project tracecompass by tracecompass.
the class UstDebugInfoAnalysisModule method getMatchingFile.
/**
* Get the binary file (executable or library) that corresponds to a given
* instruction pointer, at a given time.
*
* @param ts
* The timestamp
* @param vpid
* The VPID of the process we are querying for
* @param ip
* The instruction pointer of the trace event. Normally comes
* from a 'ip' context.
* @return A {@link UstDebugInfoLoadedBinaryFile} object, describing the
* binary file and its base address.
* @noreference Meant to be used internally by
* {@link UstDebugInfoBinaryAspect} only.
*/
@VisibleForTesting
@Nullable
public UstDebugInfoLoadedBinaryFile getMatchingFile(long ts, long vpid, long ip) {
try {
final ITmfStateSystem ss = getStateSystem();
if (ss == null) {
/* State system might not yet be initialized */
return null;
}
// $NON-NLS-1$
List<Integer> possibleBaddrQuarks = ss.getQuarks(String.valueOf(vpid), "*");
List<ITmfStateInterval> state = ss.queryFullState(ts);
/* Get the most probable base address from all the known ones */
OptionalLong potentialBaddr = possibleBaddrQuarks.stream().filter(quark -> Objects.equals(1, state.get(quark).getValue())).map(ss::getAttributeName).mapToLong(Long::parseLong).filter(baddr -> baddr <= ip).max();
if (!potentialBaddr.isPresent()) {
return null;
}
long baddr = potentialBaddr.getAsLong();
final int baddrQuark = ss.getQuarkAbsolute(String.valueOf(vpid), String.valueOf(baddr));
final int memszQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.MEMSZ_ATTRIB);
final long memsz = state.get(memszQuark).getStateValue().unboxLong();
/* Make sure the 'ip' fits the range of this object. */
if (!(ip < baddr + memsz)) {
/*
* Not the correct memory range after all. We do not have
* information about the library that was loaded here.
*/
return null;
}
final int pathQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.PATH_ATTRIB);
String filePath = state.get(pathQuark).getStateValue().unboxStr();
final int buildIdQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.BUILD_ID_ATTRIB);
ITmfStateValue buildIdValue = state.get(buildIdQuark).getStateValue();
String buildId = unboxStrOrNull(buildIdValue);
final int debugLinkQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.DEBUG_LINK_ATTRIB);
ITmfStateValue debugLinkValue = state.get(debugLinkQuark).getStateValue();
String debugLink = unboxStrOrNull(debugLinkValue);
final int isPicQuark = ss.getQuarkRelative(baddrQuark, UstDebugInfoStateProvider.IS_PIC_ATTRIB);
boolean isPic = state.get(isPicQuark).getStateValue().unboxInt() != 0;
// The baddrQuark interval lasts for the time this file is loaded
ITmfStateInterval validityInterval = state.get(baddrQuark);
return new UstDebugInfoLoadedBinaryFile(baddr, filePath, buildId, debugLink, isPic, validityInterval.getStartTime(), validityInterval.getEndTime());
} catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) {
/* Either the data is not available yet, or incomplete. */
return null;
}
}
Aggregations