use of org.jf.dexlib2.iface.debug.DebugItem in project smali by JesusFreke.
the class DexWriter method writeDebugItem.
private int writeDebugItem(@Nonnull DexDataWriter writer, @Nonnull DebugWriter<StringKey, TypeKey> debugWriter, @Nullable Iterable<? extends StringKey> parameterNames, @Nullable Iterable<? extends DebugItem> debugItems) throws IOException {
int parameterCount = 0;
int lastNamedParameterIndex = -1;
if (parameterNames != null) {
parameterCount = Iterables.size(parameterNames);
int index = 0;
for (StringKey parameterName : parameterNames) {
if (parameterName != null) {
lastNamedParameterIndex = index;
}
index++;
}
}
if (lastNamedParameterIndex == -1 && (debugItems == null || Iterables.isEmpty(debugItems))) {
return NO_OFFSET;
}
numDebugInfoItems++;
int debugItemOffset = writer.getPosition();
int startingLineNumber = 0;
if (debugItems != null) {
for (org.jf.dexlib2.iface.debug.DebugItem debugItem : debugItems) {
if (debugItem instanceof LineNumber) {
startingLineNumber = ((LineNumber) debugItem).getLineNumber();
break;
}
}
}
writer.writeUleb128(startingLineNumber);
writer.writeUleb128(parameterCount);
if (parameterNames != null) {
int index = 0;
for (StringKey parameterName : parameterNames) {
if (index == parameterCount) {
break;
}
index++;
writer.writeUleb128(stringSection.getNullableItemIndex(parameterName) + 1);
}
}
if (debugItems != null) {
debugWriter.reset(startingLineNumber);
for (DebugItem debugItem : debugItems) {
classSection.writeDebugItem(debugWriter, debugItem);
}
}
// write an END_SEQUENCE opcode, to end the debug item
writer.write(0);
return debugItemOffset;
}
use of org.jf.dexlib2.iface.debug.DebugItem in project smali by JesusFreke.
the class ClassPool method internDebug.
private void internDebug(@Nonnull Method method) {
for (MethodParameter param : method.getParameters()) {
String paramName = param.getName();
if (paramName != null) {
dexPool.stringSection.intern(paramName);
}
}
MethodImplementation methodImpl = method.getImplementation();
if (methodImpl != null) {
for (DebugItem debugItem : methodImpl.getDebugItems()) {
switch(debugItem.getDebugItemType()) {
case DebugItemType.START_LOCAL:
StartLocal startLocal = (StartLocal) debugItem;
dexPool.stringSection.internNullable(startLocal.getName());
dexPool.typeSection.internNullable(startLocal.getType());
dexPool.stringSection.internNullable(startLocal.getSignature());
break;
case DebugItemType.SET_SOURCE_FILE:
dexPool.stringSection.internNullable(((SetSourceFile) debugItem).getSourceFile());
break;
}
}
}
}
Aggregations