Skip to content

Commit

Permalink
Update UFTrace to handle new format
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
MatthewKhouzam committed Feb 24, 2024
1 parent 9a73718 commit 6e20bad
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public UfCallstackProvider(@NonNull ITmfTrace trace) {

@Override
public int getVersion() {
return 2;
return 3;
}

@Override
Expand Down Expand Up @@ -108,4 +108,10 @@ protected long getThreadId(@NonNull ITmfEvent event) {
Integer resolve = fTidAspect.resolve(event);
return resolve == null ? -1 : resolve.longValue();
}

@Override
protected @Nullable String getThreadName(@NonNull ITmfEvent event) {
return Long.toHexString(getThreadId(event));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class MapEntry {

private final Perms fPerms;

private final String fExtra;

/**
* A map entry
*
Expand All @@ -53,10 +55,10 @@ public class MapEntry {
* inode location of the device
* @param pathName
* file path that backs this mapping (there may be pseudo-paths
* in brackes [])
* in brackets [])
*/
public MapEntry(long addrLow, long addrHigh, Perms perms, long offset, char deviceMinor, char deviceMajor, long iNode,
String pathName) {
String pathName, String extra) {
fAddrLow = addrLow;
fAddrHigh = addrHigh;
fPerms = perms;
Expand All @@ -65,6 +67,7 @@ public MapEntry(long addrLow, long addrHigh, Perms perms, long offset, char devi
fDeviceMinor = deviceMinor;
fINode = iNode;
fPathName = pathName;
fExtra = extra;
}

/**
Expand Down Expand Up @@ -142,4 +145,11 @@ public Perms getPerms() {
return fPerms;
}

/**
* @return the extra
*/
public String getExtra() {
return fExtra;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MapParser {
private static final String SESSION_PATTERN_STRING = "sid\\-([a-fA-F0-9]+)\\.map"; //$NON-NLS-1$
private static final Pattern SESSION_PATTERN = Pattern.compile(SESSION_PATTERN_STRING);
private static final Pattern MAPFILE_PATTERN = Pattern.compile(
"^\\s*([a-fA-F0-9]+)\\-([a-fA-F0-9]+)\\s+([rxwps-]+)\\s+([a-fA-F0-9]+)\\s+([a-fA-F0-9]+)\\:([a-fA-F0-9]+)\\s+([a-fA-F0-9]+)\\s*(\\S+)?$"); //$NON-NLS-1$
"^\\s*([a-fA-F0-9]+)\\-([a-fA-F0-9]+)\\s+([rxwps-]+)\\s+([a-fA-F0-9]+)\\s+([a-fA-F0-9]+)\\:([a-fA-F0-9]+)\\s+([a-fA-F0-9]+)\\s*(\\S*)\\s*(\\S*)"); //$NON-NLS-1$
private final long fSessionId;
private final NavigableMap<Long, MapEntry> fData;

Expand All @@ -62,18 +62,19 @@ public static MapParser create(File file) throws IOException {
while (iter.hasNext()) {
String line = iter.next();
Matcher matcher = MAPFILE_PATTERN.matcher(line);
matcher.matches();
long addrLow = Long.parseUnsignedLong(matcher.group(1), 16);
long addrHigh = Long.parseUnsignedLong(matcher.group(2), 16);
Perms perms = Perms.create(matcher.group(3));
long offset = Long.parseLong(matcher.group(4), 16);
char deviceHigh = (char) Integer.parseInt(matcher.group(5), 16);
char deviceLow = (char) Integer.parseInt(matcher.group(6), 16);
long iNode = Long.parseLong(matcher.group(7), 16);
String pathName = matcher.group(8);

entries.put(addrLow,
new MapEntry(addrLow, addrHigh, perms, offset, deviceLow, deviceHigh, iNode, pathName));
if (matcher.matches()) {
long addrLow = Long.parseUnsignedLong(matcher.group(1), 16);
long addrHigh = Long.parseUnsignedLong(matcher.group(2), 16);
Perms perms = Perms.create(matcher.group(3));
long offset = Long.parseLong(matcher.group(4), 16);
char deviceHigh = (char) Integer.parseInt(matcher.group(5), 16);
char deviceLow = (char) Integer.parseInt(matcher.group(6), 16);
long iNode = Long.parseLong(matcher.group(7), 16);
String pathName = matcher.group(8);
String extra = matcher.group(9);
entries.put(addrLow,
new MapEntry(addrLow, addrHigh, perms, offset, deviceLow, deviceHigh, iNode, pathName, extra));
}
}
return new MapParser(sessionId, entries);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/
public class SymParser {
private static final Pattern REGEX = Pattern.compile("^([a-fA-F\\d]+)\\s+([ABbCcDdGgiNPpRrSsTtUuVvWw\\-\\?])\\s*(.*)$"); //$NON-NLS-1$
private static final Pattern REGEX = Pattern.compile("^([a-fA-F\\d]+)\\s+([a-fA-F\\d]*)\\s*([ABbCcDdGgiNPpRrSsTtUuVvWw\\-\\?])\\s*(.*)$"); //$NON-NLS-1$

/**
* Symbol for
Expand Down Expand Up @@ -79,24 +79,26 @@ public String getName() {
* the file is not able to be read.
*/
public static SymParser parse(File file) throws IOException {
LineIterator iter = FileUtils.lineIterator(file);
SymParser sp = new SymParser();
while (iter.hasNext()) {
String line = iter.next();
if (line.startsWith("#")) {
continue;
}
Matcher match = REGEX.matcher(line);
if (!match.matches()) {
throw new IllegalArgumentException("invalid " + line); //$NON-NLS-1$

try (LineIterator iter = FileUtils.lineIterator(file)) {
SymParser sp = new SymParser();
while (iter.hasNext()) {
String line = iter.next();
if (line.startsWith("#")) { //$NON-NLS-1$
continue;
}
Matcher match = REGEX.matcher(line);
if (!match.matches()) {
throw new IllegalArgumentException("Symbol Parser: invalid line: " + line); //$NON-NLS-1$
}
long range = Long.parseUnsignedLong(match.group(1), 16);
char c = match.group(3).charAt(0);
String name = (match.groupCount() < 4) ? "Anonymous" : match.group(4); //$NON-NLS-1$
Symbol sym = new Symbol(c, name);
sp.fMap.put(range, sym);
}
long range = Long.parseUnsignedLong(match.group(1), 16);
char c = match.group(2).charAt(0);
String name = (match.groupCount() < 3) ? "Anonymous" : match.group(3); //$NON-NLS-1$
Symbol sym = new Symbol(c, name);
sp.fMap.put(range, sym);
return sp;
}
return sp;
}

/**
Expand Down

0 comments on commit 6e20bad

Please sign in to comment.