Add support to smali for a .source directive with no source file

This commit is contained in:
Ben Gruver 2013-04-18 00:27:16 -07:00
parent 3e4e5ec7a4
commit b6435e7a47
4 changed files with 4 additions and 5 deletions

View File

@ -49,7 +49,6 @@ public class SetSourceFileMethodItem extends DebugMethodItem {
@Override
public boolean writeTo(IndentingWriter writer) throws IOException {
//TODO: make sure smali can handle an empty .source directive
writer.write(".source");
if (sourceFile != null) {

View File

@ -269,7 +269,7 @@ public class DebugInfoPool {
public void emitSetSourceFile(@Nonnull SetSourceFile setSourceFile) throws IOException {
emitAdvancePC(setSourceFile.getCodeAddress());
writer.write(9);
writer.write(dexFile.stringPool.getIndexNullable(setSourceFile.getSourceFile()));
writer.writeUleb128(dexFile.stringPool.getIndexNullable(setSourceFile.getSourceFile()) + 1);
}
private static final int LINE_BASE = -4;

View File

@ -807,8 +807,8 @@ epilogue_directive
-> ^(I_EPILOGUE[$start, "I_EPILOGUE"] I_ADDRESS[$start, Integer.toString($method::currentAddress)]);
source_directive
: SOURCE_DIRECTIVE STRING_LITERAL
-> ^(I_SOURCE[$start, "I_SOURCE"] STRING_LITERAL I_ADDRESS[$start, Integer.toString($method::currentAddress)]);
: SOURCE_DIRECTIVE STRING_LITERAL?
-> ^(I_SOURCE[$start, "I_SOURCE"] STRING_LITERAL? I_ADDRESS[$start, Integer.toString($method::currentAddress)]);
instruction_format12x
: INSTRUCTION_FORMAT12x

View File

@ -702,7 +702,7 @@ epilogue returns[DebugItem debugItem]
};
source returns[DebugItem debugItem]
: ^(I_SOURCE string_literal address)
: ^(I_SOURCE string_literal? address)
{
$debugItem = new ImmutableSetSourceFile($address.address, $string_literal.value);
};