summaryrefslogtreecommitdiffstats
path: root/tools/preload/Record.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
commitd24b8183b93e781080b2c16c487e60d51c12da31 (patch)
treefbb89154858984eb8e41556da7e9433040d55cd4 /tools/preload/Record.java
parentf1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff)
downloadframeworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'tools/preload/Record.java')
-rw-r--r--tools/preload/Record.java46
1 files changed, 41 insertions, 5 deletions
diff --git a/tools/preload/Record.java b/tools/preload/Record.java
index 9ffab46..b2be4d4 100644
--- a/tools/preload/Record.java
+++ b/tools/preload/Record.java
@@ -56,11 +56,14 @@ class Record {
/** Record time (ns). */
final long time;
+
+ /** Source file line# */
+ int sourceLineNumber;
/**
* Parses a line from the loaded-classes file.
*/
- Record(String line) {
+ Record(String line, int lineNum) {
char typeChar = line.charAt(0);
switch (typeChar) {
case '>': type = Type.START_LOAD; break;
@@ -70,6 +73,8 @@ class Record {
default: throw new AssertionError("Bad line: " + line);
}
+ sourceLineNumber = lineNum;
+
line = line.substring(1);
String[] parts = line.split(":");
@@ -77,20 +82,51 @@ class Record {
pid = Integer.parseInt(parts[1]);
tid = Integer.parseInt(parts[2]);
- processName = parts[3].intern();
+ processName = decode(parts[3]).intern();
classLoader = Integer.parseInt(parts[4]);
- className = vmTypeToLanguage(parts[5]).intern();
+ className = vmTypeToLanguage(decode(parts[5])).intern();
time = Long.parseLong(parts[6]);
}
+
+ /**
+ * Decode any escaping that may have been written to the log line.
+ *
+ * Supports unicode-style escaping: \\uXXXX = character in hex
+ *
+ * @param rawField the field as it was written into the log
+ * @result the same field with any escaped characters replaced
+ */
+ String decode(String rawField) {
+ String result = rawField;
+ int offset = result.indexOf("\\u");
+ while (offset >= 0) {
+ String before = result.substring(0, offset);
+ String escaped = result.substring(offset+2, offset+6);
+ String after = result.substring(offset+6);
+
+ result = String.format("%s%c%s", before, Integer.parseInt(escaped, 16), after);
+
+ // find another but don't recurse
+ offset = result.indexOf("\\u", offset + 1);
+ }
+ return result;
+ }
/**
* Converts a VM-style name to a language-style name.
*/
- static String vmTypeToLanguage(String typeName) {
+ String vmTypeToLanguage(String typeName) {
+ // if the typename is (null), just return it as-is. This is probably in dexopt and
+ // will be discarded anyway. NOTE: This corresponds to the case in dalvik/vm/oo/Class.c
+ // where dvmLinkClass() returns false and we clean up and exit.
+ if ("(null)".equals(typeName)) {
+ return typeName;
+ }
+
if (!typeName.startsWith("L") || !typeName.endsWith(";") ) {
- throw new AssertionError("Bad name: " + typeName);
+ throw new AssertionError("Bad name: " + typeName + " in line " + sourceLineNumber);
}
typeName = typeName.substring(1, typeName.length() - 1);